PushKit for VOIP iOS apps - ios

Maybe this is a trivial question, however it is not yet clear to me if the server side is impacted when PushKit frameworks will be applied in a VoIP iOS app.
The SIP server for example sends an INVITE to my app, the notification is received in the app and the call is established.
Is the server impacted when PushKit.framework is used? Who is sending the pushkit event? The SIP server or Apple? Is this similar to APNS?

It is exactly like APNS as far as the server is concerned. It just comes with added benefits for the client (the iOS app).
The client registers with the Apple servers and gets a token in return. The app registers the token with your server. Your SIP server can use the token to send the notification with the appropriate payload. That is sent to APNS which then forwards it to the device.

Related

sending gcm upstream from iOS app when app is not in foreground + gcm API for uploading APNs certificate

I have two questions about APNs push notification using gcm library.
Does gcm or fcm have a public api for uploading APNs certificates? I need to do this automatically instead of manually.
It seems that sending upstream using gcm library in an iOS app, only works when app is in foreground. Is it correct? Is there any workaround to send upstream even when app is not open or is in background? I want to send notification click event using gcm upstream to my server and it is highly preferable to do it instantly.
I am aware that I can save this click event and send it when app become active, but it is possible that user does not open the app for a long time.
1. Does gcm or fcm have a public api for uploading APNs certificates?
There is currently no public API for uploading APNs Certificates. For FCM (and any new projects), it's only done via the Firebase Console. Also, it seems that making use of the APNs Authentication Keys over certificates seem more convenient now (APNs Overview).
2. It seems that sending upstream using gcm library in an iOS app, only works when app is in foreground. Is it correct?
Yes. There has to be a connection for upstream messaging to work.
Is there any workaround to send upstream even when app is not open or is in background?
AFAIK, no. As mentioned in the FCM doc (emphasis mine):
To send messages upstream to the server, an iOS client app composes a message, connects to FCM, and calls sendMessage.
To connect, set the shouldEstablishDirectChannel flag to YES in the AppDelegate. FCM manages the connection, closing it when your app goes into the background and reopening it whenever the app is foregrounded.
...
The FCM client library caches the message on the client app and sends it when the client has an active server connection. On receiving the message, the FCM connection server sends it to the app server.
It mentions that FCM manages the connection, however AFAICT, there is this limitation for iOS devices that limits apps to maintain running services if the app is in background/closed (see this answer). And if a connection can't be established, upstream messaging won't work.
As general practice, data passed through FCM should as much as possible improve the user experience and that no app critical data is passed.
I am aware that I can save this click event and send it when app become active, but it is possible that user does not open the app for a long time.
It's possible. But it's also highly unlikely for a user to not click on a push notification immediately after it displays. In that scenario, the usual action would be for the user to immediately click on the notification while there is still an open connection.

SIP server/provider with PushKit

I develop a SIP app in iOS and I would like to know if anybody have found a sip server that supports PushKit. It might be
an existing sip provider
an opensource sip server (eg asterisk) with this capability implemented
The SIP server doesn't need to support PushKit, this is something in iOS. There are 2 types of push notifications that the app can recognize and handle differently.
Through the Apple developers portal you will need to generate a certificate type of Voip Services. Use this and the token while pushing and in iOS register and lookout for these.
This site shows differences between push types: https://zeropush.com/guide/guide-to-pushkit-and-voip
Apples best practices for VoIP: https://developer.apple.com/library/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html
On your SIP server, you will just need to send a push notification on an incoming call. If you use Asterisk you can use AGI so you can perform the push in whichever language. I've always just use APNS but there's a bunch to choose from like AWS, Urban Airship, Onesignal.
Urbanship confirmed that they would not support voip push in the near future (at the end of 2016). Finally, I found I can just use houston to send voip push. From my experience sending voip push and apn push are just the same from our side, e.g. they send to the same apple server, so I guess apple server will differentiate them based on their tokens and give voip push a higher priority.

ios - i make messenger app APNS based, but if client's notification set off , client doesn't receive message by the other client sent by APNS

My app gives and takes message by APNS.
but if client's notification set off , client doesn't receive message by the other client sent by APNS.
Is this wrong way?
If it is not, how does client receive message When client's notification sets off?
You can't rely on APNs alone for this. Notifications can be turned off and even if they are on, APNs is a "best-effort delivery" service. This means it makes no guarantee that the client will ever receive the notification, but it tries its best to deliver it. Your app should query the server for new messages, and notifications can help you make the query at the right moment. Your server can notify your app that there's a new message, then the app calls the server to get that message. But of course since notifications aren't guaranteed, your app has to reach out to the server at other times also i.e. when it enters foreground.

Can we send push notification to APNs from iOS device?

I want to send push notification from a iOS device to another iOS device without using backend server. Is it possible for an iOS device to act like a server and send push notification to APNs server?.
Thanks in advance.
Theoretically you can send Apple Push Notifications from a device directly to another device. All you need are the push certificate of the app, the device token of the device you are sending the notification to, and code that establishes a secure TLS connection to the APNS servers.
However, there are several practical problems that make the use of a server almost mandatory :
You need a single place where all the device tokens of all the devices that installed your app will be sent to and persisted in. The best such place would be a server. Without a server, how would device A send its device token to other devices that want to send it push notifications?
Apple require that you keep connections with the APNS server open for as long as possible and use the same connection for sending many notifications. If you open a connection to APNS server on your device, it will probably be short lived (since devices switch networks frequently, and don't stay connected to the internet all the time). Therefore, if you try to send many notifications frequently, and each time use a new connection to APNS, you will probably be banned (since Apple would treat this as DDoS attack).
If you store the push certificate in each device that installs your app (to allow it to send push notifications to other devices directly), aside from the security issue of storing the certificate in many places, you'll have to publish a new version of your app each time the push certificate expires (once a year), and push notifications would stop working for users who don't upgrade to the new version.
Try NWPusher.
It has an iOS framework for sending pushes and has an iOS demo application that sends push notifications from iOS to iOS.
You also need to consider Server costs (other than maintenance and development time if you code your own server).
By sending the push directly from the app device:
- you obtain a much better scalability (since you don't have to centralize everything on your server)
- you don't have to pay for server cost or other service's cost
You can use for iOS:
- https://github.com/noodlewerk/NWPusher Pusher
And for Android:
- Send push notification GCM by java

How do iOS Push Notifications work?

How do iOS "push" notifications get delivered to a particular device without that device needing to poll a server?
For example, let's say I have received a new message on Facebook. Facebook notifies Apple that my device should receive a notification as such. But how does Apple know which device/IP to push the message to?
Each device can be updated with data using their own unique device tokens. This picture explains everything . .
It was too much for me to put in a comment so.
From the documentation.
Apple Push Notification service (APNs) propagates push notifications to devices having applications registered to receive those notifications. Each device establishes an accredited and encrypted IP connection with the service and receives notifications over this persistent connection. Providers connect with APNs through a persistent and secure channel while monitoring incoming data intended for their client applications. When new data for an application arrives, the provider prepares and sends a notification through the channel to APNs, which pushes the notification to the target device..
I suggest reading the documentation for more information and how to use and configure. It's all there.
Push Notifications
I created an infographic to explain the workflow of push notifications. Hope this is helpful.
Device does not keep polling the server for the push notifications.
To keep it simple, consider an iPhone is connected to internet. On connecting to internet iPhone establishes connection to Apple Push Notifications server this connection is open connection which means data can be thrown to iPhone from server the moment data arrives to server.
Apple does not use HTTP protocol for Push notifications but if you understand HTTP Protocol its almost a similar methodology.
http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push
There is a really nice exaplanation of push notifications in this article.
In iOS, apps can’t do a lot in the background. Apps are only allowed to do limited set of activities so battery life is conserved.
But what if something interesting happens and you wish to let the user know about this, even if they’re not currently using your app?

Resources