Integrate SDK¶
Before you begin¶
- You must Install Soha SDK.
- You have downloaded and installed the
.p12
and.mobileprovision
files provided by SohaGame. - You must complete the Configure SDK Info
Initializing the iOS SDK¶
Import dependencies¶
Import SohaSDK
and set SohaDelegate to listen SDK events:
AppDelegate.h
#import <SohaSDK/SohaSDK.h>
@interface AppDelegate: UIResponder<UIApplicationDelegate,SohaDelegate>
@end
Initialize the SDK¶
Starting the SDK. In didFinishLaunchingWithOptions
, call startWithDelegate:application:launchOptions:language:
:
AppDelegate.m
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[SohaSDK startWithDelegate:self
application:[UIApplication sharedApplication]
launchOptions:launchOptions
language:@"vi"];
}
@end
Danger
The startWithDelegate
method should be called only one. Calling it multiple times may result in unpredictable errors.
Implementing SDK events¶
Through the use of SohaDelegate, you can listen for lifecycle events, such as when logged out or the status of the purchase.
-(void)sohaDidLogoutSuccess:(SohaUser *)user{
// Called after logging out the current user
}
-(void)sohaDidDeleteAccountSuccess{
// Called after successful user deletion
}
-(void)sohaDidPurchaseSuccess:(SohaTransaction *)transaction{
// Called after successful completion of in-app purchase
}
-(void)sohaDidPurchaseFailed:(SohaTransaction *)transaction purchaseError:(NSString *)error{
// Called after a failed in-app purchase
}
Listen App Delegate Events¶
Implement all the following methods of app delegate:
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
return [SohaSDK application:app
openURL:url
options:options];
}
Change SDK language¶
When the application changes the language, update the SDK language with the following method: