2
votes

I am trying implementing Push notifications for android mobile with the help of Google Cloud Messaging Service. As a backend, i am using Web API as a server which will connect with my SignalR to get the notifications from my web application. Here, i am able to get the instant notifications to Web API after connecting with SignalR. But, After i send the update to GCM to send notification, some times its sending instantly and most of the times notification is either not sending to mobile and very late while sending.

Please do suggest me on this to solve the issue ans to send messages from Web API to mobile instantly without any delay.

2
GCM sometimes delays notifications, but there are methods to circumvent this. See for example: stackoverflow.com/questions/19560448/… - Sándor Mátyás Márton
It looks user needs to download another app especially for notification on the given link. But, is there any way other than google cloud messaging to send notification? Wants to try that as well - Arjun
Did you read the first answer to the question I just linked? - Sándor Mátyás Márton
And of course there are other ways besides GCM, but they are far more tedious... Also, in case you missed it, Google has switched to a new Cloud Messaging API - FCM. It is pretty much the same as GCM with a few new features. Consider switching to it now, they also provide a migration guide. For more info, see: firebase.google.com/docs/cloud-messaging - Sándor Mátyás Márton
Thanks Sandor. Even i want to go with FCM. But, for Web API how can we connect? do we have any samples for the same? I tried to googled in all the places but no luck. Please help me if you find any better link on this - Arjun

2 Answers

0
votes

Try to force the system to send heartbeat:

getContext().sendBroadcast(new Intent("com.google.android.intent.action.GTALK_HEARTBEAT")); getContext().sendBroadcast(new Intent("com.google.android.intent.action.MCS_HEARTBEAT"));

0
votes

After all struggle, I found there was always a problem with Google Push Notification Service and I completely removed GCM and started using Pushy Notifications and it works great.

for more information on this, please check this link Pushy Notifications