1

The redirection works fine, but the redirection does not happen if the Push Notification is clicked immediately like within 2 seconds or so. The second time I made sure to wait anywhere around 10-15 seconds and that time it worked fine. Can anyone help me out how to solve this problem.

Notification notification;
        Intent notificationIntent = BMSNotificationIntent.getNotificationIntent(notificationData, mContext,
                mSharedPreferencesManager, true);

        notificationIntent.putExtras(rawNotificaionData);
        PendingIntent NotificationPendingIntent = PendingIntent.getActivity(mContext, 0, notificationIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext);
        notificationBuilder.setPriority(Notification.PRIORITY_MAX);
        notificationBuilder
                .setSmallIcon(R.drawable.status_icon)
                .setColor(ContextCompat.getColor(mContext, R.color.transparent))
                .setContentIntent(NotificationPendingIntent)
                .setTicker(notificationData.getCleverTapTitle())
                .setAutoCancel(isAutoCancelable())
                .setContentTitle(notificationData.getCleverTapTitle())
                .setContentText(notificationData.getCleverTapMessage())
                .setVisibility(Notification.VISIBILITY_PUBLIC)
                .setDefaults(NotificationCompat.DEFAULT_VIBRATE | NotificationCompat.DEFAULT_SOUND);


        notificationBuilder.setDefaults(Notification.DEFAULT_SOUND);
        notificationBuilder.setChannelId(NotificationChannelName.GENERAL);

        /*Create a Delete Intent that will be called when user removes the notification by swiping or by clear*/
        notificationBuilder.setDeleteIntent(getNotificationDeletePendingIntent());


        notification = notificationBuilder.build();
        notification.flags |= NotificationCompat.FLAG_AUTO_CANCEL;
        if (BMSUiUtility.isNotificationFromInbox(rawNotificaionData, mSharedPreferencesManager)) {
            mNotificationManager.notify(notificationId, notification);
        } else {
            mNotificationManager.notify(0, notification);
        }
tech.mohit.garg
  • 631
  • 8
  • 18

1 Answers1

0

Please use below code snip:)

Intent resultIntent = new Intent(this, ResultActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(ResultActivity.class);

// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = 
stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);

else

Intent intent = new Intent(this, SomeActivity.class);

// Creating a pending intent and wrapping our intent
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1,       
intent, PendingIntent.FLAG_UPDATE_CURRENT);
try {
// Perform the operation associated with our pendingIntent
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
hio
  • 915
  • 8
  • 26
  • if i am using this // Perform the operation associated with our pendingIntent pendingIntent.send(); this will automatic redirect to the activity associate intent without performing notification click. – tech.mohit.garg Nov 15 '19 at 06:46