This topic is intended for customers who use the existing React Native plugin for Marketing Cloud Engagement.
Important
Prerequisites
Before you configure the React Native plugin for Android apps, make sure that the plugin is installed and configured for your app. See Marketing Cloud React Native Plugin.
1// Add the google services plugin to your build.gradle file2apply plugin: 'com.google.gms.google-services'
Configure the SDK
Configure the SDK in your main application class.
React Native templates default to Kotlin (MainApplication.kt). However, older templates still support Java (MainApplication.java). When you configure the SDK, select the file type that matches your project.
Note
1import android.content.Context2import android.util.Log3import com.salesforce.marketingcloud.MarketingCloudConfig4import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions5import com.salesforce.marketingcloud.sfmcsdk.SFMCSdk6import com.salesforce.marketingcloud.sfmcsdk.SFMCSdkModuleConfig78override fun onCreate(){9 super.onCreate()1011 SFMCSdk.configure(this as Context, SFMCSdkModuleConfig.build {12 pushModuleConfig = MarketingCloudConfig.builder()13 .setApplicationId("{MC_APP_ID}")14 .setAccessToken("{MC_ACCESS_TOKEN}")15 .setSenderId("{FCM_SENDER_ID_FOR_MC_APP}")16 .setMarketingCloudServerUrl("{MC_APP_SERVER_URL}")17 .setNotificationCustomizationOptions(18 NotificationCustomizationOptions.create(R.drawable.ic_notification)19)20 .setAnalyticsEnabled(true)21 .build(this@MainApplication)22}){ initializationStatus ->23 Log.e("TAG", "STATUS $initializationStatus")24 if(initializationStatus.status == 1){25 Log.e("TAG", "STATUS SUCCESS")26}27}2829 // ... The rest of the onCreate method30}