Open fabiankoebel opened 6 years ago
+1 I have a notification server created with pushsharp, for about 20 different applications... and no idea if PushSharp will support FCM... (and if not I have to plan the migration of this server in the next months...)
+1 Yes, please add Firebase support! Many thanks.
I think Redth is busy. Some smart people has to send a pull request.
As u can see Last Commit was on Dec 1, 2016. https://github.com/Redth/PushSharp/commits/master
Good Luck 👍
hey guys,
In case you are still having issues with this, I fixed it for me by updating the gcmUrl. if you go to:
https://github.com/Redth/PushSharp/blob/master/PushSharp.Google/GcmConfiguration.cs
you'll see this at the top:
private const string GCM_SEND_URL = "https://gcm-http.googleapis.com/gcm/send";
public GcmConfiguration (string senderAuthToken)
{
this.SenderAuthToken = senderAuthToken;
this.GcmUrl = GCM_SEND_URL;
this.ValidateServerCertificate = false;
}
In your code, update the GcmUrl to the FcmUrl.
// Configuration
var config = new GcmConfiguration(senderID, serverKey, applicationID);
config.GcmUrl = "https://fcm.googleapis.com/fcm/send";
// Create a new broker
var gcmBroker = new GcmServiceBroker(config);
Good Luck
@emmanuelware Thanks a lot ! I event don't search what are the differences beetween GCM and FCM but if it is just an URL, it's cool :-) Do you use this "hack" in production, and is it working without any probem ?
@jeromeliger I think that may work. The FCM migration guide indicates that the payload is compatible between GCM and FCM, which is the key for the server side. Of course, the Android app has to be modified to use FCM, though it may work until they turn GCM services off (not sure).
@jeromeliger So far I haven't had any issues with the Beta testers of our application. I will let you know if I hear anything. I figured out how to use the hack yesterday, first I searched for FCM compatible libraries like PushSharp but couldn't find any so I got frustrated and just decided to write my own 'FCMServiceBroker' from scratch.
Did some research and came across this link: https://programmingistheway.wordpress.com/2017/07/20/send-push-notification-using-c-and-fcm/
My ServiceBroker worked great but I still preferred how PushSharp handle onNotificationFailed events, since that's particularly important in our case for auditing purposes so I decided to go through their code and checkout how they did it.
That's how I came across this hack of updating the GcmUrl to FCM's url. And like @TonyLugg mentioned the payload between GCM and FCM are compatible.
I tried it for both payloads too and they were both sent out successfully. Will let you know if anything comes up but so far this works.
GCM Notification Payload:
gcmBroker.QueueNotification(new GcmNotification
{
Tag = notificationTag,
RegistrationIds = new List<string> { token },
Data = JObject.Parse("{ \"subject\" : \"New Notification\" , \"message\" : \"" + message + "\" }")
});
FCM Notification Payload:
gcmBroker.QueueNotification(new GcmNotification
{
Tag = notificationTag,
RegistrationIds = new List<string> { token },
Data = JObject.Parse("{ \"notification\": {\"title\": \"New deal\",\"body\": \"20% deal!\"},\"priority\":10}")
});
Redth. Please add support for Firebase Cloud Messaging. This is important,Because Google will remove GCM server and client APIs until April 11, 2019 and will change to FCM Server. We're need upgrade sooner rather than later.Thanks you.
@jilnesta you didn't read the answers above ? As @emmanuelware described it, you just need to override the GCM URL for your broker config, to the FCM URL and it works... so what do you need more ?
@jeromeliger I know. But If release on Nuget it good.
Best regard
I got a tweet reply from Jon. He is no longer developing PushSharp and recommends switching to Azure Notifications Hub. He works for Microsoft now. Pricing seems reasonable, though free doesn't get you far.
@TonyLugg, Unfortunately, Azure Notifications Hub does not support push to web browsers yet. You may vote to this feature here.
@jilnesta If you need a starting point to using the new Firebase HTTP v1 API, I have added it to the push sharp project here https://github.com/SDough/PushSharp
@SDough
@jilnesta If you need a starting point to using the new Firebase HTTP v1 API, I have added it to the push sharp project here https://github.com/SDough/PushSharp
Have you got any example code using firebase HTTP v1 API? I tried to use yours, unfortunately I always got "PushSharp.Firebase.FirebaseNotificationException: HTTP 400 Bad Request"
Google will remove GCM server and client APIs until April 11, 2019, see attached notification from Firebase. Do you have plans for adding support for the FCM services?