By default, Gimbal's iOS SDK will request "Always" location permission when [Gimbal start] is called. Given some of the new flexibility which has arrived for developers in iOS11, you may wish do take more control of this yourself because of how you are phasing prompts for location permission between While In Use and Always beginning with v2.73 of our iOS SDK.
Note: This functionality requires a minimum of v2.73 of our iOS SDK and replaces any FOREGROUND_ONLY_MODE permissions you may have used when calling Gimbal previously.
One-Phase Approach
If you're using the one-phase approach as seen above, nothing needs to be done - simply set your API key and start Gimbal as you normally would.
Objective C:
[Gimbal setAPIKey:@"YOUR_API_KEY_HERE"];
[Gimbal start];
Swift:
Gimbal.setAPIKey("YOUR_API_KEY_HERE")
Gimbal.start()
Two-Phase Approach
and then later...
If instead you intend to use the two phase approach as shown above where you initially ask the user to allow "While in Use" permission and then later when trust has been established, or when new functionality has been unlocked, "Always" permission, you can instruct the Gimbal iOS SDK to not ask for permission on your behalf. To do this, you must call setAPIKey with the MANAGE_PERMISSIONS option flag.
Objective C:
[Gimbal setAPIKey:@”YOUR_API_KEY” options:@{@"MANAGE_PERMISSIONS":@NO}];
Swift:
Gimbal.setAPIKey("YOUR_API_KEY", options: ["MANAGE_PERMISSIONS":false])
Typically before you start Gimbal, you will also then use CLLocationManager to request location authorization while the app is in use.
Objective C:
@property CLLocationManager *locationManager;
self.locationManager = [[CLLocationManager alloc] init];
[self.locationManager requestWhenInUseAuthorization];
Swift:
let manager = CLLocationManager()
manager.requestWhenInUseAuthorization()
And then you should start Gimbal:
Objective C:
[Gimbal start];
Swift:
Gimbal.start()
Finally, when you reach the second phase prompt and are ready to prompt for 'Always' authorization, you would typically do the following:
Objective C:
[self.locationManager requestAlwaysAuthorization];
Swift:
manager.requestAlwaysAuthorization()
At this point, Gimbal will recognize that the location permission has been changed and will start monitoring places 'Always' instead of just 'While in Use'.
Comments
0 comments
Article is closed for comments.