LQSession Class Reference
Inherits from | NSObject |
Declared in | LQSession.h LQSession.m |
Overview
LQSession is a wrapper around the Geoloqi Web Service API, providing authentication and asynchronous APIs for making web services.
Tasks
Other Methods
-
+ setAPIKey:secret:
Call this method first in your application delegate to set up Geoloqi api.
-
+ application:didFinishLaunchingWithOptions:
Pass off the applicationDidFinishLaunching call to the SDK
-
+ registerDeviceToken:
Pass off the didRegisterForRemoteNotifications call to the SDK
-
+ registerForPushNotificationsWithCallback:
Call this to register for push notifications
-
+ handlePush:
If a push notification is received when your app is in the foreground, you can call this method from the app delegate and the SDK will handle everything for you
-
+ setSavedSession:
LQSession can persist a session for you in the keychain, or use the +sessionWithAccessToken below. This is the same session as [LQTracker sharedTracker]’s session.
-
+ sessionWithAccessToken:
Creates an LQSession object given an existing access token that is stored in some sort of permanent storage on the phone or an external API.
-
+ requestSessionWithUsername:password:completion:
Log in to an existing Geoloqi account given a username and password.
-
+ createAnonymousUserAccountWithUserInfo:completion:
Create a new anonymous user account. Geoloqi will have no identifying information for the user other than the properties you pass in the extraData. This will actually create a new user on the Geoloqi API. The SDK stores the session token locally so the account can be restored when the app re-launches.
-
+ createAccountWithUsername:password:extra:completion:
Create a new Geoloqi account with the requested username and password. The Geoloqi API will return an error if there is already a user with the requested username.
-
httpRequestQueue
By default, a session creates an NSOperationQueue to talk to the server. If you want your own queue, you can do that here.
property
Other Methods
-
– requestWithMethod:path:payload:
As a convenience, you can use these methods to run an arbitrary API request with the current session. Payload should be a JSON-compatible object of the type that the API is expecting (NSDictionary or NSArray) OAuth 2.0 authorization is implemented automatically.
Other Methods
-
– runAPIRequest:completion:
runAPIRequest:completion: will attempt to load the resource specified by the request parameter from the geoloqi server. If there is an error with HTTP loading or JSON deserialization, it will be return in the error paramater and responseDictionary will be nil, while the response paramater may still contain the response recieved as applicable.
Other Methods
-
– cancelRequest:
Any of methods on LQSession that return ‘id’ can be passed to this method to indicate the request is no longer necessary. It is not guaranteed that the request will not go through, however. The server may already have processed the request, so be prepared to respond accordingly.
LQSession_PushTracking Methods
-
– associatePushDeviceToken:
Associate the given push device token with the session’s account.
LQSession_Settings Methods
-
+ pushDisabled
If you don’t want to use Geoloqi’s push notification implementation, call +setPushDisabled:YES before you create an LQSession.
LQSession_UniqueDeviceIdentifier Methods
-
+ deviceIdentifier
A device identifier will be generated and stored to NSUserDefaults unless you call setDeviceIdentifier: with a different value
Properties
httpRequestQueue
By default, a session creates an NSOperationQueue to talk to the server. If you want your own queue, you can do that here.
@property (nonatomic, strong) NSOperationQueue *httpRequestQueue
Discussion
By default, a session creates an NSOperationQueue to talk to the server. If you want your own queue, you can do that here.
Declared In
LQSession.h
Class Methods
application:didFinishLaunchingWithOptions:
Pass off the applicationDidFinishLaunching call to the SDK
+ (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Discussion
Pass off the applicationDidFinishLaunching call to the SDK
Declared In
LQSession.h
createAccountWithUsername:password:extra:completion:
Create a new Geoloqi account with the requested username and password. The Geoloqi API will return an error if there is already a user with the requested username.
+ (id)createAccountWithUsername:(NSString *)username password:(NSString *)password extra:(NSDictionary *)extraData completion:(void ( ^ ) ( LQSession *session , NSError *error ))block
Discussion
Create a new Geoloqi account with the requested username and password. The Geoloqi API will return an error if there is already a user with the requested username.
Declared In
LQSession.h
createAnonymousUserAccountWithUserInfo:completion:
Create a new anonymous user account. Geoloqi will have no identifying information for the user other than the properties you pass in the extraData. This will actually create a new user on the Geoloqi API. The SDK stores the session token locally so the account can be restored when the app re-launches.
+ (id)createAnonymousUserAccountWithUserInfo:(NSDictionary *)extraData completion:(void ( ^ ) ( LQSession *session , NSError *error ))block
Discussion
Create a new anonymous user account. Geoloqi will have no identifying information for the user other than the properties you pass in the extraData. This will actually create a new user on the Geoloqi API. The SDK stores the session token locally so the account can be restored when the app re-launches.
Declared In
LQSession.h
deviceIdentifier
A device identifier will be generated and stored to NSUserDefaults unless you call setDeviceIdentifier: with a different value
+ (NSData *)deviceIdentifier
Discussion
A device identifier will be generated and stored to NSUserDefaults unless you call setDeviceIdentifier: with a different value
Declared In
LQSession.h
handlePush:
If a push notification is received when your app is in the foreground, you can call this method from the app delegate and the SDK will handle everything for you
+ (void)handlePush:(NSDictionary *)userInfo
Discussion
If a push notification is received when your app is in the foreground, you can call this method from the app delegate and the SDK will handle everything for you
Declared In
LQSession.h
pushDisabled
If you don’t want to use Geoloqi’s push notification implementation, call +setPushDisabled:YES before you create an LQSession.
+ (BOOL)pushDisabled
Discussion
If you don’t want to use Geoloqi’s push notification implementation, call +setPushDisabled:YES before you create an LQSession.
Declared In
LQSession.h
registerDeviceToken:
Pass off the didRegisterForRemoteNotifications call to the SDK
+ (void)registerDeviceToken:(NSData *)deviceToken
Discussion
Pass off the didRegisterForRemoteNotifications call to the SDK
Declared In
LQSession.h
registerForPushNotificationsWithCallback:
Call this to register for push notifications
+ (void)registerForPushNotificationsWithCallback:(void ( ^ ) ( NSData *deviceToken , NSError *error ))block
Discussion
Call this to register for push notifications
Declared In
LQSession.h
requestSessionWithUsername:password:completion:
Log in to an existing Geoloqi account given a username and password.
+ (id)requestSessionWithUsername:(NSString *)username password:(NSString *)password completion:(void ( ^ ) ( LQSession *session , NSError *error ))block
Discussion
Log in to an existing Geoloqi account given a username and password.
Declared In
LQSession.h
sessionWithAccessToken:
Creates an LQSession object given an existing access token that is stored in some sort of permanent storage on the phone or an external API.
+ (LQSession *)sessionWithAccessToken:(NSString *)inAccessToken
Discussion
Creates an LQSession object given an existing access token that is stored in some sort of permanent storage on the phone or an external API.
Declared In
LQSession.h
setAPIKey:secret:
Call this method first in your application delegate to set up Geoloqi api.
+ (void)setAPIKey:(NSString *)APIKey secret:(NSString *)APISecret
Discussion
Call this method first in your application delegate to set up Geoloqi api.
Declared In
LQSession.h
setSavedSession:
LQSession can persist a session for you in the keychain, or use the +sessionWithAccessToken below. This is the same session as [LQTracker sharedTracker]’s session.
+ (void)setSavedSession:(LQSession *)session
Discussion
LQSession can persist a session for you in the keychain, or use the +sessionWithAccessToken below. This is the same session as [LQTracker sharedTracker]’s session.
Declared In
LQSession.h
Instance Methods
associatePushDeviceToken:
Associate the given push device token with the session’s account.
- (id)associatePushDeviceToken:(NSData *)deviceToken
Discussion
Associate the given push device token with the session’s account.
Declared In
LQSession+Private.h
cancelRequest:
Any of methods on LQSession that return ‘id’ can be passed to this method to indicate the request is no longer necessary. It is not guaranteed that the request will not go through, however. The server may already have processed the request, so be prepared to respond accordingly.
- (void)cancelRequest:(id)request
Discussion
Any of methods on LQSession that return ‘id’ can be passed to this method to indicate the request is no longer necessary. It is not guaranteed that the request will not go through, however. The server may already have processed the request, so be prepared to respond accordingly.
Declared In
LQSession.h
requestWithMethod:path:payload:
As a convenience, you can use these methods to run an arbitrary API request with the current session. Payload should be a JSON-compatible object of the type that the API is expecting (NSDictionary or NSArray) OAuth 2.0 authorization is implemented automatically.
- (NSMutableURLRequest *)requestWithMethod:(NSString *)httpMethod path:(NSString *)requestPath payload:(id)object
Discussion
As a convenience, you can use these methods to run an arbitrary API request with the current session. Payload should be a JSON-compatible object of the type that the API is expecting (NSDictionary or NSArray) OAuth 2.0 authorization is implemented automatically.
Declared In
LQSession.h
runAPIRequest:completion:
runAPIRequest:completion: will attempt to load the resource specified by the request parameter from the geoloqi server. If there is an error with HTTP loading or JSON deserialization, it will be return in the error paramater and responseDictionary will be nil, while the response paramater may still contain the response recieved as applicable.
- (id)runAPIRequest:(NSURLRequest *)inRequest completion:(void ( ^ ) ( NSHTTPURLResponse *response , NSDictionary *responseDictionary , NSError *error ))block
Discussion
runAPIRequest:completion: will attempt to load the resource specified by the request parameter from the geoloqi server. If there is an error with HTTP loading or JSON deserialization, it will be return in the error paramater and responseDictionary will be nil, while the response paramater may still contain the response recieved as applicable.
Declared In
LQSession.h