次の方法で共有


iOS SDK の初期化

iOS SDK v8.0 以上のパブリッシャーは、広告要求を行う前に Mobile SDK を初期化する必要があります。 Mobile SDK for iOS SDK v8.0 以降を使用する場合は、他の SDK 操作の前に init() メソッドを呼び出す必要があります。 この初期化がないと、Ad 要求は実行されず、SDK によって例外がスローされます。

API 署名

SDK を初期化するための API 署名は、Xandr Ad を使用して公開されます。 例:

/**
 * 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;

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
    }
}