2

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.

Arjun
  • 533
  • 2
  • 9
  • 23
  • GCM sometimes delays notifications, but there are methods to circumvent this. See for example: http://stackoverflow.com/questions/19560448/how-to-avoid-delay-in-android-gcm-messages-change-heartbeat – Sándor Mátyás Márton May 26 '16 at 11:51
  • 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 May 26 '16 at 12:13
  • Did you read the first answer to the question I just linked? – Sándor Mátyás Márton May 26 '16 at 12:17
  • 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: https://firebase.google.com/docs/cloud-messaging/ – Sándor Mátyás Márton May 26 '16 at 12:21
  • 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 May 26 '16 at 12:26
  • You can use the samples provided for GCM if you replace the address of the server as explained in the migration guide. There is also an example HTTP message here: https://firebase.google.com/docs/cloud-messaging/downstream – Sándor Mátyás Márton May 26 '16 at 12:32
  • even this also gave the same result Sandor. I started using Pushy notifications and works great. Thanks for your help on this – Arjun Jun 01 '16 at 12:00

2 Answers2

0

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"));

Ivan Dokov
  • 121
  • 6
  • This change is something i need to implement on android or Web API Ivan? Please help me – Arjun May 26 '16 at 12:12
  • This should be implemented on Android - anywhere you have access to the context object (Application, Activity, Service). – Ivan Dokov May 26 '16 at 12:18
  • Sure Ivan. Will try and let you know if i got any luck on this – Arjun May 26 '16 at 12:27
  • No luck evan. Finally, i removed GCM and started using Pushy notifications and it just works great. Thanks for your help on this – Arjun Jun 01 '16 at 12:01
0

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

Arjun
  • 533
  • 2
  • 9
  • 23