Registration

Register an iOS device

Before an application instance can use the LumenPath service, it has to be registered. The registration is usually performed in didFinishLaunchingWithOptions method of the AppDelegate class.

#import <UIKit/UIKit.h>
#import <LPSensorLib/LPBeaconManagerListener.h>
....
....

NSString *path = [[NSBundle mainBundle] pathForResource:@"Config" ofType:@"plist"];
    
NSDictionary *configDictionary = [[NSDictionary alloc] initWithContentsOfFile:path];
NSDictionary *appConfigDictionary = [configDictionary valueForKey:@"application"];
NSString *appId = [appConfigDictionary valueForKey:@"lpAppId"];
NSString *appSecret = [appConfigDictionary valueForKey:@"lpAppSecret"];
NSString *apiURL = [appConfigDictionary valueForKey:@"lpApiBaseUrl"];//https://api.lumenpath.com
NSString *corrId = nil; //Correlation ID
NSString *deviceId = nil; //iOS device token

LPBeaconManager *lpBeaconManager = [[LPBeaconManager alloc]
                                    initWithBaseURL:apiURL 
                                    withApplicationId:appId
                                    withSecret:appSecret
                                    withCorrelationId:corrId
                                    withDeviceId:deviceId
                                    didComplete:^(NSString *msg, BOOL success) {
                                      //Set the listener delegate
                                      [lpBeaconManager addListener:self];
                                    }];
2326

LumenPath API configuration values in the plist file

Upon a successful registration, the SDK will automatically start monitoring the default iBeacon sensors for this application. To set up default sensors, go to LumenPath Web Application > Applications>Edit>Default Sensors and add one or more default sensors.

Use the correlationId parameter to associate the registration with a specific id. This can be set to a user's email address or a username or some other unique identifier that the application has associated with this user. The correlationId can later be used to retrieve device level analytics.

The device_id field is used to send APNS notifications to the device and must be set to the APNS device token. This is usually done by registering the application for notifications in the AppDelegate class.

UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];

....
  
  //Update LumenPath Service with the new device_token
  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    [[NSUserDefaults standardUserDefaults] setObject:deviceToken forKey:LPPushDeviceTokenKey];
    NSLog(@"Registered the following device token: %@", [self asHexString:deviceToken]);
    LPBeaconManager *lpBeaconManager = [LPBeaconManager sharedInstance];
    [lpBeaconManager setDeviceId:[self asHexString:deviceToken]];
    [lpBeaconManager updateRegistration];
}