Skip to content

Handling Geofence Transitions Inside Your Application (iOS)


StreetHawk SDK can notify application when a user enter or exits a geofence created on StreetHawk dashboard so that application can further extend this event to implement the desired functionality.

Consider a use case in which you wish to send a promotion code to a user after he spends some time inside your shop to encourage him to buy the product. The use case can be simply achieved by:

  1. Create a Geofence for you shop in StreetHawk console. Note this steps in independent of the code implementation and you can add or change geofences on the fly from you dashboard only.

  2. Implement StreetHawkgeofence module's notification listener SHLMEnterExitGeofenceNotification inside your application which notifies application when a user enters or exit a geofence.

  3. Implement your logic for displaying promotion code.

Code snippets

  • Add StreetHawk's Geofence module by following the steps document here.
  • Implement SHLMEnterExitGeofenceNotification notification observer.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(geofenceEnterExitHandler:) name:SHLMEnterExitGeofenceNotification object:nil];

    return YES;

- (void)geofenceEnterExitHandler:(NSNotification *)notification
    NSDictionary *geofence = notification.userInfo;
    //get properties for geofence's server id, latitude, longitude, radius, is inside.
    //register local notification which scheduled to fire in 10 mins.