CSSession Class Reference

Inherits from NSObject
Declared in CSSession.h

Overview

Every application integrating the Curbside SDK needs to have a valid CSSession in the application. The session should be created in the UIApplicationDelegate’s application:willFinishLaunchingWithOptions: method with a valid key/secret. The session should have a valid trackingIdentifier for the user in order to use the CSTracker/CSStoreArrivalTracker classes. This trackingIdentifier is what uniquely identifies a user in the Curbside system. In the mobile apps the trackingIdentifier is used to tag locations sent upstream. In the retailer app this is used to identify the user and send notifications as needed.

By default the CSEnvironment is set to CSEnvironmentProduction. In development mode the CSEnvironment has to be set to CSEnvironmentSandbox, otherwise APNS notification will not work as you are developing an application in XCode. Unless the app is signed with a distribution profile the APNS enviroment for the app will point to APNS development. The environment must reflect the APNS environment.

Note: Initializing the CSSession does not by itself start tracking, but preps the app for setting up tracking for the user from an external APNS notification.

  trackingIdentifier

trackingIdentifier for the user who is logged into the device. This may be nil when the app is started, but as the user logs into the app, make sure this value is set. Without this set, the tracking part will not work. This identifier is persisted across restarts.

@property (nonatomic, strong) NSString *trackingIdentifier

Discussion

trackingIdentifier for the user who is logged into the device. This may be nil when the app is started, but as the user logs into the app, make sure this value is set. Without this set, the tracking part will not work. This identifier is persisted across restarts.

When the user logs out, set this to nil, which will inturn stop tracking for both CSTracker/CSStoreArrivalTracker instances for the given device.

Declared In

CSSession.h

  smsNumber

SMS phone number for the user who is logged into the device. This may be nil when the app is started, but as the user logs into the app, make sure this value is set to the right SMS number if available.

@property (nonatomic, strong) NSString *smsNumber

Discussion

SMS phone number for the user who is logged into the device. This may be nil when the app is started, but as the user logs into the app, make sure this value is set to the right SMS number if available.

When the user logs out, set this to nil

Declared In

CSSession.h

  sessionState

The session has to be in CSSessionStateValid to be able to use CSTracker or CSStoreArrivalTracker

@property (nonatomic, readonly) CSSessionState sessionState

Declared In

CSSession.h

  delegate

The delegate object for the session. The session calls methods on this delegate as the session state changes.

@property (nonatomic, strong) id<CSSessionDelegate> delegate

Declared In

CSSession.h

+ setEnvironment:

By default the environment is Production. When developing make sure to use the Sandbox environment. The environment needs to reflect the app state - if the app is not signed with a distribution profile then this needs to be set to CSEnvironmentSandbox.

+ (void)setEnvironment:(CSEnvironment)environment

Discussion

By default the environment is Production. When developing make sure to use the Sandbox environment. The environment needs to reflect the app state - if the app is not signed with a distribution profile then this needs to be set to CSEnvironmentSandbox.

Declared In

CSSession.h

+ createSessionWithAPIKey:secret:delegate:

Consumers should be using this method to create a new session with a API key and secret. The state of the session can be checked using the sessionState property. The delegate is also notified of sessionState changes by the delegate callback.

+ (instancetype)createSessionWithAPIKey:(NSString *)apiKey secret:(NSString *)secret delegate:(id<CSSessionDelegate>)delegate

Discussion

Consumers should be using this method to create a new session with a API key and secret. The state of the session can be checked using the sessionState property. The delegate is also notified of sessionState changes by the delegate callback.

Declared In

CSSession.h

+ currentSession

This method returns the session initialized by createSessionWithAPIKey:secret: If there was no call made with createSessionWithAPIKey:apiKey secret:secret then this will return nil.

+ (instancetype)currentSession

Discussion

This method returns the session initialized by createSessionWithAPIKey:secret: If there was no call made with createSessionWithAPIKey:apiKey secret:secret then this will return nil.

Declared In

CSSession.h

– application:didFinishLaunchingWithOptions:

Informs the SDK that the application did finish launching. Make sure that you call this method from your application delegate’s application:application didFinishLaunchingWithOptions:launchOptions method.

- (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Discussion

Informs the SDK that the application did finish launching. Make sure that you call this method from your application delegate’s application:application didFinishLaunchingWithOptions:launchOptions method.

Declared In

CSSession.h

– registerDeviceToken:

Register’s the push notification token for this device with Curbside. The consuming application should register for push notification. The notifications to register for are :

- (void)registerDeviceToken:(NSData *)deviceToken

Discussion

Register’s the push notification token for this device with Curbside. The consuming application should register for push notification. The notifications to register for are :

UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeNewsstandContentAvailability

The device token for notifications is then returned in the UIApplication delegate’s application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken method. Once this is received on delegate call this method with the token to properly register the token with Curbside.

Declared In

CSSession.h

– handleDidFailToRegisterForRemoteNotifications:

Informs the SDK for the device token registration.

- (void)handleDidFailToRegisterForRemoteNotifications:(NSError *)error

Discussion

Informs the SDK for the device token registration.

Declared In

CSSession.h

– handlePushNotificationDictionary:

When the application receives push notification, forward the push notification to the session to handle. Returns YES if the push was processed by the SDK (The push was meant for the SDK) and NO otherwise.

- (BOOL)handlePushNotificationDictionary:(NSDictionary *)dictionary

Discussion

When the application receives push notification, forward the push notification to the session to handle. Returns YES if the push was processed by the SDK (The push was meant for the SDK) and NO otherwise.

Declared In

CSSession.h