Starting and stopping servicesΒΆ

To start the GeoMoby service, add the following to the didFinishLaunchingWithOptions method -

/*************************
* Objective-C
*************************/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Geomoby init
    NSDictionary *tags = @{
                           @"gender" : @"female",
                           @"age" : @"25",
                           @"membership" : @"gold"
                           };
    
    // First usage of class should be createInstance
    [[Geomoby alloc] initWithAppKey:@"XXXXXXXX"];
    [[Geomoby sharedInstance]  setDevMode:true];
    [[Geomoby sharedInstance]  setUUID:@"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"];
    [[Geomoby sharedInstance]  setSilenceWindowStart:23 andStop:5];
    [[Geomoby sharedInstance]  setTags:tags];
    [[Geomoby sharedInstance]  setDelegate:self];
    
    // Geomoby start
    [[Geomoby sharedInstance] start];
    return YES;
}

/*************************
* Swift
*************************/

func initGeoMoby() {
  let application = UIApplication.shared
  let delegate = application.delegate as? AppDelegate
        
  let geomoby = Geomoby(appKey: geomobyKey)
  geomoby?.setUUID(UIDevice.current.identifierForVendor?.uuidString)
  #if DEBUG
    geomoby?.setDevMode(true)
  #endif
  geomoby?.setDelegate(delegate)
  geomoby?.getFences()

  // Start the GeoMoby SDK
  Geomoby.sharedInstance()?.start()
}

To stop the GeoMoby service, add the following to the applicationWillTerminate method -

/*************************
* Objective-C
*************************/
- (void)applicationWillTerminate:(UIApplication *)application
{
    // Geomoby stop
    [[Geomoby sharedInstance] stop];
}

/*************************
* Swift
*************************/
if Geomoby.isInitialised(){
	Geomoby.sharedInstance()?.stop()
}