Skip to content

Instantly share code, notes, and snippets.

@sessionm-docs
Created February 23, 2016 17:43
Show Gist options
  • Save sessionm-docs/671b1e7892fd178834b4 to your computer and use it in GitHub Desktop.
Save sessionm-docs/671b1e7892fd178834b4 to your computer and use it in GitHub Desktop.
MMC - Geofence integration
// Ensure app Background Modes are enabled for Location updates and Background fetch in the Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>location</string>
</array>
// Then ensure at least the Key for NSLocationAlwaysUsageDescription is present:
<key>NSLocationAlwaysUsageDescription</key>
<string></string>
// Empty string will show default iOS permission description, custom string will be displayed if entered.
// Whenever you are ready to start geofence monitoring call:
[[SMLocationManager sharedInstance] startGeofenceService];
// To refresh the regions being monitored call:
[[SMLocationManager sharedInstance] refreshGeofenceService];
// Once started, this delegate callback will inform you of the regions monitored:
- (void)sessionM:(SessionM*) didStartMonitoringRegions:(NSArray*)regions {
for (CLCircularRegion *region in regions) {
// Feel free to add these regions to any MKMap to visualize the regions being monitored.
}
}
// Whenever you want to stop geofence monitoring call:
[[SMLocationManager sharedInstance] stopGeofenceService];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment