Skip to main content

Manual Initialization of SDK


info

The following guide is for cases where an automatic initialization is not wanted when initially running the app.

Before loading ads, NAM SDK initialization is required.

Through the initialization process, the Mobile Advertising SDK or Mediation Partner SDK will be initialized in advance.

To ensure smooth initialization of the partner SDK, calling initialization at the application level is recommended.

Additionally, this task only needs to be done once when the app is launched.


Auto initialization Off

Auto initialization is performed by default. To initialize manually, the below settings must be added to the Manifest file.

<!-- default true = auto-initializing -->
<meta-data
android:name="com.naver.gfpsdk.AUTO_INIT"
android:value="false" />

Perform initialization

Whether to initialize can be determined and proceeded through GfpSdk.

Also, the status value after initialization can be checked through GfpSdk.InitializationCallback.

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ...
if (!GfpSdk.isInitialized()) {
GfpSdk.initialize(applicationContext,
object: GfpSdk.InitializationCallback {
override fun onInitializationComplete(initializationResult: GfpSdk.InitializationResult) {
// is successful: initializationResult.success
}
})
}
}
}
info

When called before an ad request even if the getSuccess() value can be viewed in GfpSdk.InitializationResult within GfpSdk.InitializationCallback#onInitializationComplete(), which is a callback for initialization, returns false, there is no issue in requesting an ad. However, for an effective ad request, an accurate Publisher code and Ad Unit ID must be provided.


Manual initialization of Unity

When using Unity ads, an initialization process is required. This step is performed during the NAM SDK initialization process.

If necessary, the initialization process can be performed separately. Refer to the separate initialization process below.

info

If manually initializing, it must be performed prior to NAM SDK initialization (GfpSdk.initialize).

import com.naver.gfpsdk.provider.UnityInitializer
import com.unity3d.ads.IUnityAdsInitializationListener
import com.unity3d.ads.UnityAds

UnityInitializer.initialize(context, "your_game_id", object: IUnityAdsInitializationListener {
override fun onInitializationComplete() {
// init success
}

override fun onInitializationFailed(error: UnityAds.UnityAdsInitializationError, message: String) {
// handling error
}
})
1. When initialized to a different game ID

This message occurs when initialization is attempted with a different game ID ‘b’ after initializing it with an ID ‘a’. (It will not be initialized with the ID ‘b’.)

If it will not be called continuously, please check whether the game ID used for the first initialization is correct.

2021-08-20 12:11:51.138 6730-6730/com.naver.gfpsdk.adssample.internal E/gfp_sdk_UnityInitializationListener: Initialization Failed: [INVALID_ARGUMENT] Unity Ads SDK failed to initialize due to already being initialized with different parameters
- Game ID Current: 4114527 | Received: 2750252
- Test Mode Current: true | Received: false
2. When an ad request is made with a different game ID than the initialized one

This error occurs in UnityAds if the game ID used in mediation connected to a NAM ad unit is different from the value used for initialization.

Please check the NAM Unit ID and the game ID used for initialization.

2021-08-20 12:12:54.397 6730-8340/com.naver.gfpsdk.adssample.internal E/UnityAds: com.unity3d.services.core.api.Sdk.logError() (line:72) :: Load invocation failed: No placement configured for id: quest_reward_bonus
2021-08-20 12:12:54.400 6730-6730/com.naver.gfpsdk.adssample.internal E/gfp_sdk_UnityRewardedAdapter: onUnityAdsFailedToLoad
2021-08-20 12:12:54.400 6730-6730/com.naver.gfpsdk.adssample.internal E/gfp_sdk_GfpRewardedAdAdapter: adError: code[3310] subCode[INVALID_ARGUMENT] message[No placement configured for id: quest_reward_bonus]

Manual Vungle initialization

Vungle is supported by NAM SDK version 6.0.0.

The Vungle SDK is initialized when an ad is requested for the first time or during the NAM SDK initialization process.

If necessary, the initialization process can be performed separately.

info

If manually initializing, it must be performed prior to NAM SDK initialization (GfpSdk.initialize).

VungleInitializer.initialize(context, "your_app_id", object: VungleInitializer.VungleInitializeListener {
override fun onInitializeSuccess() {
// init success
}

override fun onInitializeError(errorMsg: String) {
// error handling
}
})