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.
Related
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.
Is it possible to receive Web Pushes in an electron app?
I don't need to display the Notification, only data is important.
Maybe someone used Onesignal, successfully with electron?
Thanks!
Unfortunately this isn't possible at the moment.
Web Push requires the browser vendor to maintain a server that keeps a connection open to each user to deliver notifications, and to store notifications while a device is offline. Electron has no such system set up for it.
It may be possible to extend Electron to use the operating system's built-in notification system. For example, Apple does have OS X notifications (currently supported by OneSignal), and Windows has a notification system built into it too (which OneSignal will support soon). Using this would require writing native extensions that bridge Electron to the operating system. This would have the added benefit of supporting notification delivery while your Electron app was not open.
Edit: This is now possible with Pushy, a paid notification product that
now supports Electron.
This is technically possible but requires a bit of lifting. If you use the OneSignal REST API in your client you can add your device, and with electron-push-receiver (https://github.com/MatthieuLemoine/electron-push-receiver) you can receive and display the push notifications that OneSignal sends.
Start under "Add a device" in the REST docs here: https://documentation.onesignal.com/reference
You'll first register your device with FCM (firebase cloud messaging) and then pass that FCM token along to OneSignal via their REST API.
I just responded to this thread with a brief description of how to do this: https://github.com/OneSignal/OneSignal-Website-SDK/issues/98
I am trying to implement an iOS chat application using Pusher or PubNub (websockets).
Question: How does message delivery work when the iOS app is in the background?
I understand that Websockets implementations provide real-time messaging and don't cache the messages. Is the message lost because the socket connection is broken when the app is in the background?
If yes, how do I recover the lost messages? One idea is to implement a state refresh protocol every time the app comes to foreground.
PubNub Missed Message Recovery Options
You mentioned PubNub (the company I work for) and as #FrankG mentioned, unless you have permission from Apple to run your app in background (staying connected to internet, and therefore, PubNub), you will not receive any message in realtime.
You can use PubNub's Mobile Push Gateway and receive APNS push messages while you app is in background (but idle/not running) or completely not running (kill state).
When the app is activated again, PubNub can be configured to automatically retrieve missed messages from the channel(s) it was subscribed to, but this is good for short periods of disconnection.
For longer periods being offline, you can enable Storage & Playback and use the historyForChannel API to fetch all the missed messages of all channels you require.
Answer: It doesn't.
If the iOS app is in the background, you are out of luck. There is no official (and Apple sanctioned) way of keeping a connection open when the app is in the background. There are hacks like playing a silent audio track to keep it in the foreground, but Apple doesn't approve of such hacks. You'll need to use APNS to send an offline message to bring the app to the foreground so it can reconnect.
And you are 100% correct that the WS standard does not address caching. That has to be performed by another subsystem in your architecture.
The Kaazing Gateway (disclosure: the company I work for) has a feature in our messaging Gateway that caches the last value sent. When the client reconnects (our client libs auto-reconnect), they will see that value.
I was wondering if its possible, using PubNub to route a message as a push notification, even if the app is running in the foreground?
One way that I can think to do this is to:
Handle any specific routing and events that need to happen first.
Check the push note portion of the message and send a local device notification. Alternatively any custom UI, etc could be done here.
PubNub does send the push notification when the app is in the foreground. In fact, PubNub (the mobile push notification server) does not know if the device is foreground, background or not running at all. So the push notification is always sent to the device either way.
See the following PubNub Developer Community article, Sending APNS and GCM Messages to Subscribers and Mobile Push Notification Services in One API Call, for more details.
Also refer to the PubNub iOS Mobile Push Gateway Tutorial for Realtime Apps. These docs are about to get a major upgrade in terms of completeness.
I want to use the push notification feature of Worklight, but worry about the reliability. According to the "Quality of Service" section in Apple Push Notification Service, APNS doesn't guarantee the arrival of the message. I heard that IBM provides a MMQT mechanism for this situation, but did't find any reference from Worklight's Guides.
I also noticed that Apple doesn't allow network operations when the APP is running in the background state. So is that possible to maintain its own persistent connection and receive messages by an APP? Is there any solution to implement a reliable push notification on iOS?
Using MQ Telemetry Transport Protocol in IBM Worklight Mobile Applications
Not sure I understand this one... When a Worklight application is in the background and you send a push notification the device (the OS...) will detect this and if you tap on the notification the app will then come to the foreground. If this doesn't answer your question, edit your question in greater detail.