Start GroundSage Subscription and Location Update with iOS

For receiving the GroundSage crowd density data from the system, you will need to call addGroundSageDelegate for registering the GroundSage data subscription, and then call startSubcription to start the GroundSage data update and the location update. The application will only receive regular updates of the GroundSage data when the location update indicates that the user is within the vicinity of the venue. When the user enters the vicinity of the venue, didEnterDensityRegion will get called and the application will receive GroundSage data regularly via didUpdate. When the user leaves the vicinity of the venue, didExitDensityRegion will get called and the application won't receive further GroundSage data via didUpdate.

As startSubscription will also initiate location update, typically you will need to call addLocationManagerDelegate for handling the callback of location update. Please refer to the example code for registering callbacks and starting subscription.


Swift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, IAGSManagerDelegate {

    func didUpdate(manager: IAGSManager, venueDensity: IAGSVenueDensity) {
        print("density : \(venueDensity)")
    }

    func didEnterDensityRegion(_ manager: IAGSManager, region: IARegion) {
        print("Enter region : \(region)")
    }

    func didExitDensityRegion(_ manager: IAGSManager, region: IARegion) {
        print("Exit region : \(region)")
    }

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // set your api key and api secret. You do this step through add *IAGSApiKey* and *IAGSSecretKey* to application plist
        IAGSManager.shared.setApiKey("SET YOUR API KEY HERE", andSecret: "SET YOUR SECRET KEY HERE")
        // register delegate for subscription callback
        IAGSManager.shared.addGroundSageDelegate(self)
        // register delegate for location update
        IAGSManager.shared.addLocationManagerDelegate(self)
        // start subscription
        IAGSManager.shared.startSubscription()
        return true
    }
}


Objective-c 

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    // set your api key and api secret. You do this step through add *IAGSApiKey* and *IAGSSecretKey* to application plist
    [[IAGSManager sharedManager] setApiKey:@"SET YOUR API KEY HERE" andSecret:@"SET YOUR SECRET KEY HERE"];
    // register delegate for subscription callback
    [[IAGSManager sharedManager] addGroundSageDelegate:self];
    // register delegate for location update
    [[IAGSManager sharedManager] addLocationUpdateDelegate:self];
    // start subscription
    [[IAGSManager sharedManager] startSubscription];

    return YES;
}

#pragma mark - IAGSManager delegate
- (void)didUpdate:(IAGSManager *)manager venueDensity:(IAGSVenueDensity *)venueDensity {
    NSLog(@"venueDensity = %@", venueDensity);
}

- (void)didEnterDensityRegion:(IAGSManager *)manager region:(IARegion *)region {
    NSLog(@"Enter region = %@", region);
}

- (void)didExitDensityRegion:(IAGSManager *)manager region:(IARegion *)region {
    NSLog(@"Exit region = %@", region);
}
@end