Pushing configuration changes to an iOS app - ios

we have an app which gets its configuration from a portal.
This is neither an MDM Portal nore any MDM Functionality is available in the app.
If the app starts for the first time, it contacts the portal and gets its initial configuration.
After this, it is polling the portal in a regular intervals to receive changes, if there is any.
I want to stop the polling. If there is a change, the Portal should PUSH it to its Apps. This can be done by Push Notifications, I can send some hint to the app, that there is new configuration to take it, but if the app does not run, the user can ignore this or according to the documentation, the PN is not a reliable system for vital information.
What could be the solution, did anyone have the same situation and solved it ?

You should use the silent push notifications (using content-available APNS payload key).
Of course this is not guaranteed to be received so you should also implement some sort of data versioning / etag / date last updated mechanism which you poll when the app is opened in order to download the latest data manually if your silent notification was not received.

Related

If APNs only stores the last push notification per device while offline, why am I receiving all? Working with Firebase

I have a production iOS app that is receiving, in most cases, all the missed push notifications while the device was offline once I connect it again to the Internet. This app uses Firebase Messaging to receive notifications and the default/recommended configuration code in Firebase's docs.
According to Apple, I would only expect only the last notification to arrive:
Quality of Service, Store-and-Forward, and Coalesced Notifications
Apple Push Notification service includes a Quality of Service (QoS)
component that performs a store-and-forward function. If APNs attempts
to deliver a notification and the destination device is offline, APNs
stores the notification for a limited period of time and delivers it
when the device becomes available again. This component stores only
the most recent notification per device and per app. If a device is
offline, sending a notification request targeting that device causes
the previous request to be discarded. If a device remains offline for
a long time, all its stored notifications in APNs are discarded.
source: apple push notifications documentation
Is Firebase doing something to ensure notifications delivery? I couldn't find any clear doc about this in the case of iOS.
On the other hand, I am working on a completely new version that uses the same Firebase Instance and client configuration, but this time I only receive the last notification no matter what. This new version is not yet released, so I'm testing it in a debug configuration (the production one is release config).
Not sure what is happening here; it's pretty confusing since the implementations are near identical. Has APNS/Firebase any policy regarding the release config and the QoS? I couldn't find anything related to that...
Thank you in advance!

Swift: Push Notifications not working after implementing Realm Database

I have a small messaging app and user receives a push notification whenever the user gets a message. Recently I have implemented Realm Database for my app. I am storing all the data that comes from the server into the realm directly and displaying the data to the user from realm. So, after shifting to this way the push notifications are not working. But again if I download the current version that is in the AppStore, the notifications are working. Every message has a messageID and we are sending the messageID as one of the parameter in the push notifications. Can someone help me on what I can do to make the push notifications working again.
Well, for getting push notifications to work, you not only need to configure the app correctly, you also need to configure the backend service & APNS linking correctly to get it to work.
You should try a methodical approach wherein you divide the entire feature implementation of push notifications into smaller sub-tasks like app side logic, backend configuration, Certificates & Provisioning Profile setup, etc. Try to examine each of these sub-task implementation & surely you would find the culprit. Since, you know the existing App Store version of the app is working,you have your task reduced

How to make an iOS app aware of data changes on the server without any user action?

Suppose I have an e-commerce ios app (like snapdeal, flipkart etc.) and I want to make my app notified when there is any change in the data stored on the server.
For instance, take an example of price change of any product in any category, so how can I update the price for that product without putting it to user's knowledge, whether the user is on that particular screen (currently seeing that product for which the price is changed) or on any other screen.
is it possible to do? if YES, how can I achieve that?
Thanks in advance!!
You have to use Apple Push Notification Service to do that.
It allows your server to send data to your app, that warns user or not (you choose), and your app is awake by this push a can work on background mode.
In order to allow you app to work in background, you have to enable Background fetch options
From Apple Background execution guide :
Apps that need to check for new content periodically can ask the system to wake them up so that they can initiate a fetch operation for that content. To support this mode, enable the Background fetch option from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the fetch value in your app’s Info.plist file.)
Edit about BaaS
As mentioned in comments, implementing the whole push notification system yourself can be difficult, especially if you are doing it for the first time.
That's why you can use a BaaS (Backend as a Service) that handle push notification for you like Parse.com, Firebase or whatever you want. It simplify a lot the process, but it remains APNS on the back, so it's important to understand how it works.
I'd recommend, like Mr. Blackus said in his answer, to use Apple Push Notification service. However, I will add one bit of information -
Don't use the service to send the actual data, only send a small packet of information telling your application to request more data from the server.
The process should be something like this:
Server asks Apple service to send Push notification to your app.
App receives push notification (but does not show any badge to the user).
App interprets the data sent from the server as a "refresh data" notification.
Fire POST or GET request upon determining type of notification received.
Update your data from the request response.
1.) Polling - app asks for list of products whose prices has changed. You can setup a timer, which triggers itself after every X seconds.
2.) Socket connection - between app and the server. App can generate a unique token (such as identifierForVendor), and use it in the socket conenction. Server can notifiy all the apps (using this token), to notify about the changed prices.
Approach 2 is better, as it is less expensive ( in terms of networking).
Hope this helps.

Unsubscribe from Apple Push Notification service

I'm developing an iOS app that enables the user to observe technical devices and be notified if there are problems.
What I know so far:
My app requests a token from the APNs.
My app sends this token to my server.
My server notifies the APNs in case of an event.
The APNs pushes a message onto the device.
What I want to know:
I read the token may change, therefor I need to request it on every app launch. Is this true?
If I get a new token from time to time I have to register at my server from time to time to make sure it uses the current token. Do I have to store and manually send the old token with the new one if the token changes to allow my server to delete the old one?
How can I detect that a user removed the app to remove his device on the server?
Highest priority in my case is for the server to know which devices are registered with the service. Old devices (old tokens that is) need to be removed immediately.
Thanks for your help.
You should register for the remote notification on every app launch and send the token to your server.
To check if the user removed the app or disabled notifications you have to check the feedback service. Look for it on this page:
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/BinaryProviderAPI.html#//apple_ref/doc/uid/TP40008194-CH13-SW1
Note: APNs monitors providers for their diligence in checking the feedback service and refraining from sending push notifications to nonexistent applications on devices.

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