remove iOS push notification after fresh reinstall - ios

I have application which has successfully integrated apple push notifications, when user logs in to the application app registers with the push notification and token is saved on our back-end, when user sign out from the app, we remove the push notification tokens from our back-end. but if user uninstall app from the device WITHOUT SIGN-OUT from app, and then re-install,in that case we can still send push notifications to the device, since app is newly installed and not logged in any user we have to remove tokens from the backend. since iOS app does not have any API for uninstallation events how can I remove device token from back-end. I can use push notification feedback service to get uninstalled device tokens but how can I resolve the issue when user removes the application and then reinstall.
I tested this scenario with skype, it also have this issue. (install Skype > Log In > (now you can send app to Background and send some chats from any other device, you will get push notifications) > then Remove app from Device without Sign-Out from Skype > Re-Install Skype > now if we send skype chat we receives push notifications but skype app is newly installed and no one is logged in)

I guess the best thing you can do is to preventively unregister/remove the tokens, when the app is started without a logged in user. You should update the registration anyways each time the app is started, so register/unregister at each app start, depending on if a user is logged in or not. This way, if the user reinstalls the app and starts it the first time, it will be unregistered.
This is the best behaviour you can achieve, as it is the same for Twitter, Facebook, Skype, etc...

I think you are not able to get an event or detect if a user has removed the app or not. What you can do is to send periodic notifications to a device (only setting the badge, without sending a notification) and remove the tokens for what you get a 401 status code. Then you know the app has been removed and you can delete the token.

Yeah! as you have quoted yourself it will continue to send notification unless your server has the info that someone has logged out. Obviously you won't get the info when your app was uninstalled and then reinstalled.
Workaround: If your app is reinstalled you can call an API to deregister since no user is logged in.

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.

When App deletes (uninstall) getting a mail iOS

I made uninstall some apps from my iOS device. Then i got a mail from app developer for particular app.
How they get particular device make uninstall the app?
I followed below links but not getting proper solution.
Detect iOS application about to delete?
How to get the device details when user uninstalls the ios application
Basically, As you know there is no event is fired when App is deleted from the iPhone.
But you can do your tasks when the app installs so basically you can check application by sending the silent push notification.
Apple server will inform you when you try to push to an uninstalled instance the notification response at the sender side will come 410 means, user, no longer activate.
APNS REQUEST/RESPONSE
If you do not get the proper response from application side that means your application is uninstalled and you can send the mail.
Helpful links:
Call status change web-service when my App is deleted

How to prevent push notifications to app after reinstallation?

Since iOS 9 application changes apns token after reinstallation of an application.
But iOS 8 and 7 doesn't do it.
How can I distinguish next situation using iOS 8 and iOS 7?
User installed an app.
User launched app and allowed push notifications in the app. (I getted some token)
User logged in/registered. (I connected token with registered user).
User deleted the app.
User installed the app, launched it once and allowed push notifications. (getted the same token, )
After these actions, this unregisterd user will get notifications about some actions in his account without needs to log in.
If it were a bank/finance app, it would influence the security of registered user.
How to prevent this?
You can call
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
in
-application:didFinishLaunchingWithOptions: method. Then, when user logs in, register for remote notifications.
But anyway, if app is uninstalled and installed again, it will not receive push notifications until -registerForRemoteNotifications get called, and you must call this method ONLY after user authentication. Even if token is same as previous one, it will associated with this new user, and your server should handle that.

iOS Detect whether my app is still installed on device

I am developing for enterprise application and no need to submit to app store.
We need our user to install our app as mandatory. If they delete, we need to track and may advice to install back.
Currently, I am thinking to do like this.
1) Send silent push notification to device and app reply back to server.
2) Run background service daily and post to server back.
Problem is that for push notification, if user deny access, it will not be working. For background service, if user don't accept allow, it won't be working too.
Is there any way to do for that?

Best way to use APNS with a login validated app

I need to implement push notifications for an app does works under a valid user and password. This authentication is handled using some web services on the server side now and was wondering which would be the best way to send push notifications for such app, as it's possible that the user is not logged in at the app, then he/she shouldn't be able to see the push notification. The same applies when another user has logged in on the same device.
Haven't found much information on this but think the best would be that the app sends status information(login, logout) to the server, so the server, before sending a push notification, checks if a user is logged in at the app, and which user is logged in. This could have some issues as it could happen that the app crashes or the mobile goes off, and the app is not able to send a logout status to the server, which would lead to push notifications for a not logged-in device. Probably there are other issues with this approach.
Any ideas or guidance would be appreciated.
Your assumptions are correct. You can certainly tell the server when you have logged in/out, but there is always a chance that the login state can become unsynchronized between the device and the server. You could implement the desired functionality while the app is running by maintaining a persistent connection to the server and only sending a push notification while the connection exists; if the app crashes or is exited the connection would break and push notifications would stop. This won't help if you want to receive notifications when the app is exited or backgrounded, however.

Resources