1

I'm trying to use MarketingCloudSDK 7.4.0 with a Mendix made Android Mobile Application. Mendix is a lowcode platform that uses ReactNative as framework. Therefore, I'm using the react-native-marketingcloudsdk package. The goal is to have an Android app able to receive push notifications and report back the statistics to Salesforce (Inbox push Opened, etc)

Right now, I'm able to receive push notifications properly. However, I'm struggling to report the Analytics of the message to the Salesforce portal. The sample code in the documentation is in Kotlin and I'm not getting success to adapt the code to JScript. For exemple, I've made a binding to call AnalyticsManager.trackInboxOpenEvent from my Jscript and got the error below:

AnalyticsManager: InboxMessage is a Legacy message, null or unknown. Call to trackInboxOpenEvent() ignored.

My question: Does anyone have a ReactNative sample code that report back the statistics to Salesforce. It seems that the code example that comes with the react-native-marketingcloudsdk package does not have this feature enabled.

Any help or comment will be appreciated!

2 Answers 2

0

The Message you're tracking must exist in the SDK's storage ref:

    if (message == null || !storage.getInboxMessageStorage().isKnownMessage(message.id())) {
  MCLogger.w(TAG,
      "InboxMessage is a Legacy message, null or unknown.  Call to trackInboxOpenEvent() ignored.");
  return;
}

So, are you sure you're using an Inbox Message and not just some push message? Also, clicking the notification, if this is an Alert+Inbox message, will automatically track that the message was clicked. What is unknown to the SDK, and the reason for the trackInboxOpenEvent() convenience method, is when the click happens from your Inbox UI that you own and control.

0

Can you try this.

import { NativeModules } from 'react-native';

const SalesforceAnalytics = NativeModules.SalesforceAnalytics;

function reportStatistics(statistics) {
  const payload = {
    statistics: statistics,
    timestamp: Date.now()
  };
  SalesforceAnalytics.report(payload);
}

In this example, we're using the NativeModules API from React Native to access a native module called SalesforceAnalytics. This module provides a report function that we can use to send data to Salesforce. We're defining a reportStatistics function that takes in a statistics object and sends it to Salesforce with a timestamp.

To use this code, you'll need to have the SalesforceAnalytics module installed in your React Native project and configured with your Salesforce account credentials. Additionally, you'll need to define the structure of the statistics object that you want to send to Salesforce.

You must log in to answer this question.

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