Preparing your app
First, we need to request location permissions from users
This is a required step that requests the necessary permissions and explains to the user why these permissions are being requested. The example text below can be used as a default; any changes to this text should be reviewed and approved by the client.
Add the following entries into your app's Info.plist file :
Privacy - Location When In Use Usage Description (NSLocationWhenInUseUsageDescription)
Default string:
Allow While Using App to take full advantage of personalized notifications for branch details, community events and possible fraud activity
Privacy - Location Always and When In Use Usage Description (NSLocationAlwaysAndWhenInUseUsageDescription)
Default string:
Please tap Always Allow to continue taking full advantage of personalized notifications for branch details, community events and possible fraud activity
Adding Location Request code to your app
Once the proper plist entries are set, we can add the code for the registerForLocationServices function shown below. Place this code where you would like to prompt the user for location permissions. This is typically done near the beginning of the app's lifecycle but after initialization of nudge. If the user has not yet accepted push notifications permissions then this function will not prompt for location permissions.
myNudge.registerForLocationServices(showLocationDialog: true)
Key:
-
myNudge: This would be your instance of nudge created when initializing the library -
showLocationDialog(Bool): This is an optional boolean that triggers the display of a prominent disclosure dialog box providing context to the user about why the application is requesting access to background location, before that request is actually made to the OS. This is required by the Google Play store for all Android apps, and is best practice for all iOS apps. If you choose to disable the dialog, we highly recommend that in order to deliver the best overall user adoption, you provide one of your own in conditional code wrapped around the initialization line. We would be happy to discuss the details of this with you! Please contact support@larky.com for more information.
Placing the Location Permission Request
Calling registerForLocationServices in close proximity to a Push Notification permission prompt can cause the location permission dialog to be suppressed during the initial app session, surfacing instead on the next launch.
To resolve this, ensure adequate separation between the two permission requests. This can be achieved in a number of ways; however, placing the call to registerForLocationServices inside the didRegisterForRemoteNotificationsWithDeviceToken delegate callback works particularly well, as it ensures location permission is only requested after push notification permission has been granted and prevents the call from being made unnecessarily if push notifications are declined.
Comments
0 comments
Article is closed for comments.