28

I saw in google's developer console that GCM allows to generate a API key for iOS. I searched in the web for any kind of documentation about how to implement Push Notifications through GCM in an iOS App, but i didn't find answers.

Is it really possible to implement Push Notifications jet using GCM in iOS apps? documentation, examples or something to learn how to do this?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Alejandro Fraenkel
  • 289
  • 1
  • 3
  • 4

8 Answers8

25

YES

I tried it and it works great. Follow this https://developers.google.com/cloud-messaging/ios/start

This is how it works.

You create app entry at google console. Upload development and production certificated in creation wizard.(You have to upload both) and follow the steps in docs.

Logic works as follows

  1. We request device token from apns as usual.
  2. Then we send that token to gcm service with provided api.
  3. Then gcm sends back a another token.
  4. We send that token to app server.
  5. App server can send notifications using that token.

Cool Features.

GCM for iOS has some cool features as

  • Subscribe to notification based on a particular topic. Ignore others.

  • Send Notification to other devices within the app.

If you want to try google sample app. UPDATE: it's Google with a capital G now. Just

pod try Google

There you will get an example in ObjC , swift and even mac app that can send notification.

Update.

Google is moving to Firebase cloud messageing from GCM.

Community
  • 1
  • 1
MadNik
  • 7,713
  • 2
  • 37
  • 39
  • What about performance? Are there any downsides to having a persistent connection open on iOS? – Lizza Sep 15 '15 at 22:06
  • i am getting notification message from server but not like APNS like top on navigation so how can handle this @MadNik – Anil Prasad Jan 08 '16 at 07:34
  • @AnilPrasad what do u mean that "getting message from server but not like APNS"? – Gajendra K Chauhan Jan 25 '16 at 13:38
  • 1
    The data payload and notification payload are both applicable on iOS & Android. On iOS the difference is that notification payload is sent through APNS while data payload is sent through GCM's own connection which is only there when app is in foreground. SO,If I want to use GCM in both android and ios,the payload should contain only notification?or is both data and notification is fine? – abhimuralidharan Feb 20 '16 at 10:20
17

Google has now introduced Google Cloud Platform for iOS. See their blog entry for more information. Google Cloud Messaging is supported now for both Android and iOS.

Scott Leslie
  • 1,147
  • 9
  • 11
  • 5
    GCM is not supported for iOS: `The same set of features exists for both Android and iOS, and the backend manages the platform specifics such as using Google Cloud Messaging for Android and APNS for iOS devices`. They just make it simpler to develop server side with push notifications for both iOS and Android. – Eran Oct 15 '13 at 15:58
  • 4
    You are correct that GCM is not supported on iOS, but the same server API is supported to talk to GCM or APNS. This makes life a lot easier for people implementing backend servers. – Scott Leslie Oct 15 '13 at 17:41
  • 2
    This answer has the link that I was actually searching for. Don't down-vote it people. – Zsolt Safrany Jul 22 '14 at 14:34
  • Looks like the link in this answer is outdated, suggests using a library that is no longer supported. I'm still searching, will report back when I can find the library we should be using. – livingtech Jun 18 '15 at 14:27
  • 1
    Current link is here: https://developers.google.com/cloud-messaging/ios/api/gcm/ More details: https://developers.google.com/cloud-messaging/ios/client (Via Sergio Feo's answer below.) – livingtech Jun 18 '15 at 14:56
  • The data payload and notification payload are both applicable on iOS & Android. On iOS the difference is that notification payload is sent through APNS while data payload is sent through GCM's own connection which is only there when app is in foreground. SO,If I want to use GCM in both android and ios,the payload should contain only notification?or is both data and notification is fine? – abhimuralidharan Feb 20 '16 at 10:20
9

Google has updated their online documentation. You still need a valid APNS certificate. After, your app can register with GCM using the iOS GCM API. Your notifications server should work without modification.

Sergio Feo
  • 292
  • 2
  • 7
5

the answer is yes, you can use Google Cloud Messaging API to communicate with iOS devices, but its quite a complex process. You can read the official documentation on https://cloud.google.com/resources/articles/ios-push-notifications

Regards

Javi Vazquez
  • 517
  • 6
  • 21
5

As of Google I/O 2015, Google officially added iOS support for GCM. You can find more information here: https://developers.google.com/cloud-messaging/ios/start

Sean Abraham
  • 191
  • 2
  • 3
3

While some Google APIs work with iOS GCM is for Android only. The only way to send push notifications to iOS devices is through the Apple push notification system. Google would have to support this.

You can always us something like Urban Airship if you want to push to multiple platforms.

Patrick Tescher
  • 3,387
  • 1
  • 18
  • 31
  • 1
    you can improve answer with links – shareef May 19 '13 at 09:56
  • 1
    The data payload and notification payload are both applicable on iOS & Android. On iOS the difference is that notification payload is sent through APNS while data payload is sent through GCM's own connection which is only there when app is in foreground. SO,If I want to use GCM in both android and ios,the payload should contain only notification?or is both data and notification is fine? – abhimuralidharan Feb 20 '16 at 10:20
1

The response is no for Google Cloud Messaging. However it's possible to send push notification to iOS devices using Google Cloud Platform with Google App Engine and Google Cloud Endpoints. (See this documentation)
But you will need inevitably to communicate with the Apple Push Notication Service. The task to do it is for sure more complex than using directly the Apple service.

Maurice
  • 2,129
  • 2
  • 25
  • 33
0

Wow, this is really bad. Actually you need to modify the client on iOS for this to work! In my company this is just not an option unfortunately, so back to Amazon SNS.

The idea here is that with Google's implementation you only need to communicate with the GCM, but in order to send a message to iOS, then your device will have had to sync with GCM first to pass tokens etc, hence the need for the iOS client library.

As a user of Google App Engine, I was really excited by this, but this is a real let down.