1

I encountered a problem where the app is closed completely, and I start the first notification it opens where it needs to open, but when I tap the second notification, nothing happens. Notification close and it doesn't land anywhere where it should.

Here's the code in NotificationLaunchIntentProvider where I handle PendingIntent routing.

private final SalesForceNotificationRouter notificationRouter; public SalesForceNotificationCustomizationManager(AppConfig appConfig) { this.notificationRouter = new SalesForceNotificationRouter(appConfig); } @Nullable @Override public PendingIntent getNotificationPendingIntent(@NonNull Context context, @NonNull NotificationMessage notificationMessage) { PendingIntent notificationRoute = notificationRouter.getNotificationRoute(context, notificationMessage.url()); return NotificationManager.redirectIntentForAnalytics(context, notificationRoute, notificationMessage, true); } 

Here's the code in SalesForceNotificationRouter

 private final AppConfig appConfig; public SalesForceNotificationRouter(AppConfig config) { this.appConfig = config; } public PendingIntent getNotificationRoute(Context context, String url) { if (url == null || TextUtils.isEmpty(url)) { Intent intent = new Intent(context, HomeActivity.class); return pendingIntent(context, intent); } String path = url.trim(); Uri uri = Uri.parse(path); String scheme = uri.getScheme(); if (scheme != null && scheme.equalsIgnoreCase(appConfig.getScheme())) { Intent intent = DeeplinkActivity.initializeResponseIntent(context, uri); return pendingIntent(context, intent); } else { Intent intent = new Intent(context.getApplicationContext(), ResolverActivity.class); intent.putExtra(IntentCommand.EXTRA_URL, path); intent.putExtra(BaseActivity.EXTRA_CAME_FROM_NOTIFICATION, true); return pendingIntent(context, intent); } } private PendingIntent pendingIntent(Context context, Intent intent) { return PendingIntent.getActivity( context, randomRequestCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT ); } private int randomRequestCode() { return (int) (System.currentTimeMillis() & 0xfffffff); } 

I think before 1 year or less since now, everything was working fine. I wonder where's the problem because i tried to change things like PedingIntent flags, request code, tried opening different activities but nothing helped.

SDK version : 8.0.4 doesnt work in 7.4.2 also (didn't tried lower versions)

17
  • What version of Android are you targeting? Does the OS version of the device impact success? Please open a support case through your account manager. Commented Dec 1, 2021 at 15:10
  • Also, just so we're clear: 1) kill the application, 2) click a notification (works), and 3) leaving the application open click a second notification (nothing happens) Commented Dec 1, 2021 at 15:15
  • @BillMote targetSdkVersion 30 Commented Dec 1, 2021 at 15:17
  • @BillMote yes, that's the sequence Commented Dec 1, 2021 at 15:18
  • 1
    @BillMote logs actually ends in 129 line, I don't receive more logs in logcat after 2nd click Commented Dec 1, 2021 at 16:41

1 Answer 1

1

This problem is not related to Marketing Cloud SDK at all. Just creating my own notification I can replicate the problem, so the fix was to add Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK to my landing ResolverActivity.class Intent. You can also add Intent.FLAG_ACTIVITY_REORDER_TO_FRONT instead of Intent.FLAG_ACTIVITY_CLEAR_TASK and it works as expected. The only downside is that with clear task, no history will be preserved.

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.