TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
220 stars 49 forks source link

How do I intercept the push notification click and do something with it in the app #213

Closed SteveSitekitcare closed 1 year ago

SteveSitekitcare commented 1 year ago

Hey all,

I've using firebase push notifications in my sample app. Its working well, my problem is I cant seem to do anything usefull with the click of the notification. What I want to do is identify the message type e.g What topic it was sent on so I can direct to the correct page in my app. It looks like mainactivity.cs method "protected override void OnNewIntent(Intent intent)" is hit when the notication is tapped. but the intent object doesnt seem to contain anything of use?

IOS seems to use the following https://github.com/xamarin/GoogleApisForiOSComponents/blob/main/docs/Firebase/CloudMessaging/GettingStarted.md#handle-messages-received-through-the-fcm-apns-interface

which I havent even got round to

Can anyone help me.

TobiasBuchholz commented 1 year ago

Hi, to handle a tapped notification you can use the IFirebaseCloudMessaging.NotificationTapped event handler. It triggers an event that contains an instance of FCMNotification, which should have all the information you need. Take a look at this comment that showcases the use of the FCMNotiifcation.Data property.

If there are further questions don't hesitate to ask :)

SteveSitekitcare commented 1 year ago

Hi, to handle a tapped notification you can use the IFirebaseCloudMessaging.NotificationTapped event handler. It triggers an event that contains an instance of FCMNotification, which should have all the information you need. Take a look at this comment that showcases the use of the FCMNotiifcation.Data property.

If there are further questions don't hesitate to ask :)

Thanks for the help @TobiasBuchholz I used this in the end https://apoorv487.medium.com/testing-fcm-push-notification-through-postman-terminal-part-1-5c2df94e6c8d

SteveSitekitcare commented 1 year ago

closed