Usage
Methods for using in AppDelegate
Override the AppDelegate application methods as follows:
#import <P101XP/P101XP.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return [P101XP didFinishLaunchingWithOptions:application launchOptions:launchOptions];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [P101XP openUrl:application url:url sourceApplication:sourceApplication annotation:annotation];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[P101XP didRegisterForRemoteNotificationsWithDeviceToken:application deviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[P101XP didReceiveRemoteNotification:application userInfo:userInfo];
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [P101XP application:application supportedInterfaceOrientationsForWindow:window];
}
Initializing the SDK
To initialize the SDK, you need to call [P101XP initialize:self] in viewDidAppear method of the main view controller of your application.
#import <P101XP/P101XP.h>
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[P101XP initialize:self];
}
Handling SDK events
To handle SDK events, implement the methods of the P101XPDelegate delegate.
#import <P101XP/P101XP.h>
// The method is called after the authorization event.
// If authorization succeeds, the token is passed to the method, in the event of an error - error.
- (void)p101xpOnAuthorizeResult:(P101XPToken *)token error:(NSError *)error;
Errors
You can get the following errors with error.code for NSError, where code int is the value from the enumeration P101XPCodeError
Constant | Description |
---|---|
TypeCanceled | User has canceled an action |
Connection | User doesn't have an internet connection |
NotInitialized | Initialization hasn't completed or wasn't called |
PaymentProcessing | Payment in process and hasn't been processed yet |
User authorization
The result of the authorization or an error is passed to method 101xpOnAuthorizeResult of the delegate P101XPDelegate.
- By default, the method uses guest authorization
- In case the time of using guest authorization has expired (24 hours from the time of the first authorization), the "Save Game Progress" window is displayed
- If a user has been authorized before, then the token refreshes by calling p101xpOnAuthorizeResult
[P101XP authorize];
Show profile
The result of the authorization or an error is passed to method p101xpOnAuthorizeResult of the delegate P101XPDelegate.
[P101XP showProfile];
Logout event
To handle this event use p101xpOnLogout method of P101XPDelegate.
- (void)p101xpOnLogout;
Initialization result event (optional)
To handle this event use p101xpOnInitializeResult method of P101XPDelegate.
- (void)p101xpOnInitializeResult:(NSError *)error;