Firebase Cloud Messaging and IOS strengths and weaknesses - ios

I have built an application using phonegap. So far, all of the application features work in both Android and IOS. Now, I would like the app to receive push notifications.
I plan to use Firebase but a friend has warned that FCM can only send push notifications to IOS if a user manually types a message into the FCM console (As in there is no API which would allow my server to send push notifications to IOS manually). The docs haven't helped me prove or refute this warning. Can anyone tell me if I can programmatically send push notifications to IOS using Firebase?

Yes, it is possible to send messages to iOS through Firebase Cloud Messaging through its (server-side) API. You can either just target iOS devices, or send a message to both iOS and Android devices with specific details for each platform.
For full documentation, see https://firebase.google.com/docs/cloud-messaging/send-message.

Related

Invertase: Firebase Cloud Messaging (FCM) with iOS devices

I'm trying to use push notifications on iOS devices with react-native.
I'm using Invertase and I managed to make them work on Android.
The only things I'm doing are:
ask for the permission with messaging().requestPermission(); and registering a token with
firebase.messaging().getToken()
I can get a token on both devices. However when sending them with admin.messaging().sendToDevice
does display the notification on Android but not on iOS although I don't get any error for both.
What Am I missing? Is there something more to do to handle notifications on the iOS part? Do I have to use zo0r/react-native-push-notification or wix/react-native-notifications?
Could you provide a push notification code example working on iOS with Invertase?

iOS push notification using FCM

Currently we are using AWS for sending IOS push notifications and FCM for Android notifications. As FCM also supports IOS notifications, we want to consider that for 2 reasons
It is free service (AWS is not that costly)
to have single interface from app server for push and web notifications
but from FCM documentation, it looks IOS app has to be tightly integrated with FCM API for delivering push notifications (this is not required for AWS). so i want to know if there is a way I can send push notifications without any change to iOS app code.
The iOS app must be configured to receive messages from the FCM Servers.
You'll have to implement the necessary functions (callbacks specifically) in your client app that will handle/receive the messages as mentioned in the Setting Up a Firebase Cloud Messaging Client App on iOS.
It's also through implementing the needed functions you'll be able to generate a token needed by the FCM servers to send a message towards the device(s).

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

How PubNub publish subscribe works internally in iOS (client side)

I wanted to know what technology it uses to deliver real time messages iOS given all the os limitations. There are few of them comes to my mind are
Periodic polling
Persistent connection to server such as websocket or xmpp
Push Notification
Do its publish subscribe works even when app is in background?
As of 4.0, the PubNub iOS SDK does not receive subscription events when the app it is running in is suspended. You can set up Push Notifications via PubNub's APNS gateway to receive push events, but they are handled like standard push notifications and not like PubNub events.
When your app is running, PubNub appears to use a websocket connection to send and receive notifications. The client you create receives callbacks when messages are received on the channels you subscribe to.
Their SDK is open source, so you can inspect what is happening internally if you're interested.
PubNub and Background Connectivity
Staying connected in the background an continuing to receive realtime messages via subscribe is not a function of the PubNub SDK and it does not matter if you are using PubNub iOS 3.x SDK (please don't, it has EOL'ed) or PubNub Objective-C for iOS 4.x SDK (please start using this or migrate to it ASAP). You have to configure and implement your app to run in the background and Apple has to give you permission (via the app review) to do so.
Your app has to be of the type that justifies background activity: see Apple dev docs for iPhone OS Programming Guide - Background Execution (table 3.1)
There is a great tutorial at RayWunderlich.com on Background Modes in iOS that does a great job of explaining all the options.
There is PubNub Swift for iOS SDK 4.x, as well.

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.

Resources