Search code examples
androidfirebasefirebase-notifications

Opening particular app on notification click


I'm receiving a package name in the notification and I want to open that particular app in play store once I click the notification. How to proceed with that?


Solution

  • You can simply use an implicit intent:

           NotificationManager notificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = new Notification(icon, message, when);
            Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + PACKAGENAME))
            PendingIntent intent = PendingIntent.getActivity(context, 0,
                    notificationIntent, 0);
            notification.setLatestEventInfo(context, title, message, intent);
            notificationManager.notify(0, notification);