Partager via


Initialisation du KIT de développement logiciel (SDK) iOS v8.0

Les éditeurs avec le KIT de développement logiciel (SDK) iOS v8.0 doivent initialiser le Kit de développement logiciel (SDK) mobile avant d’effectuer une demande publicitaire. Lors de l’utilisation du Kit de développement logiciel (SDK) mobile pour iOS SDK v8, la init() méthode doit être appelée avant toute autre opération du SDK. Sans cette initialisation, aucune demande d’annonce ne sera effectuée et le SDK lèverait une exception.

Signature d’API

La signature d’API pour l’initialisation du KIT de développement logiciel (SDK) est exposée à l’aide de Xandr Ad. Par exemple :

/**
 * Initialize Xandr Ads SDK
 * @param memberId for initializing the Xandr SDK
 * @param preCacheRequestObjects provides flexibility to pre-cache content, such as fetch userAgent, fetch IDFA and activate OMID. Pre-caching will make future ad requests faster.
 * @param completionHandler The completion handler to call when the init request is complete
 * */
- (void)initWithMemberID:(NSInteger) memberId
        preCacheRequestObjects:(BOOL)preCacheRequestObjects
        completionHandler: (XandrAdInitCompletion _Nullable)completionHandler;

Exemples

Objective-C

@implementation AppDelegate
 
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
     
    // ideally initialize Xandr SDK inside AppDelegate before calling any other SDK methods
    [[XandrAd sharedInstance] initWithMemberID:1234 preCacheRequestObjects:YES completionHandler:^(BOOL success) {
            if(success){
                NSLog(@"XandrAd init Complete");
            }
    }];
    return YES;
}

Swift

class AppDelegate: UIResponder, UIApplicationDelegate {
 
    var window: UIWindow?
 
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 
        // ideally initialize Xandr SDK inside AppDelegate before calling any other SDK methods
        XandrAd.sharedInstance().initWithMemberID(1234, preCacheRequestObjects: true) { initComplete in
            if(initComplete){
                print("XandrAd init Complete")
            }
        }
        return true
    }
}