firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
370 stars 131 forks source link

Custom data on FirebaseAdmin.Messaging.Notification? #118

Closed halomakes closed 5 years ago

halomakes commented 5 years ago

Hello, I'm trying to send a notification with this sdk and I'm supposed to set "click_action":"FCM_PLUGIN_ACTIVITY" on the notification object so that our cordova app can handle click events. Is there any way to do this via the sdk?

hiranya911 commented 5 years ago

click_action is only available for AndroidNotification in the v1 API: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification

hiranya911 commented 5 years ago

@chong-shao please see if there's anything missing from this API, and resolve as you see fit.

chong-shao commented 5 years ago

@hiranya911 I may misunderstood something here, but seems like click action is supported? https://github.com/firebase/firebase-admin-dotnet/blob/master/FirebaseAdmin/FirebaseAdmin/Messaging/AndroidNotification.cs#L81

hiranya911 commented 5 years ago

Yes, it is supported on AndroidNotification. But the developer also wants it supported on Notification (I think). It seems in the legacy API this was available as general notification option.

halomakes commented 5 years ago

That's correct. Our client app uses cordova-plugin-firebase which requires a click_action to be set on the notification object to trigger events in the app after a user opens the app via a notification. I tried setting the value in AndroidNotification already but it doesn't have any effect there.

chong-shao commented 5 years ago

Hi halomademeapc, the fields in Notification object all map to fields in all platforms (Android, iOS, and Webpush). But if I understand it correctly, clieck_action do not have a corresponding field in iOS https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1 therefore it makes less sense to have it in the Notification object.

I assume you have an Android app. Setting it in AndroidNotification should be the correct approach. If it does not have any effect on your Android app, could you double check if your app's implementation in handling the notification's click_action works as intended.