Skip to main content

Manual Initialization

info

Starting from NAM SDK 4.0.0, automatic initialization using ContentProvider is supported. Initialization is automatically performed using the required PublisherCode or the optional ServiceCode values set in the manifest without any additional configuration.

The NAM SDK is automatically initialized through a custom ContentProvider. However, for cases where you need to control the initialization timing due to specific app requirements, manual initialization is also supported.

Disabling Automatic Initialization

To manually initialize the NAM SDK, you need to disable the automatic initialization option by adding a <meta-data> tag to your app's AndroidManifest.xml file.

AndroidManifest.xml
<meta-data
android:name="com.naver.gfpsdk.AUTO_INIT"
android:value="false" />

Manual Initialization Call

When the automatic initialization option is disabled, i.e., the manual initialization option is enabled, you must call the initialization method of the NAM SDK as soon as possible. Typically, this should be done during the app startup, such as in the Application.onCreate() method or within the Activity.onCreate() lifecycle of activities that include ads.

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) {
// 성공 여부: initializationResult.success
// (참고용) 성공/실패시 내부 메시지: initializationResult.message
}
})
}
}
}
info

Even if a failure is received in the initialization response callback when the manual initialization method is called before the ad request, it does not cause any issues in requesting ads. However, it is recommended to ensure proper initialization for effective ad requests.