Reputation: 1
With Apple Push noitifications, there is a url parameter in the notification request that specifies where the app opens to when a user clicks the notification.
Is there an equivalent for android FCM notifications?
Upvotes: 0
Views: 87
Reputation: 9225
With Android you have two FCM options here.
Upvotes: 0
Reputation: 719
You can send a custom value in the FCM message (a Data message) payload and then parse it in the device and create the notification with a custom click action according to the value of the custom field. For example this could be your method to build the notification:
private static Notification createNotification(final Context context, final String activity){
final Class activityToLaunch;
switch (activity){
case "Activity1":
activityToLaunch = Activity1.class;
break;
case "Activity2":
activityToLaunch = Activity2.class;
break;
default:
activityToLaunch = MainActivity.class;
}
final PendingIntent myAction = PendingIntent.getActivity(context, 1, new Intent(context, activityToLaunch), PendingIntent.FLAG_CANCEL_CURRENT);
return new NotificationCompat.Builder(context)
.setContentTitle("My Title")
.setContentText("My Content")
.setSmallIcon(R.drawable.my_icon)
.setContentIntent(myAction)
.build();
}
Where the "activity" param is the value of the field you sent in your payload.
Upvotes: 1