Xamarin's implementation of FCM update broke data messages on iOS 11 and Xamarin - firebase

I updated my project's Firebase packages, including Cloud Messaging, with 2.0.0 release. Now I see that iOS 11 devices do not receive data messages from FCM. Unlike this thread, I have no problems receiving notifications via APNs with Firebase.
I implemented every necessary change, including replacing the old Messaging.SharedInstance.Connect() method with Messaging.SharedInstance.ShouldEstablishDirectChannel = true;.
I have tried to implement the IMessagingDelegate's methods ApplicationReceivedRemoteMessage and DidReceiveMessage - both separately and together. neither hits breakpoints.
The Xamarin guys have not updated the guideline here as of this question's writing. Has anyone else encountered this issue? What can be done?

Related

Can FCM push notifications in Electron App

I'm trying to send notifications from Firebase Cloud Messaging (FCM) to a window app (window form for example) but it doesn't seem to be possible (since fcm only supports android/ios/webapp, for here and here).
So trying building Electron app to be able to receive and display notifications from fcm (slack is built from electron js and also displays notifications, here), and found the electron-push-receiver allowing it to receive notifications from FCM
But it seems that there is no update for a long time, so there is a issue#80
Now is it possible to build electron application that can receive notifications from FCM?
Thank you very much!
I just implemented FCM in my Electron app earlier today by following the guide here:
https://github.com/CydeSwype/electron-fcm-demo
Screenshot of FCM working in an Electron app
I was skeptical at first as well, given that the repo hasn't been updated in a while, but was pleasantly surprised that it still works.
If you have any further questions, go ahead and I'll try to help :)
I also got this working with electron-push-receiver, though I had to do a workaround for more recent versions of Electron.
I looked at the firebase-admin.messaging Node package but that is only for privileged environments.
The HTTP 503 issue you linked it seems was just another outage that has been resolved; I can still register for push notifications with this setup.

Firebase Cross Platform Push Notification Plugin Duplicating MainActivity

I'm using the following plugin for implementing and handling FCM push notifications in my xamarin application and there's one little unaddressed problem I'm facing.
I was hoping someone else has already figured it out and could help me.
THE PROBLEM:
It seems to be duplicating my MainActivity although I have the LaunchMode set to SingleTop.
There's an event called OnNotificationReceived that's provided by the library.
This event fires as expected, only once, when the application is in the foreground.
When I minimize the application (let it run in the background), send a notification to the device and tap on the notification, it opens the application, as expected, but if I send another notification after that, while the application is in the foreground, The OnNotificationReceived Event is fired twice.
I've tried changing the NotificationActivityFlags property to SingleTop.
I've tried changing my MainActivity's Launch Mode to SingleTop
I tried running the sample application they've provided to check if its something that I'm doing wrong, and still the same thing happens.
Logging the issue in their Github repository
None of the above have worked.
The issue can be reproduced by:
downloading the sample from the repository, link provided above
replacing their google-services.json file with your own from the Firebase
console.
change the package name of the sample of the application to the one you
have registered on Firebase
following the steps above that I've mentioned
ADDITIONAL INFO
Version Number of Plugin: 1.3.0
Device Tested On: Huawei P8 Lite Android Version 6.0
Version of VS: Visual Studio 2019
Version of Xamarin: 3.4.0.1009999
Update:
Unfortunately, the method below has not proven successful after attempting to implement it, I should have thought of the fact that I'm still going to need the notification object for iOS, earlier.
Myself and the team are going to implement a way to keep track of the users platform on the server and send them a notification either with or without the notification based on their platform, since iOS handles FCM notifications differently from Android. For now we're going to use Google's Instance ID service to determine what platform existing users are on.
Workaround:
I hope this helps someone in the future, if not I hope someone can provide me with a better solution.
In order to have my cake and eat it, basically be able to keep the notification object in the payload instead of removing it and having to further customise the payload to display notifications just for iOS, I changed the MainActivity's (the activity thats launched when a user taps on the notification) Launch mode to SingleInstance. That way I can keep my notification object in the payload and not have to worry about the OnNotificationReceived event being triggered twice.

Xamarin and Push Notifications - Reason to use Azure Notification Hubs?

Good afternoon,
I apologize in advance, as I know this is subjective. But, I'd very much love the opinion of a Xamarin expert.
I'm building a mobile application for a client using Xamarin targeting Android and iOS devices. We have a .NET Web API back-end application that is consumed by a MVC web application (hosted in Azure), and now our Xamarin application. Our API needs to send basic push notifications (to iOS and Android) when certain things happen.
I've configured push notifications (also targeting Xamarin projects) in the past, but it has been a few years. That configuration included Azure Notification Hubs and GCM (the GCM piece was recently updated to Firebase - still in combination with Azure Notification Hubs). All of that is working just fine.
After reviewing push notifications again, it seems as though Firebase has become something of a Notification Hub itself, handling both iOS and Android applications. There is plenty of documentation on setting up push notifications in a variety of ways, using just Firebase for both iOS and Android, using Firebase with Azure, using just Azure for iOS, etc.
So, my question is.. If you are a seasoned Xamarin developer creating a new iOS and Android targeted application with a .NET backend, would you use Azure Notification Hubs? Based on my reading, it seems as though the simplest approach would be to utilize Firebase for both iOS and Android, leave out the Azure Notification Hub piece of it, and use our back-end to make a single POST request to the Google API (i.e. https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send based on their documentation at https://firebase.google.com/docs/cloud-messaging/send-message) to send a new push notification.
However, that doesn't sit very well with me considering that Microsoft is behind both Xamarin and Azure. My gut is telling me that I should be using Azure Notification Hubs. Could someone please provide some guidance? I feel like I'm not understanding something that's preventing me from being able to come to a good conclusion on my own.
Thanks,
Chandler
This seems to be a problem with the software architecture. Technically, notifications can be done for both Azure and IOS/Android notifications. But from user data statistics and future data service analysis, you need to consider whether the notification service you used before can continue to provide services for you. At the same time, if you are ready to abandon the previous use, you can slowly split some users to use the new notification service. From my personal point of view, this is the safest.

FCM console push test is currently broken? (Android)

I've been using FCM console(web) to test push notification for Android smartphone.
I use push token from Android device, but FCM console says "Completed" and it's not delivered.
It worked fine before, but recent few days, it's not working.
Is there anyone facing same problem?
I got an answer from FCM support team.
Thank you for that information.
It would seem that you are affected by the changes made between July
31 and August 1st. We rolled out a change to Firebase Notifications to
filter apps by GMP App Id rather than by package name. This change was
purely internal and should have had no effect on visible behavior as
all apps using Firebase should have had both package name and app id
set to match. However, we are now seeing some apps that have the wrong
app id set and this is causing messages to not be delivered (or in
some cases to be delivered to the wrong app if an app has the app id
of another app). These apps have a bug that was previously masked but
is now exposed.
We are investigating ways in which apps have sent these incorrect app
ids and ways in which we can catch them and warn app developers.
For now, the Firebase Notifications console will only work with apps
that use the FCM SDK. We recommend updating to the latest version of
the FCM SDK in order to mitigate the issue, but in case you don't want
to migrate to FCM SDK, you can still use your own server to send push
notifications.
Apologies for the inconvenience this may have caused. Please let me
know if there's anything else I could help with.
Regards,

Can use Google's Cloud Messaging for iOS in a hybrid app?

I am planning to build a "hybrid app" using PhoneGap which needs to have a iOS push notification engine.
And I want to use Google Cloud Messaging for sending push notifications to the iOS (I have used this for sending notifications to Android).
My questions here are:
Can I use Google Cloud Messaging for iOS in an hybrid app (using PhoneGap's https://github.com/phonegap-build/PushPlugin)?
Are there any changes that I may have to do while using the above plugin?
I have used the above PhoneGap plugin to receive notifications from GCM and APNS separately but this time I want to use the GCM for both iOS and Android.
Any help will be appreciated.
I also have used GCM and APNS separately for send push notifications to Android and iOs devices independently.
For all the documentation I've read, GCM for iOs devices is an approach of the APNS service but using the same structure that GCM is using for Android devices. I think that if you have used the APNService, you have found all the hard steps (certificates, using strictly a Mac for some things, ...) so, answering to your questions:
Yes, you can use the GCM for iOs with Phonegap plugin because GCM Server sends the data that PhoneGap's plugin is ready to receive (as you can see in the GCM Server Reference there are some data specific for APNS (nothing that you don't know if you have worked with APNS)).
If you are preparing a native app for iOs, you should see the GCM iOs Client documentation because you will have to use the iOs API but it's not your problem.
I don't expect that you have to do changes while using PhoneGap's plugin. You will only have to use PhoneGap's implementation for iOs devices and get ready to receive push notifications (but if you have some troubles, please, I will be pleased to know them).
Good luck!

Resources