0

I'm trying to implement push notifications through SF MC in my React Native project. I installed react-native-marketingcloudsdk and followed the instructions in the README and I get the following build errors:

error: cannot find symbol
  MarketingCloudSdk.init(this,
  ^
  symbol:   variable MarketingCloudSdk
  location: class MainApplication
 <folderpath>/MainApplication.java:57: error: cannot find symbol
    MarketingCloudConfig.builder()
    ^
  symbol:   variable MarketingCloudConfig
  location: class MainApplication
 <folderpath>/MainApplication.java:63: error: cannot find symbol
      .setNotificationCustomizationOptions(NotificationCustomizationOptions.create(R.mipmap.ic_launcher_round))
                                           ^
  symbol:   variable NotificationCustomizationOptions

I added my SDK initialization in MainApplication.java:

@Override
public void onCreate() {
    super.onCreate();

  MarketingCloudSdk.init(this,
    MarketingCloudConfig.builder()
      .setApplicationId("******")
      .setAccessToken("*****")
      .setSenderId("("*****")")
      .setMarketingCloudServerUrl("("*****")/")
      .setMid("("*****")")
      .setNotificationCustomizationOptions(NotificationCustomizationOptions.create(R.mipmap.ic_launcher_round))
      .setAnalyticsEnabled(true)
      .build(this),
    initializationStatus -> Log.e("SF MC INIT Status", initializationStatus.toString()));

    
    SoLoader.init(this, /* native exopackage */ false);
    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());  
}

If I add these lines to my MainApplication.java file, I can get rid of the build errors and I can see the Marketing cloud initialization is successful:

import com.salesforce.marketingcloud.MarketingCloudConfig;
import com.salesforce.marketingcloud.MarketingCloudSdk;
import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions;

However, when I send a test notification through Marketing Cloud Mobile Push I don't receive any on Android despite the Device ID being registered on my contact. On iOS my test notifications also work fine through Mobile Push. Testing through Firebase I do receive test notifications so that side should be fine. What could be wrong with my React Native Marketing Cloud SDK implementation for Android?

2 Answers 2

0

You probably have not followed the multiple push provider implementation instructions. 9.99x out of 10, customers include the ReactNative push plugin in addition to the Marketing Cloud Push Plugin, but the RN plugin is not required. So, either remove it or implement the SDK per the docs for a multiple push provider implementation.

2
  • Could you expand a little? Are you recommending I implement the Android Marketing Cloud SDK instead of the React Native Marketing Cloud SDK?
    – Tara
    Mar 17 at 18:32
  • I'm simply recommending you follow the documentation for multiple push providers, or remove the ReactNative plugin you've added if you're not using any other push provider other than Marketing Cloud.
    – Bill Mote
    Mar 20 at 12:07
0

unfortunately the MktCloud documentation are not very helpful. Remember to import your R (resource) for your icon inside option function and try this imports (worked for me):

import com.salesforce.marketingcloud.MCLogListener;
import com.salesforce.marketingcloud.MarketingCloudSdk;
import com.salesforce.marketingcloud.MarketingCloudConfig;
import com.salesforce.marketingcloud.notifications.NotificationManager;
import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions;
import com.<your_project_name_here>.R;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .