API Specifications
OVERVIEW
Mini APIs provide APIs for you to interact with the MoMo App Platform. Some APIs require you to submit for review before being used.
Versioning
Beta 1.0
INSTALLATION
To be able to install Mini API, please follow the document to set the NPM configuration
Mini API is installed automatically when you create Mini App. In case you want to update this package, run command below.
momo-miniapp update-packages
or run the command below to install new Mini API.
npm install @momo-miniapp/api
USAGE
To import and init MiniApi, call
/** import */
import MiniApi from "@momo-miniapp/api";
/** Call it once, only for Mini App WebView */
MiniApi.init({ appId: "", partnerCode: "" });
To call APIs
/** call API */
/** open QR code scanner */
MiniApi.scanQRCode((data) => {});
FUNCTIONS
User
Name | Description |
---|---|
requestUserConsents | Request to access user’s information. It will show a bottom drawer to request for user information |
getUserConsents | Get user info after permissions granted in requestUserConsents |
getUserAuth | Get user authentication |
Navigation
Name | Description |
---|---|
goHome | Navigate to home screen |
goBack | Back to previous screen |
openUrl | Open url with callback deep link |
openWeb | Open web url |
dismissAll | Dismiss all screen |
dismiss | Dismiss current screen and return result for previous route |
Utilities
Name | Description |
---|---|
copyToClipboard | Copy text to clipboard and show toast |
share | Share text content to other apps |
Phone
Name | Description |
---|---|
openDialer | Open dialer to call |
Image
Name | Description |
---|---|
getBase64FromUrl | Convert image from url to base64 string |
getImage | Get image from gallery or capture new image |
saveImage | Save image to gallery |
getImageSize | Get size image |
Storage
Name | Description |
---|---|
getItem | Get data from storage |
setItem | Set data to storage |
removeItem | Remove data from storage |
Permissions
Name | Description |
---|---|
requestPermission | Request permissions on the device such as camera, location,... |
checkPermission | Check permission has granted |
Location
Name | Description |
---|---|
getLocation | Get location of device |
Camera
Name | Description |
---|---|
scanQRCode | Get data from qr code |
Message, Dialog
Name | Description |
---|---|
showToast | Show toast |
hideToast | Hide toast |
showToastSuggestion | Show suggestion toast |
hideToastSuggestion | Hide suggestion toast |
showAlert | Show dialog alert |
showAction | Show bottomsheet to choose action |
Screen
Name | Description |
---|---|
showLoading | Show loading |
hideLoading | Hide loading |