Catalog Functions
USER
requestUserConsents(options, callback)
1. Function introduction
Request to access user’s information. It will show a bottom drawer to request for user information
To use this function, please follow the Request Permission document
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
options | object | yes | An object with “permissions” field is an array for requested permission |
callback | function | yes | Callback function with data from the request |
Options object
Field | Data type | Required | Description |
---|---|---|---|
permissions | array | yes | An array contain object represent as a permission. |
Permission object
Field | Data type | Required | Description | Value |
---|---|---|---|---|
role | string | yes | Permission role | "address" | "addressKyc" | "city" | "countryCode" | "countryName" | "currentAddress" | "deviceName" | "deviceOs" | "dobKyc" | "email" | "fullNameKyc" | "gender" | "genderKyc" | "loyaltyPoints" | "maritalStatus" | "microShop" | "name" | "nationality" | "nationalityKyc" | "nickname" | "phone" | "preferedLanguage" | "professional" |
required | boolean | no | Set a permission role to be required sharing from user | true | false |
Response
Params | Data type | Description |
---|---|---|
data | object | User’s data |
status | object | Status of requested permission |
3. Sample Request & Response
Request
MiniApi.requestUserConsents({
“permissions”: [
{
"role": “name”,
"require": true
},
{
"role": “phone”
},
{
"role": “email”,
}
]
}, (response) => {
console.log(response)
// Data handle for old and new Platform version
const name = response?.name || response?.data?.name;
const phone = response?.phone || response?.data?.phone;
const email = response?.email || response?.data?.email;
})
Response
// Case 1: User accept sharing some data
{
"data": {
"name": "John Doe",
"phone": "09xxxxxxxx"
},
"status": {
"email": "denied",
"name": "granted",
"phone": "granted"
}
}
// Case 2: User cancelled sharing data
{
"data" : {}
"status" : "cancelled"
}
// Case 3: AppId doesn’t have permission to request sharing data / Wrong appId. Go to developers.momoapp.vn to request permission
{
"data" : {},
"status" : {}
}
4. Error code & handle exception
Error Code | Description |
---|---|
-1 | No permission |
getUserConsents(options, callback)
1. Function introduction
Access user’s information that is already granted. Data will be returned through callback
To use this function, please follow the Request Permission document
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
options | object | yes | An object with “permissions” key as an array for permission |
callback | function | yes | Callback function with data from the request |
Options object
Field | Data type | Required | Description |
---|---|---|---|
permissions | array | yes | An array contain object represent as a permission. |
Permission object
Field | Data type | Required | Description | Value |
---|---|---|---|---|
role | string | yes | Permission role | "address" | "addressKyc" | "city" | "countryCode" | "countryName" | "currentAddress" | "deviceName" | "deviceOs" | "dobKyc" | "email" | "fullNameKyc" | "gender" | "genderKyc" | "loyaltyPoints" | "maritalStatus" | "microShop" | "name" | "nationality" | "nationalityKyc" | "nickname" | "phone" | "preferedLanguage" | "professional" |
Response
Params | Data type | Description |
---|---|---|
data | object | User’s data |
status | object | Status of requested permission |
3. Sample Request & Response
Request
MiniApi.getUserConsents({
“permissions”: [
{
"role": “name”,
},
{
"role": “phone”
},
{
"role": “email”,
},
]
}, (data) => {
// Data handling
const name = response?.data?.name;
const phone = response?.data?.phone;
const email = response?.data?.email;
})
Response
{
"data": {
"name": "John Doe",
"phone": "09xxxxxxxx"
},
"status": {
"email": "denied",
"name": "granted",
"phone": "granted"
}
}
4. Error code & handle exception
Error Code | Description |
---|---|
-1 | No permission |
getUserAuth(callback)
1. Function introduction
Get User Authentication
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
callback | function | Callback |
Response
Params | Data type | Description |
---|---|---|
authCode | string | Auth code |
miniAppUserId | string | Id of Mini App user |
partnerUserId | string | Id of partner user |
3. Sample Request & Response
Request
MiniApi.getUserAuth(callback);
Response
{
authCode: "eyJ...";
miniAppUserId: "MRk...";
partnerUserId: "MRv...";
}
NAVIGATION
goHome(callback)
1. Function introduction
Navigate to home screen
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
callback | callback | allback |
3. Sample Request & Response
Request
MiniApi.goHome(callback);
Response
N/A
goBack(callback)
1. Function introduction
Navigate to previous screen
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.goBack(callback);
Response
N/A
openURL(callbackDeeplink)
1. Function introduction
Open url with callback deep link
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
callbackDeepLink | callback | Callback |
3. Sample Request & Response
Request
MiniApi.openURL(callbackDeepLink);
Response
N/A
openWeb(params, callback)
1. Function introduction
Open web url
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
params | object | {url,html,title} | |
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.openWeb(
{
url: "https://www.google.com",
title: "google"
},
callback
);
Response
N/A
dismissAll(callback)
1. Function introduction
Dismiss all screen
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.dismissAll(callback);
Response
N/A
dismiss(result, callback)
1. Function introduction
Dismiss current screen and return result for previous route
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
result | object | Result | |
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.dismiss({resultCode:”001”},callback);
Response
N/A
UTILITIES
copyToClipboard(text, toastMsg)
1. Function introduction
Copy text to Clipboard and show toast
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
text | string | Text to save to Clipboard | |
toastMsg | string | Text to show on toast |
3. Sample Request & Response
Request
MiniApi.copyToClipboard("Text to copyToClipboard","Text to show toast");
Response
N/A
share(data, callback)
1. Function introduction
Share text content to other apps
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
data | |||
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.share("Text to share",callback);
Response
N/A
PHONE
openDialer(phone)
1. Function introduction
Open Dialer to call
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
phone | text | yes | Phone number |
3. Sample Request & Response
Request
MiniApi.openDialer("0xxxxxxxx");
Response
4. Sample Request & Response
Cannot catch error and exception. If input wrong argument’s type will crash app
IMAGE
getBase64FromUrl(url, callback)
1. Function introduction
Convert image from url to base64 string
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
url | string | Url of image | |
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.getBase64FromUrl("https://example.png", (data) => {
console.log(data);
})
Response
Params | Data type | Description |
---|---|---|
data | string | Base64 string |
4. Sample Request & Response
No error and exception. If input wrong argument’s type will crash app
getImage(options, callback)
1. Function introduction
Get image from gallery or capture new image
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
options | object | {type: "camera"/"album", editable: true/false} | |
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.getImage({
type: "camera",
editable: true
}, (data) => {
console.log(data);
})
Response
Params | Data type | Description |
---|---|---|
data | string | Base64 string |
saveImage(base64Image, callback)
1. Function introduction
Save image to gallery
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
base64Image | string | ||
callback | callback |
3. Sample Request & Response
Request
MiniApi.saveImage(data, (res) => {
console.log(res);
})
Response
Params | Data type | Description |
---|---|---|
data | boolean | true if image is saved in gallery, false otherwise |
getImageSize(uri, callback)
1. Function introduction
Get size image
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
uri | string | yes | |
callback | callback | callback |
3. Sample Request & Response N/A
STORAGE
getItem(key, callback)
1. Function introduction
Get data from Storage
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
key | string | yes | Key |
callback | callback | Return value |
3. Sample Request & Response
Request
MiniApi.getItem('API', (data) => {
console.log(data);
})
Response
Params | Data type | Description |
---|---|---|
data | string | Value of the key |
setItem(key, value)
1. Function introduction
Set data to Storage
2. Function request & response params
Params | Data type | Required | Description |
---|---|---|---|
key | string | yes | Key |
value | string | yes | Value |
3. Sample Request & Response
Request
MiniApi.setItem(‘API’, ‘hello’)
Response
void
removeItem(key)
1. Function introduction
Remove data from Storage
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
key | string | Key |
3. Sample Request & Response
Request
MiniApi.removeItem(‘API’)
Response
void
PERMISSIONS
requestPermission(permission, callback)
1. Function introduction
Request permissions on the device such as camera, location,...
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
permission | string | “camera” | “photo” | “storage” | “location” | “contacts” | |
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.requestPermission('photo', (data) => {
console.log(data);
})
Response
Params | Data type | Description |
---|---|---|
data | string | ‘granted’ if allow, ‘denied’ if not allow, ‘unavailable’ if the permission is not exist |
checkPermission(permission, callback)
1. Function introduction
Check permission has granted
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
permission | string | “camera” | “photo” | “storage” | “location” | “contacts” | |
callback | callback | callback |
3. Sample Request & Response
Request
MiniApi.checkPermission(‘camera’, (data) => {
console.log(data);
})
Response
Params | Data type | Description |
---|---|---|
data | string | ‘granted’ if allow, ‘denied’ if not allow, ‘unavailable’ if the permission is not exist |
LOCATION
getLocation(callback)
1. Function introduction
Get location of device
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
callback | callback | Return device’s location |
3. Sample Request & Response
Request
MiniApi.getLocation((data) => {
console.log(data);
})
Response
{
"mocked": boolean,
"timestamp": number,
"coords": {
"speed": number,
"heading": number,
"altitude": number,
"accuracy": number,
"longitude": float,
"latitude": float
}
}
Params | Data type | Description |
---|---|---|
data | object | (above code block) |
CAMERA
scanQRCode(data, callback)
1. Function introduction
Get data from qr code
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
data | deeplink | ||
callback | callback | Callback |
3. Sample Request & Response
Request
MiniApi.scanQRCode(data, (result) => {
console.log(data);
})
Response
Params | Data type | Description |
---|---|---|
data | object | Data in the deeplink |
MESSAGE, DIALOG
showToast(...args)
1. Function introduction
Show Toast
2. Function request & response params
Request
Param | Type | Required | Description |
---|---|---|---|
object | object | yes | Object contains field like description, type, and duration |
description | string | yes | Toast description |
type | string | yes | Toast type |
duration | number | yes | Toast duration |
Reponse
Show toast at the end of the screen
3. Sample Request & Reponse
Request
MiniApi.showToast({
description: "Successfully",
type: "success",
duration: 2000
});
Response
hideToast()
1. Function introduction
Hide Toast
2. Sample Request & Response
Request
MiniApi.hideToast();
showToastSuggestion(...args)
1. Function introduction
Show suggestion toast
2. Function request
Request
Params | Data Type | Required | Description |
---|---|---|---|
type | string | yes | Type of the call-to-action. Value: share | addFavorite | addShortcut. |
duration | number | no | Suggestion toast's duration |
3. Sample Request & Response
Request
MiniApi.showToastSuggestion({
type: 'addShortcut',
duration: 2000,
},callback);
Response
hideToastSuggestion()
1. Function introduction
Hide suggestion toast
2. Sample Request
Request
MiniApi.hideToastSuggestion()
showAlert(title, message, buttonTitles, callback)
1. Function introduction
Show dialog alert
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
title | string | Title | |
message | string | Message | |
buttonTitles | array | Button titles | |
callback | callback | Return index of CTAs of dialog which be clicked |
3. Sample Request & Response
Request
MiniApi.showAlert(
"hello",
"hello world",
["OK", "Cancel"],
(data) => {
console.log(data);
}
)
Response
Params | Data type | Description |
---|---|---|
data | number | Return 0 or 1 based on the action chosen |
showAction(title, buttonTitles, callback)
1. Function introduction
Show bottom sheet to choose action
2. Function request & response params
Request
Params | Data type | Required | Description |
---|---|---|---|
title | string | Title | |
buttonTitles | array | Button titles | |
callback | callback | Return index of CTAs of bottomSheet which be clicked |
3. Sample Request & Response
Request
MiniApi.showAction(
"hello",
["OK", "Cancel"],
(data) => {
console.log(data);
}
)
Response
Params | Data type | Description |
---|---|---|
data | number | Return 0 or 1 based on the action chosen |
SCREEN
showLoading()
1. Function introduction
Show loading
2. Function request & response params |
3. Sample Request & Response
Request
MiniApi.showLoading()
Response
void
hideLoading()
1. Function introduction
Hide loading
2. Function request & response params |
3. Sample Request & Response
Request
MiniApi.hideLoading()
Response
void