0

I'm currently in the process of adding the Salesforce Marketing Cloud SDK to our React Native app, following the instructions posted in the README here: https://github.com/salesforce-marketingcloud/react-native-marketingcloudsdk

Our app is relatively new and the MainApplication is written in Kotlin.

Are there any guides for initializing the SDK in Kotlin vs. Java? I'm a relatively experienced JavaScript/Java developer but I've never used Kotlin. I tried pulling the Java code directly into Android Studio and it offered to convert it into Kotlin for me but that's not working. I'm trying to figure it out manually but would prefer something official so I know I did it right. Are there any sample projects or a guide I'm missing that would explain how to initialize the SDK in Kotlin? I did try searching through the StackExchange but didn't see anything so I apologize if this is a duplicate.

Thank you very much

1 Answer 1

-1
//add this imports import android.util.Log import com.salesforce.marketingcloud.MarketingCloudConfig import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions import com.salesforce.marketingcloud.sfmcsdk.InitializationStatus import com.salesforce.marketingcloud.sfmcsdk.SFMCSdk import com.salesforce.marketingcloud.sfmcsdk.SFMCSdkModuleConfig //and this inside onCreate FMCSdk.configure( applicationContext, SFMCSdkModuleConfig.build { pushModuleConfig = MarketingCloudConfig.builder() .apply { //Update these details based on your MC config setApplicationId("01708630-c201-49be-87f6-d7e252a0d58f") setAccessToken("8LIqUQvWM9L8ZqGU4NmUAbB2") setMarketingCloudServerUrl("https://mcrxsvhm6f2k8k05dz-c7ppng7dy.device.marketingcloudapis.com/") setSenderId("536006497") setNotificationCustomizationOptions( NotificationCustomizationOptions.create( R.mipmap.ic_launcher ) ) } .build(applicationContext) } ) { initStatus -> when (initStatus.status) { InitializationStatus.SUCCESS -> Log.d("SFMC", "SFMC SDK Initialization Successful") InitializationStatus.FAILURE -> Log.d("SFMC", "SFMC SDK Initialization Failed") else -> Log.d("SFMC", "SFMC SDK Initialization Status: Unknown") } } 
1
  • I've downvoted this because it is a code dump. The explanation is as important as the solution. Commented Apr 14 at 16:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.