Application removal and APNS - ios

How to avoid sending push notification to iOS app that is uninstalled.
Is there any way that we can catch application uninstallation event and call our server to stop sending notification.
What happens to the notification that is sent to device after the app is uninstalled.
Will old and new notification be available in the notification center even after the app is uninstalled.
Please explain.

The APNS Feedback Service exists for this purpose. When you connect to this service, you receive device tokens of devices that uninstalled your application, and you should stop sending push notifications to such device tokens.
When you send a notification to a device that uninstalled the app, Apple logs the device token and will send it to you the next time you contact the Feedback Service.

When you call the APNS service ,you will receive uninstalled app's device tokens.
After that checking those device token, you should stop sending push notifications to those device tokens.
Hope this help.

Related

OneSignal subcribers not updating after switching from Pushwoosh

I have an app which had 7,000 users subscribed on Pushwoosh. We switched from Pushwoosh to OneSignal and updated our app with OneSignal documentation. New users downloading our app are getting subscribed to our push notifications but the old ones are not getting updated.
Do we have to trigger permission to send push notification again ? Does Apple allow to do so ?
What is the workaround this ?
Notification Permissions & APNs Token
Notification permission is granted at the app level, so no matter what SDK / library is in your app it can read if the user has already accepted notifications and the APNs token.
The OneSignal iOS SDK does automatically check if permission is already granted and attempts to register for an APNs token. The OneSignal SDK will register the device with the app_id you put in your app and create a new player if it is the first time you opened the app since you added OneSignal.
APNs will return the same push token each time unless the user has fully uninstalled and reinstalled your app. However just in-case Apple were to deiced to rotate the token the OneSignal SDK does call the APNs register API to be sure.
Finding & Fixing The Issue
To find the issue I recommend the following;
Only include one push notification SDK in your app at a time, it possible for SDKs to have conflicts due to method swizzling or other possible issues.
In this case remove the Pushwoosh SDK if you using OneSignal.
Try to reproduce the issue on a test device by upgrading your app.
When testing the upgrade, I recommend enabling verbose logging in the OneSignal SDK.
OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
Also observe at this point if you are getting a user on the OneSignal dashboard.
If there was an issue getting an APNs token by the OneSignal SDK there will still be a user, they will just show as unsubscribed with details why.
This all depends on how you are getting the device push token from the user's device and sending it to OneSignal. A common mistake is to only get the device token the first time the user accepts the notification permission prompt. However, the device push token is subject to change randomly at any point in the future which can result in outdated device push tokens on the server used to send notifications.
To combat this, it is suggested to register for push notification every time the user launches the app. While this won't re-prompt them to accept notification permissions, it will fetch the device push token again. The push service you are using should then be updated with the new device token.
TL;DR: at every app launch register for a device push token and send it to your push server.

How to get responce of Push Notification sent via APN to check uninstalled users

I am sending bulk push notifications to IOS users through APNS , and want to check the response of all the users , to check if any of them has uninstalled the app or not.
You can't be sure with Push Notifications about anything, Apple never guaranty the delivery of the Notification.
Your notification may never be delivered simply because when you send it he is in high mountain hiking with no data cover, or his phone is turned of, or he has killed your app from task manager (unless your send a VoIP notification), ecc.

Update device token in iOS app for remoteNotifications

I have been developing an iOS app, which is sending remote notifications. For that I am saving the device token on our server. When the user logs in to our app, the device token saves on our server and remote notifications work fine.
But after some time, the notifications stop coming. I think it's due to that the device token changes but doesn't get updated on our server. I studied Apple's document on remote notifications; it says that if the device token ever changes, then it is the responsibility of the iOS to call the
didRegisterForRemoteNotificationsWithDeviceToken
of the app delegate with the updated device token. I have written the code to save the device token to our server in this method, but the device token does not change and remote notifications do not come.
Do I have to update the device token myself? If yes, then where to do that?

Is there any alternative then Push Notifications on iOS

Push notification has some drawback eg:
1. It doesn't revert if its delivered or not
2. If device was off the push notification arrives in bunch. (I don't need the old push notifications if device was off)
For the purposes of displaying messages to users who do not currently have your app open, there is no alternative to Push Notifications.
However, each of the drawbacks you mention does have a solution.
Determining delivery status
There are 2 possible reasons a notification will not be immediately delivered.
The device has uninstalled your app
If the device has uninstalled your app or opted-out of notifications, Apple will return the failed recipient device token through their Feedback Service protocol. In the newest HTTP/2 version of APNS, the failed recipient token will be returned as a response to your HTTP/2 connection.
The device is turned off or does not have a network connection.
Apple will attempt to deliver your most recent notification to the device when the device comes back online. If determining delivery status is essential to you, then you can supply the Content-Available flag and have your application report any successful deliveries of notifications.
Managing notifications when devices are turned off
By default, Apple will deliver only the one most recent notification per application when a device is turned on. This prevents the possibility of a user receiving a deluge of notifications from any single app when they turn on their device.
You can also prevent Apple from delivering old notifications by setting a TTL value. If the TTL expires before Apple is able to successfully send the notification to a device, the notification will be discarded.

iPhone - App Uninstallation notification

How can I get a notification from App Store or APNs when my iOS App gets uninstalled?
Also, if I send a push notification for the device where my App is uninstalled, what happens? Will Apple ban for such rogue Push notifications?
There isn't a way that your app will know if it is uninstalled. Also I do not believe there is anyway Apple will tell you if your app is uninstalled.
Apples Push Notification Service's FeedBack Service does provide a way to know if a device cannot receive a notification. However this does not guarantee that the device was uninstalled, only that it, for whatever reason, can not receive push notifications.
If a provider attempts to deliver a push notification to an application, but the application no longer exists on the device, the device reports that fact to Apple Push Notification Service. This situation often happens when the user has uninstalled the application. If a device reports failed-delivery attempts for an application, APNs needs some way to inform the provider so that it can refrain from sending notifications to that device. Doing this reduces unnecessary message overhead and improves overall system performance.
For this purpose 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.

Resources