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

StatusResponse
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

  1. Transparency: Clearly explain the benefit of sharing location (e.g., "Find the nearest pickup point").
  2. Timing: Request location only when the user navigates to a map or store locator page.
  3. Check Variables: Use Superfans.variables.device.permissions.location to check the current state before triggering a prompt to avoid a redundant user experience.

Caveats

  1. 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).
  2. Accuracy may vary based on the user's hardware and environment (indoor vs. outdoor).

Did this page help you?