### Install Pods via Command Line Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/quick-start/install-fivesdk.html Run this command in your terminal after updating your Podfile to install the FiveAd SDK. ```bash pod install ``` -------------------------------- ### Complete AndroidManifest Example Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/quick-start/setup-manifest.html This is a full example of an AndroidManifest.xml file with the necessary configurations for an application, including hardware acceleration enabled on the application tag. ```xml ``` -------------------------------- ### Legacy Custom Layout Ad Loading (Kotlin) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/ad-loader-api-migration.html Example of loading a custom layout ad using the legacy method in Kotlin. Requires implementing FiveAdLoadListener. ```kotlin class MyActivity : Activity(), FiveAdLoadListener { // 広告を表示するためのコンテナビュー private lateinit var fiveAdCustomLayoutHolder: FrameLayout // カスタムレイアウト広告オブジェクト private var fiveAdCustomLayout: FiveAdCustomLayout? = null // ロード処理 private fun loadFiveAdCustomLayout() { fiveAdCustomLayout = FiveAdCustomLayout(this,"your-slot-id", 120) fiveAdCustomLayout?.setLoadListener(this) fiveAdCustomLayout?.loadAdAsync() } // FiveAdLoadListener interface methods override fun onFiveAdLoad(fiveAdInterface: FiveAdInterface) { val fiveAdCustomLayout: FiveAdCustomLayout = this.fiveAdCustomLayout ?: return // ビューに追加 fiveAdCustomLayoutHolder.removeAllViews() fiveAdCustomLayoutHolder.addView(fiveAdCustomLayout) } override fun onFiveAdLoadError(fiveAdInterface: FiveAdInterface, fiveAdErrorCode: FiveAdErrorCode) { Log.e(this::class.simpleName, "onFiveAdLoadError: $fiveAdErrorCode") this.fiveAdCustomLayout = null; } } ``` -------------------------------- ### Legacy Custom Layout Ad Loading (Java) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/ad-loader-api-migration.html Example of loading a custom layout ad using the legacy method in Java. Requires implementing FiveAdLoadListener. ```java public class MyActivity extends Activity implements FiveAdLoadListener { // 広告を表示するためのコンテナビュー @NonNull private FrameLayout fiveAdCustomLayoutHolder; // カスタムレイアウト広告オブジェクト @Nullable private FiveAdCustomLayout fiveAdCustomLayout; // ロード処理 private void loadFiveAdCustomLayout() { fiveAdCustomLayout = new FiveAdCustomLayout(this, "your-slot-id", 120); fiveAdCustomLayout.setLoadListener(this); fiveAdCustomLayout.loadAdAsync(); } // FiveAdLoadListener interface methods @Override public void onFiveAdLoad(@NonNull FiveAdInterface fiveAdInterface) { FiveAdCustomLayout fiveAdCustomLayout = this.fiveAdCustomLayout; if (fiveAdCustomLayout == null) { return; } // ビューに追加 fiveAdCustomLayoutHolder.removeAllViews(); fiveAdCustomLayoutHolder.addView(fiveAdCustomLayout); } @Override public void onFiveAdLoadError(@NonNull FiveAdInterface fiveAdInterface, @NonNull FiveAdErrorCode fiveAdErrorCode) { Log.e(MyActivity.class.getSimpleName(), "onFiveAdLoadError: " + fiveAdErrorCode.name()); this.fiveAdCustomLayout = null; } } ``` -------------------------------- ### Loading Native Ad (Objective-C) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading a native ad using the AdLoader API in Objective-C. The updated process involves creating FADAdSlotConfig, calling the appropriate loader function, and retrieving the ad object through the provided callback. ```objectivec loadNativeAdWithConfig:withInitialWidth:withLoadCallback: ``` -------------------------------- ### Loading Native Ad (Swift) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading a native ad using the AdLoader API in Swift. The updated process involves creating FADAdSlotConfig, calling the appropriate loader function, and retrieving the ad object through the provided callback. ```swift loadNativeAd(with:withInitialWidth:withLoadCallback:) ``` -------------------------------- ### Loading Reward Ad (Objective-C) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading a video reward ad using the AdLoader API in Objective-C. The process involves creating FADAdSlotConfig, calling the loader function, and handling the loaded ad object in the provided callback. ```objectivec loadRewardAdWithConfig:withLoadCallback: ``` -------------------------------- ### Loading Reward Ad (Swift) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading a video reward ad using the AdLoader API in Swift. The process involves creating FADAdSlotConfig, calling the loader function, and handling the loaded ad object in the provided callback. ```swift loadRewardAd(with:withLoadCallback:) ``` -------------------------------- ### Fetch API Usage History Source: https://adsnetwork-docs.linebiz.com/cms/api-guide/how-to-fetch-api-history.html This example demonstrates how to download API usage history using a curl command. Refer to the API Usage History API specification page for details on the request URL and request body. ```APIDOC ## Fetch API Usage History ### Description This endpoint allows you to retrieve the history of your API requests. ### Method POST ### Endpoint `https://adsnetwork.line.biz/api/public/v1/api-key-history` ### Parameters #### Request Body - **from** (int) - Optional - The starting position for fetching history. Defaults to 0. - **limit** (int) - Optional - The number of items to retrieve. The maximum limit is 100. Defaults to 100. ### Request Example ```json { "from": 0, "limit": 100 } ``` ### Response #### Success Response (200) - **histories** (Array[History]) - API usage history, retrieved in descending order of request epoch time. #### History Object - **request_epoch_time** (long) - The epoch time of the request. - **method** (string) - The HTTP Method. - **content_type** (string) - The HTTP Content-Type. - **path** (string) - The HTTP request path. - **body** (string) - The HTTP request body. - **status_code** (int) - The HTTP status code. #### Response Example ```json { "histories": [ { "request_epoch_time": 1678886400, "method": "POST", "content_type": "application/json", "path": "/some/api/path", "body": "{\"key\": \"value\"}", "status_code": 200 } ] } ``` ### Error Handling - **400**: Bad Request. The request is invalid or has syntax/validation errors. Ensure your request is in a valid format. - **401**: Unauthorized. Authentication failed. Ensure your authentication header is formatted correctly. - **429**: Too Many Requests. You have exceeded the rate limit. Please wait a while before retrying. - **500**: Internal Server Error. An unknown error occurred. ``` -------------------------------- ### Loading Banner Ad (Objective-C) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading a custom layout banner ad using the AdLoader API in Objective-C. This follows the new procedure: create FADAdSlotConfig, call the loader function, and receive the ad object in the callback. ```objectivec loadBannerAdWithConfig:withInitialWidth:withLoadCallback: ``` -------------------------------- ### Loading Banner Ad (Swift) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading a custom layout banner ad using the AdLoader API in Swift. This follows the new procedure: create FADAdSlotConfig, call the loader function, and receive the ad object in the callback. ```swift loadBannerAd(with:withInitialWidth:withLoadCallback:) ``` -------------------------------- ### Loading Interstitial Ad (Objective-C) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading an interstitial ad using the AdLoader API in Objective-C. This new procedure requires creating FADAdSlotConfig, invoking the loader function, and receiving the ad object via the specified callback. ```objectivec loadInterstitialAdWithConfig:withLoadCallback: ``` -------------------------------- ### Load Custom Layout Ad (Legacy Objective-C) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html This Objective-C code shows the traditional approach to loading a custom layout ad, including view setup and delegate method implementations for ad loading events. ```objectivec // ViewController.h @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UIView* adContainerView; @end // ViewController.m @interface ViewController () @property (nonatomic, strong) FADAdViewCustomLayout* adCustomLayout; @end @implementation ViewController #pragma mark - Load Ad - (void)loadCustomLayoutAd { self.adCustomLayout = [[FADAdViewCustomLayout alloc] initWithSlotId:@"your-slot-id" width:120]; [self.adCustomLayout setLoadDelegate:self]; [self.adCustomLayout loadAdAsync]; } #pragma mark - FADLoadDelegate - (void)fiveAdDidLoad:(id)ad { FADAdViewCustomLayout* adView = self.adCustomLayout; if (adView == nil) { return; } if (adView.superview != self.adContainerView) { [adView removeFromSuperview]; [self.adContainerView addSubview:adView]; // Auto Layout設定 adView.translatesAutoresizingMaskIntoConstraints = NO; [NSLayoutConstraint activateConstraints:@[ [adView.topAnchor constraintEqualToAnchor:self.adContainerView.topAnchor], [adView.leadingAnchor constraintEqualToAnchor:self.adContainerView.leadingAnchor], [adView.trailingAnchor constraintEqualToAnchor:self.adContainerView.trailingAnchor], [adView.bottomAnchor constraintEqualToAnchor:self.adContainerView.bottomAnchor], ]]; } } - (void)fiveAd:(id)ad didFailedToReceiveAdWithError:(FADErrorCode)errorCode { NSLog(@"Failed to load ad with error code: %ld", (long)errorCode); } @end ``` -------------------------------- ### Loading Interstitial Ad (Swift) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Example of loading an interstitial ad using the AdLoader API in Swift. This new procedure requires creating FADAdSlotConfig, invoking the loader function, and receiving the ad object via the specified callback. ```swift loadInterstitialAd(with:withLoadCallback:) ``` -------------------------------- ### Initialize SDK (Old Method) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/ad-loader-api-migration.html This is the traditional method for initializing the SDK by registering FiveAdConfig with FiveAd. Use this for reference to understand the previous approach. ```kotlin FiveAd.initialize(context, config) ``` ```java FiveAd.initialize(context, config) ``` -------------------------------- ### Registering Configuration (Old) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html Previously, SDK initialization was performed by registering FADConfig with FADSettings. ```swift FADSettings.register(config) ``` ```objectivec [FADSettings registerConfig:config]; ``` -------------------------------- ### Video Ad Playback Start Event Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/advanced/ad-events.html This event occurs when video playback starts. It triggers not only on the initial playback but also on resuming from a pause or replaying. ```APIDOC ## Video Ad Playback Start Event ### Description This event occurs when video playback starts. It triggers not only on the initial playback but also on resuming from a pause or replaying. ### Swift ```swift func fiveCustomLayoutAdDidPlay(_ ad: FADAdViewCustomLayout) func fiveVideoRewardAdDidPlay(_ ad: FADVideoReward) func fiveInterstitialAdDidPlay(_ ad: FADInterstitial) func fiveNativeAdDidPlay(_ ad: FADNative) ``` ### Objective-C ```objectivec - (void) fiveCustomLayoutAdDidPlay:(nonnull FADAdViewCustomLayout*)ad - (void) fiveVideoRewardAdDidPlay:(nonnull FADVideoReward*)ad - (void) fiveInterstitialAdDidPlay:(nonnull FADInterstitial*)ad - (void) fiveNativeAdDidPlay:(nonnull FADNative*)ad ``` ``` -------------------------------- ### Get AdLoader Instance Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-loader/prepare-ad-loader.html Obtain an AdLoader instance using the configured FiveAdConfig. The first argument for AdLoader.forConfig is android.content.Context. The AdLoader instance is cached internally. ```kotlin val adLoader = AdLoader.forConfig(context, config) ``` -------------------------------- ### Initialize SDK (AdLoader API) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/ad-loader-api-migration.html Initialize the SDK using the AdLoader API by obtaining an AdLoader instance for the given configuration. This method is rarely expected to fail, and retries are generally unnecessary. ```kotlin val adLoader: AdLoader? = AdLoader.forConfig(context, config) if (adLoader == null) { // エラーの場合の処理 } ``` ```java AdLoader adLoader = AdLoader.forConfig(context, config); if (adLoader == null) { // エラーの場合の処理 } ``` -------------------------------- ### Fetch Reports (CSV) Source: https://adsnetwork-docs.linebiz.com/cms/api-guide/how-to-fetch-reports-from-api.html This snippet demonstrates how to fetch reports in CSV format using the Report API. It includes an example request body with common parameters. ```APIDOC ## Fetch Reports (CSV) ### Description This endpoint allows you to retrieve reports in CSV format. You can specify the date range, dimensions, metrics, and filters to customize the report. ### Method POST ### Endpoint `https://adsnetwork.line.biz/api/public/v1/reports.csv` ### Parameters #### Request Body - **start_date** (string) - Required - The start date for the report in YYYY-MM-DD format. - **end_date** (string) - Required - The end date for the report in YYYY-MM-DD format. - **dimensions** (Array[string]) - Required - Specifies the dimensions for the report (e.g., `["date", "app_id"]`). - **metrics** (Array[string]) - Required - Specifies the metrics to include in the report (e.g., `["imp", "click"]`). - **filter** (object) - Optional - Used to filter the report data (e.g., `{"app_ids": [12345]}`). - **from** (int) - Optional - The starting position for the data retrieval. Defaults to 0. - **limit** (int) - Optional - The maximum number of records to retrieve. Defaults to 1000, with a maximum of 1000. ### Request Example ```json { "start_date": "2024-01-01", "end_date": "2024-01-01", "dimensions": [ "date", "app_id", "slot_id" ], "metrics": [ "imp", "click" ], "filter": { "app_ids": [ 12345 ] }, "from": 0, "limit": 1000 } ``` ### Response #### Success Response (200) - The response will be in CSV format, with headers corresponding to the requested dimensions and metrics. #### Response Example ```csv date,app_id,slot_id,imp,click 2024-01-01,12345,6789,5432,5 2024-01-01,12345,6790,3310,2 ``` ``` -------------------------------- ### Initialize FiveSDK Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/quick-start/initialize-sdk.html Initialize the FiveSDK after configuring FiveAdConfig. This step enables ad serving capabilities. The first argument to `FiveAd.initialize` is the Android `Context`. ```kotlin FiveAd.initialize(context, config) ``` -------------------------------- ### Load Ad Images Asynchronously Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/native.html Use loadInformationIconImageAsync and loadIconImageAsync to get Bitmap objects for the information icon and advertiser icon, respectively. These methods accept a FiveAdNative.LoadImageCallback. ```kotlin adNative.loadInformationIconImageAsync(object : FiveAdNative.LoadImageCallback { override fun onImageLoaded(bitmap: Bitmap?) { // Handle loaded bitmap } }) adNative.loadIconImageAsync(object : FiveAdNative.LoadImageCallback { override fun onImageLoaded(bitmap: Bitmap?) { // Handle loaded bitmap } }) ``` -------------------------------- ### Get Ad Information Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/native.html Retrieve various assets for native ads, such as button text, descriptions, advertiser names, and ad titles, to customize your ad views. ```kotlin val buttonText = adNative.buttonText val longDescriptionText = adNative.longDescriptionText val advertiserName = adNative.advertiserName val adTitle = adNative.adTitle ``` -------------------------------- ### Info.plist SKAdNetwork Configuration Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/advanced/sk-ad-network.html Example of how to configure the SKAdNetworkItems array in your app's Info.plist file. This includes all necessary ad network identifiers for LINE Yahoo Ad Network. ```xml SKAdNetworkItems SKAdNetworkIdentifier vutu7akeur.skadnetwork SKAdNetworkIdentifier eh6m2bh4zr.skadnetwork SKAdNetworkIdentifier cstr6suwn9.skadnetwork SKAdNetworkIdentifier 578prtvx9j.skadnetwork SKAdNetworkIdentifier 9t245vhmpl.skadnetwork SKAdNetworkIdentifier v72qych5uu.skadnetwork SKAdNetworkIdentifier x8uqf25wch.skadnetwork SKAdNetworkIdentifier 7ug5zh24hu.skadnetwork SKAdNetworkIdentifier hs6bdukanm.skadnetwork SKAdNetworkIdentifier dbu4b84rxf.skadnetwork SKAdNetworkIdentifier 8c4e2ghe7u.skadnetwork ``` -------------------------------- ### Prepare Video Reward Ad Object Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/video-reward.html Create a `FiveAdVideoReward` object to display video reward ads. Replace `your-slot-id` with your registered slot ID. The first argument to `FiveAdVideoReward` is the `Context`. ```java val videoRewardAd = FiveAdVideoReward(this, "your-slot-id") ``` -------------------------------- ### Display Video Reward Ad Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/video-reward.html Once the ad is loaded, the `onFiveAdLoad` method of the registered `FiveAdLoadListener` will be called. Call the `showAd` method on the `FiveAdVideoReward` object at this stage to start playing the ad. ```java videoRewardAd.showAd() ``` -------------------------------- ### Show Interstitial Ad Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/interstitial.html When the ad is loaded, the `onFiveAdLoad` method of the registered `FiveAdLoadListener` interface is called. At this stage, calling the `showAd` method of the `FiveAdInterstitial` object will start playing the ad full-screen. ```APIDOC ## Show Interstitial Ad ### Description Displays the loaded interstitial ad in full-screen. ### Method Signature ```java void showAd() ``` ### Callback This method should be called within the `onFiveAdLoad` callback of the `FiveAdLoadListener`. ### Callback Example * Kotlin ```kotlin override fun onFiveAdLoad(fiveAdInterface: FiveAdInterface) { this.adInterstitial.showAd() } ``` * Java ```java @Override public void onFiveAdLoad(FiveAdInterface fiveAdInterface) { this.adInterstitial.showAd(); } ``` ``` -------------------------------- ### Impression Event Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/advanced/ad-events.html This event is triggered when an ad starts being viewed. It occurs once per ad and requires the ad view to be visible. It's recommended to confirm this event occurs when implementing ad slots. ```APIDOC ## Impression Event ### Description This event is triggered when an ad starts being viewed. It occurs once per ad and requires the ad view to be visible. It's recommended to confirm this event occurs when implementing ad slots. ### Swift ```swift func fiveCustomLayoutAdDidImpression(_ ad: FADAdViewCustomLayout) func fiveVideoRewardAdDidImpression(_ ad: FADVideoReward) func fiveInterstitialAdDidImpression(_ ad: FADInterstitial) func fiveNativeAdDidImpression(_ ad: FADNative) ``` ### Objective-C ```objectivec - (void) fiveCustomLayoutAdDidImpression:(nonnull FADAdViewCustomLayout*)ad - (void) fiveVideoRewardAdDidImpression:(nonnull FADVideoReward*)ad - (void) fiveInterstitialAdDidImpression:(nonnull FADInterstitial*)ad - (void) fiveNativeAdDidImpression:(nonnull FADNative*)ad ``` ``` -------------------------------- ### API使用履歴をダウンロードするコマンド例 Source: https://adsnetwork-docs.linebiz.com/cms/api-guide/how-to-fetch-api-history.html API使用履歴を取得するための `curl` コマンドの例です。リクエストURLとリクエストボディは、API仕様ページを参照してください。 ```bash curl -u ${API_KEY_ID}:${API_KEY_SECRET} \ -X POST \ -H "Content-Type: application/json" \ -d "${リクエストボディ}" \ ${リクエストURL} ``` -------------------------------- ### Register Configuration to Initialize SDK Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/quick-start/initialize-sdk.html Register the configured FADConfig object with FiveSDK to initiate the SDK's initialization process. This step is crucial before the SDK can be used. ```swift FADSettings.register(config) ``` ```objectivec [FADSettings registerConfig:config]; ``` -------------------------------- ### Initializing AdLoader API (New) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html The AdLoader API initializes the SDK by obtaining an FADAdLoader corresponding to FADConfig. Initialization errors are rare and typically due to storage allocation failures; retries are generally not recommended. ```swift do { let adLoader: FADAdLoader = try FADAdLoader(for: config) } catch { // エラーの場合の処理 } ``` ```objectivec NSError* error = nil; FADAdLoader* adLoader = [FADAdLoader adLoaderForConfig:config outError:&error]; if (error) { // エラーの場合の処理 } ``` -------------------------------- ### Create Ad Slot Configuration (Objective-C) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html This Objective-C code demonstrates the creation of an FADAdSlotConfig object, a necessary step for using the AdLoader API to load ads. ```objectivec FADAdSlotConfig* slotConfig = [FADAdSlotConfig configWithSlotId:@"your-slot-id"]; ``` -------------------------------- ### Prepare Ad Object Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/native.html Create a FiveAdNative object by replacing 'your-slot-id' with your registered slot ID. The first argument is the Context. ```kotlin val adNative = FiveAdNative(this, "your-slot-id") ``` -------------------------------- ### Video Reward Ad: Before Migration (Old API) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/20240112-fullscreen-showad.html This code demonstrates the old API usage for showing a video reward ad. The show() method returns a boolean indicating success or failure. ```kotlin val fiveAdVideoReward = FiveAdVideoReward(context, "slot-id") if (fiveVideoReward.show()) { // 動画リワード広告の表示に成功した際の処理 } else { // 動画リワード広告の表示に失敗した際の処理 } ``` ```java FiveAdVideoReward fiveAdVideoReward = new FiveAdVideoReward(context, "slot-id"); if (fiveAdVideoReward.show()) { // 動画リワード広告の表示に成功した際の処理 } else { // 動画リワード広告の表示に失敗した際の処理 } ``` -------------------------------- ### Load Information and Icon Images - Java Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-loader/native.html Asynchronously load the information icon and advertiser icon images. Handle the loaded Bitmap or null if the image is not available or loading failed. ```java fiveAdNative.loadInformationIconImageAsync(new FiveAdNative.LoadImageCallback() { @Override public void onImageLoad(@Nullable Bitmap bitmap) { if (bitmap != null) { // インフォメーションアイコンのロードに成功した際の処理 } else { // インフォメーションアイコンが存在しない際、またはロードに失敗した際の処理 } } }); fiveAdNative.loadIconImageAsync(new FiveAdNative.LoadImageCallback() { @Override public void onImageLoad(@Nullable Bitmap bitmap) { if (bitmap != null) { // 広告主アイコンのロードに成功した際の処理 } else { // 広告主アイコンが存在しない際、またはロードに失敗した際の処理 } } }); ``` -------------------------------- ### 広告クリックイベントの通知 Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/advanced/ad-events.html 広告がクリックされ、遷移が発生したときに発生するイベントです。アプリ内のWebViewやStoreKitに遷移した場合でも発生します。 ```swift func fiveCustomLayoutAdDidClick(_ ad: FADAdViewCustomLayout) func fiveVideoRewardAdDidClick(_ ad: FADVideoReward) func fiveInterstitialAdDidClick(_ ad: FADInterstitial) func fiveNativeAdDidClick(_ ad: FADNative) ``` ```objective-c - (void) fiveCustomLayoutAdDidClick:(nonnull FADAdViewCustomLayout*)ad - (void) fiveVideoRewardAdDidClick:(nonnull FADVideoReward*)ad - (void) fiveInterstitialAdDidClick:(nonnull FADInterstitial*)ad - (void) fiveNativeAdDidClick:(nonnull FADNative*)ad ``` -------------------------------- ### Load Custom Layout Ad (Legacy Swift) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html This Swift code demonstrates the traditional method for loading a custom layout ad, including setting up the ad view and handling delegate callbacks for load success and failure. ```swift class ViewController: UIViewController { /// 広告を表示するためのコンテナビュー @IBOutlet weak var adContainerView: UIView! /// カスタムレイアウト広告オブジェクト private var adCustomLayout: FADAdViewCustomLayout? // ロード処理 func loadCustomLayoutAd() { self.adCustomLayout = FADAdViewCustomLayout(slotId: "your-slot-id", width: Float(120)) self.adCustomLayout?.setLoadDelegate(self) self.adCustomLayout?.loadAdAsync() } } // FADLoadDelegateの実装 extension ViewController: FADLoadDelegate { func fiveAdDidLoad(_ : FADAdInterface!) { guard let adView = self.adCustomLayout else { return } // ビューに追加 if adView.superview != self.adContainerView { adView.removeFromSuperview() self.adContainerView.addSubview(adView) // Auto Layout設定 adView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ adView.topAnchor.constraint(equalTo: self.adContainerView.topAnchor), adView.leadingAnchor.constraint(equalTo: self.adContainerView.leadingAnchor), adView.trailingAnchor.constraint(equalTo: self.adContainerView.trailingAnchor), adView.bottomAnchor.constraint(equalTo: self.adContainerView.bottomAnchor), ]) } } func fiveAd(_: FADAdInterface!, didFailedToReceiveAdWithError errorCode: FADErrorCode) { NSLog("Failed to load ad with error code: \(errorCode.rawValue)") } } ``` -------------------------------- ### Prepare Interstitial Ad Object Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/interstitial.html Instantiate the FiveAdInterstitial object. Replace 'your-slot-id' with your registered slot ID. The first argument is the Context. ```kotlin this.adInterstitial = FiveAdInterstitial(context, "your-slot-id") ``` ```java this.adInterstitial = new FiveAdInterstitial(context, "your-slot-id"); ``` -------------------------------- ### Load Custom Layout Ad (Objective-C) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html This code demonstrates how to load a custom layout ad using the FADAdLoader. It configures the ad slot and handles the ad loading callback, invoking success or failure methods. ```objectivec // ViewController.h @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UIView* adContainerView; @end // ViewController.m @implementation ViewController #pragma mark - Load Ad - (void)loadCustomLayoutAd { FADAdSlotConfig* slotConfig = [FADAdSlotConfig configWithSlotId:@"your-slot-id"]; AppDelegate* appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate; FADAdLoader* adLoader = appDelegate.adLoader; [adLoader loadBannerAdWithConfig:slotConfig withInitialWidth:120 withLoadCallback:^(FADAdViewCustomLayout* ad, NSError* error) { if (error) { [self onLoadFailureWithError:error]; } else { [self onLoadSucceededWithAd:ad]; } }]; } #pragma mark - Load完了時の処理 - (void)onLoadSucceededWithAd:(FADAdViewCustomLayout*)ad { [self.adContainerView addSubview:ad]; // Auto Layout設定 ad.translatesAutoresizingMaskIntoConstraints = NO; [NSLayoutConstraint activateConstraints:@[ [ad.topAnchor constraintEqualToAnchor:self.adContainerView.topAnchor], [ad.leadingAnchor constraintEqualToAnchor:self.adContainerView.leadingAnchor], [ad.trailingAnchor constraintEqualToAnchor:self.adContainerView.trailingAnchor], [ad.bottomAnchor constraintEqualToAnchor:self.adContainerView.bottomAnchor], ]]; } - (void)onLoadFailureWithError:(NSError*)error { NSLog(@"Failed to load ad with error code: %ld", (long)error.code); } @end ``` -------------------------------- ### Implement Ad Load Handlers (Kotlin) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/ad-loader-api-migration.html Implement the methods to handle successful ad loading and errors in Kotlin. This includes adding the ad view or logging the error. ```kotlin private fun onLoadSucceeded(fiveAdCustomLayout: FiveAdCustomLayout) { // ビューに追加 fiveAdCustomLayoutHolder.removeAllViews() fiveAdCustomLayoutHolder.addView(fiveAdCustomLayout) } private fun onLoadFailure(fiveAdErrorCode: FiveAdErrorCode) { Log.e(this::class.simpleName, "onLoadFailure: $fiveAdErrorCode") } ``` -------------------------------- ### Load Native Ad - Java Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-loader/native.html Use this to load a native ad. Provide your slot ID and an AdLoader.LoadNativeAdCallback to handle success or failure. ```java adLoader.loadNativeAd( new AdSlotConfig("your-slot-id"), adMainAssetWidth, new AdLoader.LoadNativeAdCallback() { @Override public void onLoad(@NonNull FiveAdNative nativeAd) { // 広告ロード成功時の処理 } @Override public void onError(@NonNull FiveAdErrorCode errorCode) { // 広告ロード失敗時の処理 } }); ``` -------------------------------- ### Load Ads with Listener Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/native.html Register a FiveAdLoadListener to receive notifications for ad loading success or failure. Then, load the ad. ```kotlin adNative.setLoadListener(this) adNative.loadAd() ``` -------------------------------- ### Loading Image Assets Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-loader/native.html Asynchronously load images for the information icon and advertiser icon. ```APIDOC ## Loading Image Assets ### Description Load `Bitmap` objects for the information icon and advertiser icon asynchronously. ### Methods - `loadInformationIconImageAsync(callback: FiveAdNative.LoadImageCallback)`: Loads the information icon image. - `loadIconImageAsync(callback: FiveAdNative.LoadImageCallback)`: Loads the advertiser icon image. ### `FiveAdNative.LoadImageCallback` This callback interface is used to receive the loaded image. - `onImageLoad(bitmap: Bitmap?)`: Called when the image is loaded. Returns a `Bitmap` if successful, or `null` if the image does not exist or loading failed. ### Request Example (Kotlin) ```kotlin fiveAdNative.loadInformationIconImageAsync(object : FiveAdNative.LoadImageCallback { override fun onImageLoad(bitmap: Bitmap?) { if (bitmap != null) { // Handle successful information icon load } else { // Handle missing or failed information icon load } } }) fiveAdNative.loadIconImageAsync(object : FiveAdNative.LoadImageCallback { override fun onImageLoad(bitmap: Bitmap?) { if (bitmap != null) { // Handle successful advertiser icon load } else { // Handle missing or failed advertiser icon load } } }) ``` ### Request Example (Java) ```java fiveAdNative.loadInformationIconImageAsync(new FiveAdNative.LoadImageCallback() { @Override public void onImageLoad(@Nullable Bitmap bitmap) { if (bitmap != null) { // Handle successful information icon load } else { // Handle missing or failed information icon load } } }); fiveAdNative.loadIconImageAsync(new FiveAdNative.LoadImageCallback() { @Override public void onImageLoad(@Nullable Bitmap bitmap) { if (bitmap != null) { // Handle successful advertiser icon load } else { // Handle missing or failed advertiser icon load } } }); ``` ``` -------------------------------- ### Load Information and Icon Images - Kotlin Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-loader/native.html Asynchronously load the information icon and advertiser icon images. Handle the loaded Bitmap or null if the image is not available or loading failed. ```kotlin fiveAdNative.loadInformationIconImageAsync(object : FiveAdNative.LoadImageCallback { override fun onImageLoad(bitmap: Bitmap?) { if (bitmap != null) { // インフォメーションアイコンのロードに成功した際の処理 } else { // インフォメーションアイコンが存在しない際、またはロードに失敗した際の処理 } } }) fiveAdNative.loadIconImageAsync(object : FiveAdNative.LoadImageCallback { override fun onImageLoad(bitmap: Bitmap?) { if (bitmap != null) { // 広告主アイコンのロードに成功した際の処理 } else { // 広告主アイコンが存在しない際、またはロードに失敗した際の処理 } } }) ``` -------------------------------- ### Initialize FiveAdInterstitial Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/ad-formats/interstitial.html To display an interstitial ad, you need to create a `FiveAdInterstitial` object. Replace `your-slot-id` with your registered slot ID. The first argument passed during the creation of `FiveAdInterstitial` is the `Context`. ```APIDOC ## Initialize FiveAdInterstitial ### Description Creates an instance of `FiveAdInterstitial` to display full-screen ads. ### Method Signature ```java FiveAdInterstitial(Context context, String slotId) ``` ### Parameters #### Path Parameters - **context** (Context) - Required - The Android context. - **slotId** (String) - Required - The registered slot ID for the ad. ### Request Example * Kotlin ```kotlin this.adInterstitial = FiveAdInterstitial(context, "your-slot-id") ``` * Java ```java this.adInterstitial = new FiveAdInterstitial(context, "your-slot-id"); ``` ``` -------------------------------- ### Implement Ad Load Handlers (Java) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/ad-loader-api-migration.html Implement the methods to handle successful ad loading and errors in Java. This includes adding the ad view or logging the error. ```java private void onLoadSucceeded(@NonNull FiveAdCustomLayout fiveAdCustomLayout) { // ビューに追加 fiveAdCustomLayoutHolder.removeAllViews() fiveAdCustomLayoutHolder.addView(fiveAdCustomLayout); } private void onLoadFailure(@NonNull FiveAdErrorCode fiveAdErrorCode) { Log.e(MyActivity.class.getSimpleName(), "onLoadFailure: " + fiveAdErrorCode.name()); } ``` -------------------------------- ### Load Custom Layout Ad (Swift) Source: https://adsnetwork-docs.linebiz.com/fivesdk-ios/migration-guide/ad-loader-api-migration.html This code demonstrates how to load a custom layout ad using the FADAdLoader. It configures the ad slot and handles the ad loading callback, invoking success or failure methods. ```swift class ViewController: UIViewController { /// 広告を表示するためのコンテナビュー @IBOutlet weak var adContainerView: UIView! // ロード処理 func loadCustomLayoutAd() { let slotConfig = FADAdSlotConfig(slotId: "your-slot-id") let appDelegate = UIApplication.shared.delegate as? AppDelegate let adLoader: FADAdLoader? = appDelegate?.adLoader adLoader?.loadBannerAd(with: slotConfig, withInitialWidth: Double(120)) { ad, error in if let error = error { self.onLoadFailure(error: error) } else { self.onLoadSucceeded(ad: ad!) } } } // ロード完了時の処理 func onLoadSucceeded(ad: FADAdViewCustomLayout) { self.adContainerView.addSubview(ad) // Auto Layout設定 ad.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ ad.topAnchor.constraint(equalTo: self.adContainerView.topAnchor), ad.leadingAnchor.constraint(equalTo: self.adContainerView.leadingAnchor), ad.trailingAnchor.constraint(equalTo: self.adContainerView.trailingAnchor), ad.bottomAnchor.constraint(equalTo: self.adContainerView.bottomAnchor), ]) } func onLoadFailure(error: Error) { print("Failed to load ad with error code: \((error as NSError).code)") } } ``` -------------------------------- ### Video Reward Ad: After Migration (New API) Source: https://adsnetwork-docs.linebiz.com/fivesdk-android/migration-guide/20240112-fullscreen-showad.html This code shows the new API usage for video reward ads. Success and failure are handled via event listeners, and showAd() is called to display the ad. ```kotlin val fiveAdVideoReward = FiveAdVideoReward(context, "slot-id") fiveAdVideoReward.setEventListener(object : FiveAdVideoRewardEventListener { override fun onFullScreenOpen(FiveAdVideoReward: FiveAdVideoReward) { // 動画リワード広告の表示に成功した際の処理 } override fun onViewError(FiveAdVideoReward: FiveAdVideoReward, fiveAdErrorCode: FiveAdErrorCode) { // 動画リワード広告の表示に失敗した際の処理 } }) fiveAdVideoReward.showAd() ``` ```java FiveAdVideoReward fiveAdVideoReward = new FiveAdVideoReward(context, "slot-id"); fiveAdVideoReward.setEventListener(new FiveAdVideoRewardEventListener() { @Override public void onFullScreenOpen(@NonNull FiveAdVideoReward fiveAdVideoReward) { // 動画リワード広告の表示に成功した際の処理 } @Override public void onViewError(@NonNull FiveAdVideoReward fiveAdVideoReward, @NonNull FiveAdErrorCode fiveAdErrorCode) { // 動画リワード広告の表示に失敗した際の処理 } }); fiveAdVideoReward.showAd(); ```