DimitarStoyanoff / Notifications

FCM Notifications with images in app foreground
61 stars 41 forks source link

Click action #3

Closed aruphazarika closed 6 years ago

aruphazarika commented 6 years ago

How to add Click action in this, pls help

DimitarStoyanoff commented 6 years ago

Hey @aruphazarika , you can check out the tutorial where I add actions to the notification: https://www.pluralsight.com/guides/push-notifications-with-firebase-cloud-messaging

aruphazarika commented 6 years ago

I have tested your above project, I didnot get what I was looking for, I want when users clicks on notification , then the app will open a specific activity which was send in JSON , It will be more fine if Notification buttons have specific click action activity. Thank you!

DimitarStoyanoff commented 6 years ago

I have both of those cases implemented in the tutorial. If you want clicking on the activity to open a specific activity you create a pending intent and pass it to the NotificationBuilder.setContentIntent(), as shown here: https://www.pluralsight.com/guides/push-notifications-with-firebase-cloud-messaging#module-customizingnotifications

If you want to add buttons to the notification that do certain operations on the background you create a service, otherwise you can still create a pending intent and pass it to NotificationBuilder.addAction(). The notification payload can be passed with intent extras to the activity or service, as demonstrated here: https://www.pluralsight.com/guides/push-notifications-with-firebase-cloud-messaging#module-notificationbuttons

Hope that was exhaustive enough.

aruphazarika commented 6 years ago

Thanks for replying, I m beginner in this field, can u pls write code in your project as demo

aruphazarika commented 6 years ago

Suppose I have Activity1, Activity2, I want to open Activity2 after clicking notification, what is code for that?