Skip to content

Dealing with user tapping on notification

Android

The previous way of handling a notification click is no longer supported due to the notification trampoline restrictions introduced in Android 12. Now a user notification click is handled using activities.

When starting the plot plugin you should decide which activity the user will see once a notification is clicked, in case you don't do this, we'll use the activity from where your started the plot plugin. This will be the default activity for all notifications

Plot.init(this, ConsoleActivity.class);

You can customize this depending on the notification the user clicks. On the notificationFilter you can define the class that will be open when the user clicks on the notifications, if nothing is set, the default one will be used.

@Override
    public List<FilterableNotification> filterNotifications(List<FilterableNotification> notifications) {
        for (FilterableNotification notification : notifications) {
            notification.setNotification.setActivity("THE_NAME_OF_THE_ACTIVITY");
        }
        return notifications;
    }

Once in the activity, you can access the data on the notification the user clicked. Here's an example below.

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FilterableNotification notification =  getIntent().getParcelableExtra("notification");
    }