birdcash-miniprogram-sdk-alpha
v1.0.41
Published
SDK for miniprograms
Downloads
115
Readme
SDK
SDK for miniprograms
Make your webapp a super app
ESM
Load the script in the head of your HTML file and initialize the bridge
<script type="module">
import { initializeBridge } from "https://unpkg.com/birdcash-miniprogram-sdk-alpha@latest";
try {
await initializeBridge();
} catch (error) {
console.error("Bridge initialization failed:", error);
}
</script>
NPM
npm install birdcash-miniprogram-sdk-alpha
Initialize the bridge before the app is mounted, example: react
import { initializeBridge } from "birdcash-miniprogram-sdk-alpha";
initializeBridge()
.then(() => {
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
)
root.render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>,
)
})
.catch(console.error)
Typescript
npm install birdcash-miniprogram-sdk-alpha
All set :)
Usage
Set Navigation Bar
window.miniProgram?.call("setNavigationBar", {
title: "Alert",
backgroundColor: "#333",
color: "light",
});
Show Toast
window.miniProgram?.call("showToast", {
type: "success",
content: "OK Pressed",
duration: 3000,
});
Open Payment Sheet
window.miniProgram?.call(
"showPaySheet",
{
id: orderID,
},
{
success(response: any) {
window.miniProgram?.call("hideToast");
if (response.ok) {
// payment successful
}
},
failure(err) {
console.error(err);
},
completed() {},
}
);
Show Alert
window.miniProgram?.call("showAlert", {
title: "Alert",
message: "This is an alert",
});