getLocation
Note
Please contact Zalopay Team to be granted permission to use this functionality.Supported Version
Started support in
zpa
(Zalopay App) from version 8.26.0 and all versions of zpi
(Zalopay in Zalo App)Description
Get the user's current location. MiniApp can only get location information depending on the user's permission choice (Always allow, Allow one-time access, Do not allow)
Parameters
Param | Data type | Required | Description |
---|---|---|---|
isForceUpdate | boolean | No (default value is false ) | If the value is true , the location will be continuously updated in real time. If false , the location will be taken from cache |
Return Value
Param | Data type | Description |
---|---|---|
longitude | string | Longitude value of current location |
latitude | string | Latitude value of current location |
Error Code
Error Code | Description |
---|---|
010101 | The user refuses to grant location access |
010102 | The application cannot get the current location |
010103 | Location access request expired |
Sample Code and Sample Return Data
Sample Request:
window.zlpSdk.Device
.getLocation({ isForceUpdate: true })
.then((response) => console.log(response))
.catch((error) => console.error(error.errorCode));
Sample Response:
{
data: {
longitude: "106.745674"
latitude: "10.757318"
},
status: "success"
}