I am trying to get the notification message in my react native App.tsx
for Android
. I have below Configuration in MarketingCloudSdk.init()
.
I have found one thing in logcat
When I click the notification the NotificationOpenActivity
(START u0 {act=com.salesforce.marketingcloud.NOTIFICATION_CLICKED dat=mcsdk:pushOpen cmp=com.myapp/com.salesforce.marketingcloud.notifications.NotificationOpenActivity (has extras)} from uid 10153
) is starting with (has extras)
.
after that the app is trying to start com.myapp.MainActivity
(START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.myapp cmp=com.myapp/com.myapp.MainActivity}
), and here there is no (has extras)
.
Please help me to unblock this. I have tried to receive notification with multiple react native notification libraries like notifee
wix react native notification
etc.,
MainApplicaiton.java
MarketingCloudSdk.init(this,
MarketingCloudConfig.builder()
.setApplicationId(this.getResources().getString(R.string.PUSH_APPLICATION_ID))
.setAccessToken(this.getResources().getString(R.string.PUSH_ACCESS_TOKEN))
.setMarketingCloudServerUrl(this.getResources().getString(R.string.PUSH_TSE))
.setNotificationCustomizationOptions(
NotificationCustomizationOptions.create((context, notificationMessage) -> {
int requestCode = new Random().nextInt();
String url = notificationMessage.url();
PendingIntent pendingIntent;
Log.i(SALESFORCE_TAG, "NotificationCompat.Builder > notificationMessage.url(): " + notificationMessage.url());
Intent newIntent;
if (TextUtils.isEmpty(url)) {
newIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
} else {
newIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
}
pendingIntent = PendingIntent.getActivity(
context,
requestCode,
newIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE
);
NotificationCompat.Builder builder =
NotificationManager.getDefaultNotificationBuilder(
context,
notificationMessage,
NotificationManager.createDefaultNotificationChannel(context),
R.drawable.ic_notification
);
builder.setColor(getResources().getColor(R.color.accentColor));
builder.setContentIntent(
NotificationManager.redirectIntentForAnalytics(
context,
pendingIntent,
notificationMessage,
true
)
);
return builder;
})
)
.setAnalyticsEnabled(true)
.build(this),
initializationStatus -> Log.e("INIT", initializationStatus.toString()));
Logcat
2022-11-27 15:07:27.674 680-862 EGL_emulation pid-680 D app_time_stats: avg=469.03ms min=2.74ms max=13012.87ms count=28
2022-11-27 15:07:27.928 680-680 ActivityLaunchAnimator pid-680 D Starting intent with a launch animation
2022-11-27 15:07:27.935 521-1375 ActivityTaskManager pid-521 I START u0 {act=com.salesforce.marketingcloud.NOTIFICATION_CLICKED dat=mcsdk:pushOpen cmp=com.myapp/com.salesforce.marketingcloud.notifications.NotificationOpenActivity (has extras)} from uid 10153
2022-11-27 15:07:27.937 521-1375 ActivityTaskManager pid-521 W startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=com.salesforce.marketingcloud.NOTIFICATION_CLICKED dat=mcsdk:pushOpen cmp=com.myapp/com.salesforce.marketingcloud.notifications.NotificationOpenActivity (has extras) }
2022-11-27 15:07:27.938 521-1375 ActivityTaskManager pid-521 W Can't find TaskDisplayArea to determine support for multi window. Task id=218 attached=false
2022-11-27 15:07:27.945 680-680 ActivityLaunchAnimator pid-680 D launchResult=0 willAnimate=true isOnKeyguard=false
2022-11-27 15:07:27.965 521-766 ActivityTaskManager pid-521 W Tried to set launchTime (0) < mLastActivityLaunchTime (124971625)
2022-11-27 15:07:27.991 1709-1709 BoundBrokerSvc pid-1709 D onBind: Intent { act=com.google.android.gms.measurement.START pkg=com.google.android.gms }
2022-11-27 15:07:27.991 1709-1709 BoundBrokerSvc pid-1709 D Loading bound service for intent: Intent { act=com.google.android.gms.measurement.START pkg=com.google.android.gms }
2022-11-27 15:07:27.999 3351-3351 NotificationManager com.myapp D Notification open Event Logged for id : (NDs2MJE9LkE)
2022-11-27 15:07:28.001 521-4372 ActivityTaskManager pid-521 I START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.myapp cmp=com.myapp/com.myapp.MainActivity} from uid 10153
2022-11-27 15:07:28.004 3351-3351 BehaviorManager com.myapp D Behavior found: BEHAVIOR_SDK_NOTIFICATION_OPENED
2022-11-27 15:07:28.006 521-521 Compatibil...geReporter pid-521 D Compat change id reported: 175319604; UID 1000; state: ENABLED
2022-11-27 15:07:28.011 680-680 ShadeControllerImpl pid-680 V NotificationShadeWindow: com.android.systemui.statusbar.phone.NotificationShadeWindowView{755fb41 V.E...... ........ 0,0-1080,1920} canPanelBeCollapsed(): true
2022-11-27 15:07:28.014 680-901 PeopleSpaceWidgetMgr pid-680 D Sbn doesn't contain valid PeopleTileKey: null/0/com.myapp
2022-11-27 15:07:28.016 680-21138 ActivityLaunchAnimator pid-680 D Remote animation was cancelled
2022-11-27 15:07:28.049 521-4907 ServiceManager pid-521 W Permission failure: android.permission.HIGH_SAMPLING_RATE_SENSORS from uid=10153 pid=3351
2022-11-27 15:07:28.050 521-4907 ServiceManager pid-521 W Permission failure: android.permission.HIGH_SAMPLING_RATE_SENSORS from uid=10153 pid=3351