Regarding Push Notification and Apple Development Licence - ios

I would like to ask about notifications and apple development license.  In addition to adding users to our shared backend on server, we will also be installing the system on user internal networks, in dedicated self-hosted implementations.  In such a scenario, how is the installation of the Push Notification system affected, versus our current installation on the platform?  Can we install multiple servers, each with its respective notification systems running concurrently at different user sites?

You can have many servers sending push notifications - there is no problem with that. You would need to handle centralized or distributed database of the users devices IDs (to which you want to send notifications), so you don't end up sending same notifications to the same device from your multiple servers multiple times.

If by installing the system on user internal networks you mean networks not connected to the internet, then you can't use Apple Push Notifications, since it requires access to Apple's servers.
If, however, you simply mean that multiple servers connected to the internet would send push notifications to your app, you can do it. I assume you'd want each subset of devices that install your app to send their device tokens to a different server, which will send push notifications to those devices. Each server would need your push certificate in order to send notifications to your app. You can either share the same certificate with all servers that host your server code, or create a different certificate for each server.

Related

Use Meraki to send push push notifications to the app

I am developing an iOS app for a client which is Meraki controlled. The Meraki solution is controlled by the client, I just ship the ipa file via a plist file.
Now I want to add push notifications as an enhancement to the app. As Meraki works based on push notifications (Meraki Push Notification), I was wondering if I can actually use it to send app related push notifications?
So can I ask for the p12 file of the client, deploy it on our server and send push notifications on API calls (e.g. C# push notifications IIS) which would spare me using a third party provider or my own push service?
You can use the Meraki AP's Bluetooth Beacon if you have a model MR32/42/52/53/72. This sends a message directly to the mobile app. You'll need the mobile app to have the Apple iBeacon service running.
You can also use Meraki's CMX Location API to detect a device's MAC address. It sends an HTTP post to your server. You'll need a server to host a listener, but fortunately ciscoshipped.io will host it for free.
developers.meraki.com

How to reliably assess uninstalls on iOS?

I'm trying to detect uninstalls of our iOS app.
I read this document which gives some useful information. However, how can I understand from the error codes returned whether the user uninstalled versus disabled push notifications/has no connectivity?
I think you'll want to use the Feedback Service. When a user deletes an app, the service provider should ideally stop sending notifications to that device. But Apple does not notify the service that "this device is not using your app, dont send notifications". Technically, a device which has uninstalled your app will not make it onto this list until the next time a push notification goes to the device. So you need to poll for this info using the Feedback Service.
Periodically, you will need to hit Apple Notification servers asking it to give you IDs that have deleted your app. Once you get them you mark them in your DB as deleted thereby not sending any more notifications. This Feedback Service will tell devices that have been unregistered (app uninstalled). The part I'm not sure about is whether a user who has turned off push notifications in settings will register the same. I believe they will not show up in the feed from the Feedback Service. I am certain, however, that users who are offline and the push notification is not delivered will not be included in the list.
It would be a simple test in your dev region to try the app, disable push notifications for the app, and then see if the device shows up in the feed.
Take a look at Apple's documentation
From Apple Documentation -
Apple Push Notification Service includes a feedback service that APNs
continually updates with a per-application list of devices for which
there were failed-delivery attempts. The devices are identified by
device tokens encoded in binary format. Providers should periodically
query the feedback service to get the list of device tokens for their
applications, each of which is identified by its topic. Then, after
verifying that the application hasn’t recently been re-registered on
the identified devices, a provider should stop sending notifications
to these devices.
Access to the feedback service takes place through a binary interface
similar to that used for sending push notifications. You access the
production feedback service via feedback.push.apple.com, port 2196;
you access the sandbox feedback service via
feedback.sandbox.push.apple.com, port 2196. As with the binary
interface for push notifications, you must use TLS (or SSL) to
establish a secured communications channel. The SSL certificate
required for these connections is the same one that is provisioned for
sending notifications. To establish a trusted provider identity, you
should present this certificate to APNs at connection time using
peer-to-peer authentication.
Make sure you also read up on - Issues with Feedback Service

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 should I handle push notifications with an app that's distributed through multiple channels?

We have developed an iOS app that makes use of push notifications.
Our client wants to distribute the app through their own MDM server. This means they'll compile and sign the app themselves and also have the appropriate APNS certificate, which we include in our server-side application. So far, so good.
Now, the client also wants to distribute the app to other devices that aren't connected to the MDM server. This would mean a different (AdHoc, App Store, ...) distribution channel with a different certificate chain.
How should we handle this on our server side where we send the push notifications to the APNS?
Can we just send every push notification twice, once with each certificate? Do we need to determine which app installation requires which device (depending on the distribution channel)?
This is basically dependent on the way you distribute the app. When distributing if the application identifier is the same it will refer to same app. If it different only it will install multiple times. Means if you have the same app id in both cases its enough to send one notification so that no matter how you distribute it will send the notification. In case if you have changed the app ids yes you have to send that multiple times. Another thing you may do is to change the app id slightly and introduce a wildcard for app id. Which is also fine to send one notification.

Receiving push notification even after the app is deleted iPhone

I implemented push notification in my app.
It is working fine.
Now the problem is even after i deleted my app from device it is getting the push notifications.
So is there any way to unregister the app from push notification when it is deleted from the device.
Hoping for your help.
Thanks in advance.
In Apple push notification there is something called - Feedback Service. So when a user deletes an app, the service provider should ideally stop sending notifications to that device. But Apple does not notify the service that "this device is not using your app, dont send notifications". So instead you need to poll for this info.
Every day you might need to hit Apple Notification servers asking it to give you device Ids who have deleted your app. Once you get them you mark them in your DB as deleted thereby not sending any more notifications. Hope this is what you wanted.
From Apple Documentation -
... Apple Push Notification Service includes a feedback
service that APNs continually updates with a per-application list of
devices for which there were failed-delivery attempts. The devices are
identified by device tokens encoded in binary format. Providers should
periodically query the feedback service to get the list of device
tokens for their applications, each of which is identified by its
topic. Then, after verifying that the application hasn’t recently been
re-registered on the identified devices, a provider should stop
sending notifications to these devices.
Access to the feedback service takes place through a binary interface
similar to that used for sending push notifications. You access the
production feedback service via feedback.push.apple.com, port 2196;
you access the sandbox feedback service via
feedback.sandbox.push.apple.com, port 2196. As with the binary
interface for push notifications, you must use TLS (or SSL) to
establish a secured communications channel. The SSL certificate
required for these connections is the same one that is provisioned for
sending notifications. To establish a trusted provider identity, you
should present this certificate to APNs at connection time using
peer-to-peer authentication.
Be sure to checkout - Issues with Feedback Service
Having not seen this answer so far, there is a small note in the Apple "Troubleshooting Push Notifications" document.
In short, if you delete the last push enabled app, the persistent connection from the device to Apples push server is broken before the server is told that the app has been deleted.
Solution: keep at least one push enabled app on your device.
There is the explanation from the document:
Issues with Using the Feedback Service
If you remove your app from your device or computer and then send a push notification to it, you would expect to have the device token rejected, and the invalidated device token should appear on the feedback service. However, if this was the last push-enabled app on the device or computer, it will not show up in the feedback service. This is because deleting the last app tears down the persistent connection to the push service before the notice of the deletion can be sent.
You can work around this by leaving at least one push-enabled app on the device or computer in order to keep the persistent connection up. To keep the persistent connection to the production environment up, just install any free push-enabled app from the App Store and you should then be able to delete your app and see it appear in the feedback service.
Recall that each push environment has its own persistent connection. So to keep the persistent connection to the sandbox environment up, install another development push-enabled app."

Resources