Skip to content

Initialize the SDK delegate function ​

After initializing the SDK basic data, it is necessary to implement delegate methods for each delegate function in order to support "Facebook account login", "statistics of marketing data","activation of advertising media", "activation of SDK functions", etc. Features.

There are 12 initial methods for all the delegate functions. All of them must be called. They are added in the AppDelegate.m file. (Note: If there are duplicate methods after copying, please copy the method inside the method to the previous one. The same method can be), respectively:

1、application:openURL:sourceApplication:annotation: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    return [[GamedreamerManager shareInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    
    NSString *sourceApplication = [options objectForKey:UIApplicationOpenURLOptionsSourceApplicationKey];
    id annotation = [options objectForKey:UIApplicationOpenURLOptionsAnnotationKey];
    
    return [[GamedreamerManager shareInstance] application:app openURL:url sourceApplication:sourceApplication annotation:annotation];
    
}

2、applicationWillResignActive: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (void)applicationWillResignActive:(UIApplication *)application {
    [[GamedreamerManager shareInstance] applicationWillResignActive:application];
}

3、applicationDidEnterBackground: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (void)applicationDidEnterBackground:(UIApplication *)application {
    [[GamedreamerManager shareInstance] applicationDidEnterBackground:application];
}

4、applicationWillEnterForeground: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (void)applicationWillEnterForeground:(UIApplication *)application {
    [[GamedreamerManager shareInstance] applicationWillEnterForeground:application];
    
}

5、applicationDidBecomeActive: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[GamedreamerManager shareInstance] applicationDidBecomeActive:application];
}

6、applicationWillTerminate: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (void)applicationWillTerminate:(UIApplication *)application {
    [[GamedreamerManager shareInstance] applicationWillTerminate:application];
}

7、application:didRegisterForRemoteNotificationsWithDeviceToken: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
    [[GamedreamerManager shareInstance] application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

8、application:didFailToRegisterForRemoteNotificationsWithError: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    
    [[GamedreamerManager shareInstance] application:application didFailToRegisterForRemoteNotificationsWithError:error];
}

9、application:handleOpenURL: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    
    return [[GamedreamerManager shareInstance] application:application handleOpenURL:url];
}

10、application:continueUserActivity:restorationHandler: ​

  • Directly add all code copies of the next box to AppDelegate.m
objective-c
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {

    return [[GamedreamerManager shareInstance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}

11、gamedreamerNeedRelogin ​

  • This function is to achieve the Member Center point in the SDK after the call to log out of the account, quite game type account logout operation, the method inside the need to achieve the game logout effect of the code logic, this method also need to write on AppDelegate.m
objective-c
- (void)gamedreamerNeedRelogin{
    
    Need to join the game to log out the code, such as disconnect the game, go back to the login interface process
    
}

12、gamedreamerInAppActivityInfo: ​

This function retrieves in-app activity information from the iOS App Store. When a user opens the app from an App Store activity, the SDK receives the link, determines whether it is an activity deep link, and sends it to the game integration through the notification delegate. The game can parse the link and process the activity parameters.

objective-c
-(void)gamedreamerInAppActivityInfo:(NSString *)info{
    // Parse the activity link to obtain the relevant parameters.
}


After completing the above steps, the introduction, configuration, and initialization of all SDKs have been completed. Then you can call the function in the SDK. For details, please read API