Location Permission
Helps customers to enable location services on the device.
Description
The requestLocationPermission() action triggers the native permission prompt on the user's device, allowing your app to request access to GPS and network-based location data.
This action is used to provide location-aware features, such as finding the nearest physical store or calculating shipping distances. When invoked, the device will display the OS-native permission page (iOS/Android), usually offering options like "Allow While Using App" or "Allow Once."
Function Description
await Superfans.actions.requestLocationPermission()Structure of Response
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Action executed" } |
| Failed | { "status": "failed", "message": "Action not executed " } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
async function handleRequestPermission() {
await Superfans.actions.requestLocationPermission();
}Best Practices
- Transparency: Clearly explain the benefit of sharing location (e.g., "Find the nearest pickup point").
- Timing: Request location only when the user navigates to a map or store locator page.
- Check Variables: Use
Superfans.variables.device.permissions.locationto check the current state before triggering a prompt to avoid a redundant user experience.
Caveats
- On iOS, users may be prompted again by the OS after some time to confirm they still want to share their location in the background (if applicable).
- Accuracy may vary based on the user's hardware and environment (indoor vs. outdoor).
Updated 13 days ago
Did this page help you?