Skip to main content

iOS - 进阶设定

帮助您取得更多广告功能

设定 Audio Session


为配合第三方追踪要求,Vpon SDK 会在初始化时,将 App 的Audio Session Category 设为AVAudioSessionCategoryPlayBack / OptionsWithMixWithOthers (当有音乐要播放时,App 将以混音形式播放音乐,且不会受实体静音键的影响)。您可以在SDK初始化后,重新指定及启用其他 Audio Session Category。

如果您不希望 Vpon SDK 更动 Audio Session,请在初始化时,加入以下程式片段。

Objective-C

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Vpon SDK initialization
    VpadnAdConfiguration *config = [VpadnAdConfiguration sharedInstance];
    config.logLevel = VpadnLogLevelDefault;
    config.audioManager.isAudioApplicationManaged = YES;
    // set YES, SDK won't set and activate the audio session
    [config initializeSdk];

    return YES;
}

Switft

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:      
    [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        // Vpon SDK initialization
        let config = VpadnAdConfiguration.sharedInstance()
        config.logLevel = .default
        config.audioManager.isAudioApplicationManaged = true
        // set true, SDK won't set and activate the audio session
        config.initializeSdk()

        return true
    }

(Optional) 通知 SDK Audio Session 使用状况


我们建议您在重新指定 Audio Session Category 及结束影音播放时,呼叫以下 Function,让 SDK 知道您是否正在控制 Audio Session 。

- (void) noticeApplicationAudioWillStart;
// Call this function to let SDK know that you will set and activate a new Audio Session Category

- (void) noticeApplicationAudioDidEnded;
// Call this function to let SDK know that your media is finish, SDK will set and activate the Audio Session Category to AVAudioSessionCategoryPlayBack / OptionsWithMixWithOthers

Note: noticeApplicationAudioWillStart 及 noticeApplicationAudioDidEnded 不适用于透过 Mediation 串接 Vpon SDK 者。

自定义广告请求参数


您可以在建立广告请求时,选择项地加入以下自定义的参数,让 Vpon 可以用更精准的方式投放广告

Objective-C

VpadnAdRequest *request = [[VpadnAdRequest alloc] init];

[request setAutoRefresh:YES];
// Only available for Banner Ad, will auto refresh ad if set YES
[request setTestDevices:@[[ASIdentifierManager sharedManager].advertisingIdentifier.UUIDString]];
// Set your test device's IDFA here if you're trying to get Vpon test ad

[request setUserInfoGender:VpadnGenderUnspecified];
// Set user's gender if available
[request setUserInfoBirthdayWithYear:2000 Month:1 andDay:1];
// Set user's birthday if available

[request setMaxAdContentRating:VpadnMaxAdContentRatingUnspecified];
// To set up the maximum content rating filter
[request setTagForUnderAgeOfConsent:VpadnTagForUnderAgeOfConsentUnspecified];
// To set up if the ads will be displayed only to the specific ages of audience
[request setTagForChildDirectedTreatment:VpadnTagForChildDirectedTreatmentUnspecified];
// To set up if the ads will be displayed to childern specific

[request addKeyword:@"keywordA"];
[request addKeyword:@"keyword1:value1"];

Swift

let request = VpadnAdRequest.init()

request.setAutoRefresh(true)
// Only available for Banner Ad, will auto refresh ad if set true
request.setTestDevices([ASIdentifierManager.shared().advertisingIdentifier.uuidString])
// Set your test device's IDFA here if you're trying to get Vpon test ad

request.setUserInfoGender(.genderUnspecified)
// Set user's gender if available
request.setUserInfoBirthdayWithYear(2000, month: 01, andDay: 01)
// Set user's birthday if available

request.setMaxAdContentRating(.general)
// To set up the maximum content rating filter
request.setTagForUnderAgeOfConsent(.false)
// To set up if the ads will be displayed only to the specific ages of audience
request.setTagForChildDirectedTreatment(.false)
// To set up if the ads will be displayed to childern specific

request.addKeyword("keywordA")
request.addKeyword("keyword1:value1")

回传内容资讯


您可以透过 setContentUrlsetContentData 将页面内容资讯透过 SDK 发给 Vpon

Note: 此功能适用于 Vpon SDK v5.1.1 及以上版本

Objective-C

[request setContentUrl:@"https://www.vpon.com.tw/"];
// Set content page url
[request setContentData:@{@"key1": @(1), @"key2": @(YES), @"key3": @"name", @"key4": @(123.31)}];
// Set content page data with an array of key-value

Swift

request.setContentUrl("https://www.google.com.tw/")
// Set content page url
request.setContentData(["key1": 1, "key2": true, "key3": "name", "key4": 123.31]) 
// Set content page data with an array of key-value