Get Gimbal up and running in your iOS App.
Important This guide assumes you have a iOS project setup with Gimbal. Please folllow Gimbal Quick Start guide if you have not yet setup an iOS project with Gimbal.
The following steps will allow you to use Gimbal Geofencing features in your application.
Create a geofence for your current location so you will see a place event trigger when your application starts.
Note Make sure the geofence you create is at your current location if you want it to trigger when your app launches.
To receive geofence events you must add the <QLContextPlaceConnectorDelegate>
protocol to your AppDelegate.h
and add a QLContextPlaceConnector
property.
#import <ContextLocation/QLContextPlaceConnector.h> @interface AppDelegate : UIResponder <UIApplicationDelegate, QLContextPlaceConnectorDelegate> ... @property (nonatomic) QLContextPlaceConnector *placeConnector; ...
Add the didGetPlaceEvent:
method to your AppDelegate.m
class. This method
is
called when a geofence event is detected.
#import <ContextLocation/QLPlaceEvent.h> #import <ContextLocation/QLPlace.h> ... - (void)didGetPlaceEvent:(QLPlaceEvent *)placeEvent { NSLog(@"did get place event %@", [placeEvent place].name); }
To receive the geofence events you must set your AppDelegate
as the delegate on the
QLContextPlaceConnectorDelegate
.
Do this in your application: didFinishLaunchingWithOptions:
method (after the Core Connector is enabled).
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... self.placeConnector = [[QLContextPlaceConnector alloc] init]; self.placeConnector.delegate = self; ...
Note When you launch the application you will have to accept the Gimbal Terms of Service.
Once Gimbal detects you are in the geofence you created in the Gimbal Manager you will see a log entry that looks like this.
2013-03-28 11:17:58.947 myproduct[11532:907] did get place event My Place
For additional details on how to leverage the SDK functionality, refer to the sample applications and documentation included in the zip file provided.