GCM (Google Cloud Messaging) for iOS apps - ios

I am working on an iOS app, in which my client is asking for implementing GCM (Google Cloud Messaging) on iOS platform. I need to be sure if it can be done on iOS. As we use APNS for Push Notifications in iOS.
Can anyone suggest me about this.
Thanks In Advance.

Please check this link it contains all steps to integrate GCM in iOS and requirement is you need to set up CocoaPods dependencies.
https://developers.google.com/cloud-messaging/ios/start
https://developers.google.com/cloud-messaging/ios/client

Its a late answer.But I just started working on GCM on iOS.SO I thought to answer this question as it might help someone.
The following flow chart gives a brief idea on GCM.
GCM can can be used to send updates to a single registrationID,a group
to registrationIDs,or we can register a topic in the GCM server and we
can send updates to all the devices subscribed to that particular
topic.
Just follow the steps and you will find GCM integration easy.
STEP 1: Do watch this video completely : https://www.youtube.com/watch?v=gJatfdattno This gives the basic idea on how GCM works.
STEP 2
Goto this link: https://developers.google.com/cloud-messaging/ios/client
This shows clearly how you should configure the project.The main and important part is properly configuring the GCM config file.
You just have to upload apns certificate (developer and production) and get the gcm config file and add it to your project (drag and drop to your project navigation pane).
The following code which you should call in the didFinishLaunchingWithOptions will automatically fetch the _gcmSenderID from the config file.
_gcmSenderID = [[[GGLContext sharedInstance] configuration] gcmSenderID];
Another important part is properly setting the kGGLInstanceIDAPNSServerTypeSandboxOption to yes or no in didRegisterForRemoteNotificationsWithDeviceToken depending on which environment you are using the code(development or production).ie; kGGLInstanceIDAPNSServerTypeSandboxOption key should be YES if you are using it for testing.
Here is a sample quick start project for you to start with.(both swift and objective-C).Everything is well explained in this sample app.
Let me know if you have any doubts.
Regarding actual communication, as long as the application is in the background on an iOS device, GCM uses APNS to send messages, the application behaving similarly as using Appleā€™s notification system. But when the app is active, GCM communicates directly with the app
.
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.

Related

FCM Notifications not arriving on iOS

This bounty has ended. Answers to this question are eligible for a +500 reputation bounty. Bounty grace period ends in 5 hours.
Scorb wants to draw more attention to this question.
I have a cross platform flutter app. I am using FCM to send notifications and they are not arriving on the iOS app in any state (foreground, background, terminated). I am testing on a physical device.
The notifications work on Android, so I know the topic subscription and send code is correct.
I have followed these steps for configuration defined here...
https://firebase.flutter.dev/docs/messaging/apple-integration/
To verify I have:
added and initialized firebase using google-services-info.plist.
created and added my APNS key
created the app identifier in the Apple Developer center and confirmed it matches my apps bundle id (and added push notification
capability for the identifier.
added push notification capability to the app in xcode
added background fetch and background remote notification capabilities to the app in xcode.
It seems like I have addressed every step to configure FCM on iOS. But none of my notifications arrive.
When the app is minimized, no system tray notification is triggered, and when in the foreground the FirebaseMessaging.onMessage is never triggered, like is is when on Android.
An important note is that this is the second iOS app added to this project, and the first iOS app works correctly. Though there is no indication that there are any special steps for a second app.
We saw a similar problem (for a native iOS app) where FCM would deliver to one app in the project but not the other. The mistake we made was not repeating the configuration in Firebase for the other apple bundle id since each app in our project has a different bundle id. Given it works for one of your iOS apps but not the other on the same project, it sounds like you've got the same issue.
Also, a good diagnostic step is to use the Firebase Console to manually send off a Push Notification to a particular app. It means you can then discount errors further upstream in your backend that may not have caused FCM to be invoked.
Have you tried to send testing notifications via firebase console?
You can log your device token in your app.
Background notification must work if you have done correct with firebase and APN settings despite without implementing some methods of AppDelegate file for remote notification on the next step.
Your question is very blur to have a specific answer but you can separate your concerns to find the issue and then try to resolve that:
1. Make sure about the APNs configuration
First, try to send a notification to your iOS app, directly using the APNS key. If you get the notification, it means you have configured the APNS correctly
2. Make sure about the firebase setup
Check with both the Android and iOS app and see if there are connected to the firebase console. You can use the real-time event to confirm that.
3. Make sure you have implemented the correct methods.
Firebase and apple have different methods for push notifications. Make sure you are implementing the correct one. Also, it may vary based on the configuration file of firebase. search for iOS firebase swizzling for more information
4. Make sure you got the right permissions from the user
You should get the notification permission from the user before trying to show any notification. Make sure you've done that
Note that you may have already tried some of these but I've mentioned them for the sake of completeness. Hope it helps you and others.

iOS Firebase Push Notification - Token received but push not working

I am currently developing an App with push notifications using Capacitor. I followed their guide for the implementation online and everything works so far. I am receiving a token & it is successfully sent to my backend. The problem I am facing right now is that when I try to send a push to that deviceToken via firebase admin SDK the push never reaches my phone (the same is true, when I try to target the whole iOS platform via Firebase Cloud Messaging).
I am not sure why I don't receive any pushes (I have tested it on 2 different devices -> both receive their pushToken, but none of the receive pushes, everything works just fine on android). Do you have any ideas what the problem might be here?
you should enable the capability of push notification and enable background mode such as:
!(https://i.stack.imgur.com/DGZ7h.png)
!(https://i.stack.imgur.com/z7ITq.png)
and you should go to your
firebase project settings/cloud messaging/
add or insert your APNs Authentication Key
from apple developer account

APN push notifications for chat

I'm trying to add notifications to a private chat app that uses Firebase, unfortunately Firebase has an APN service but it must be configured and needs also a server app to manage it. I'd like to have the user notified when someone is texting him while the app is in the background. The problem is that APN (Apple Push Notifications) requires a server with a certificate and that is ok with me, but I'm looking for a way to send push notifications from an iOS device to another device, I mean device-to-device push notifications and the server has just to relay the messages as they are. In my case the APN server should only relay the messages that it receives from a source device to the destination device. I couldn't find a way to obtain that without writing sever code. I want to use pre-built existing services. Has anybody any idea on how to send push notifications from one device to another without configuring and writing server apps? I tried a workaround using the background fetch iOS feature, but the system si randomly giving my app execution time... and that means that my app could wait hours before being started by the system... so that is not a viable solution. Please help
Ok, probably what I found out could be helpful for others. Actually
what I'm looking for can be directly integrated in the app. You need a library like NWPusher (free on GitHub) which can be imported, and with just a few lines of code and the APN device token you get from the system, it is possibile to implement APN notifications... easily, but most importantly... for free.
UPDATE
Check also APNS framework on GitHub. It's written in Swift 3.0 and it supports the latest features.
You are essentially looking for a messaging / chat API to handle device-to-device communication. You might want to try Pusher or PubNub

GCM in iOS - clarification

Just wanted to conform if my understanding is correct. As per my understanding, the mechanism involved in delivering the push notification to iOS App is Server -> GCM -> APNS -> iOS App. I am an iOS developer and I know that Apple strictly never allows a server other than APNS server to send a remote notification to iOS App. So, just wanted to know whether the notification is directly pushed to the iOS App from GCM or, via APNS.
Push messages are always sent by APNS.
What services like Google Cloud Messaging or Parse.com do is facilitating the administration of push messages - eg enabling an app to switch pushon or off for an app, or group users so you can send push messages to certain user groups instead of all of them.
GCM is not involved in Push Notification in iOS.
It is carried out through APNS.
Please refer
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html
It will clear all your doubts.
Everything will be clear if you just look at image:
Its showing complete APNS process. This is the process for iOS, no GCM included for iOS.

Receive push notifications from APNS to Titanium (iOS) App without using Appcelerator Cloudpush (ACS)?

I'm now responsible for a initial release of an app for iOS and Android. The developer that started the work has left the company and we are left with an incomplete Titanium application to finish.
Once this app is finished we do not plan to continue using Titanium.
We need to add push notifications to this app.
We have enabled Android push notifications using the standard GCM push servers using http://iamyellow.net/post/40100981563/gcm-appcelerator-titanium-module or https://marketplace.appcelerator.com/apps/5165#!overview
Does anyone know of a guide to use APNS that connects directly to the Apple servers and does not require sending the notification payload via ACS?
Thanks
The first step is to get the device token from apple to do this you have to register for Push notifications, you will find it in detail here
The process that follows is saving the token to your database and using it to send Push notifications, this blog explains it best.
Hope it helps.

Resources