Is there any way to get a notification when the user uninstalls my networked IPhone app, preferably including some custom data from the app's preferences like the user ID?
What I'm trying to do is to automatically delete the user's data from the server backend when they delete the app.
The only thing like this is the feedback service of Apple Push Notifications. So, if you're using push notifications and you can readily recreate the user's data if they reinstall the app, you can use the feedback service as a trigger mechanism for cleaning up your user database. Just make sure that all devices associated with the user record have deleted the app before doing this.
I think you have only approach - it is to set user data expiration time.
Check last user activity time using:
Push Notification Sending error (see #warrenm post)
or time when user had access to your services
or use log services like BugSence or TestFlight to do the same
Related
I am adding Push Notifications to my app and I know I need to store the device tokens in my database so that I can send push notifications to specific devices (or all devices).
My question is what is the best practice for maintenance of these device tokens? I can store all device tokens as they are received, but how can I detect and remove old device tokens that are no longer valid? I assume a device token can become invalid if user deletes the app, or if user turns off notifications for the app.
Update - Having a user authentication and linking it to the device token (and updating based on login/logout) makes sense. But what about if the user deletes the app? there is no logout, how do you remove the device token then?
The Apple feedback service is no longer used. Instead we have to look for a response status of 401 from the apple push notification service to determine that a token is invalid.
To test this in a development environment. Use the trick below (it says it's for feedback service, but should work with the new status code from APNS as well)
How to test Apple Push Notifications Feedback Service?
Use the APNS feedback service, to find the device tokens that belonged to an app that was uninstalled.
See this apple documentation
If you are using something like Amazon SNS for push notifications, you can use their API to get list of disabled arns and remove the corresponding device tokens from your database.
Make an webservice which stores user's device token in database for particular user. Call this webservice only if user is logged in or you have identify user as per your requirement. You need to call this webservice when device successfully register for notification and if user is not identify (i.e. not logged-in) then call this service after login api.
Also pass device token when in login and register API if you have according to your flow and replace device token for particular user.
And when user logout just unregister for notification
As you said in your last statement I assume a device token can become invalid if user deletes the app, or if user turns off notifications for the app.
General scenario is when user again login to the app or register to the app you need to again take the device token from the user and need to store it in your database
Suppose I had one app and again I install only that at that time whenever I login again to the app at that time the api must having parameter for deviceID so whenever api call happen for login at that time new device token take place in your database by just replacing the old one. Same thing will happen for new register with that app.
Hope above description help you. :)
Your app server won't know if a particular app has been forcefully deleted & your server would still have let's say token T1 mapped to deleted app/device let's say A1. Now, it may be possible that another valid user (A2) comes up with same device token T1. You just need to make sure that at any point of time one device token (i.e. T1) is mapped to only one device (the device which has provided the T1 latest). All other older device token mappings i.e. A1-T1 shall be deleted at this point else A2 might receive A1's notifications.
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?
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.
I have an app that creates pdf's for the user. When this app creates a new pdf (say on the users i-pad) I want the iwatch to display a notification saying a new pdf has been created.
Does this require a server, it was my understanding apple could provide this service.
Any help or tips would be appreciated!
First to address the difference between local and push notifications. Local Notifications would be used on the specific device the user is on at the time, and is normally scheduled for a specific time such as the reminder app notifying you at a scheduled time. Push notification are sent via a server to other devices.
Since you want to send to the other devices you will want to implement push notifications. In order to do this the user will need your app on all devices. Additionally you will need to have a login system so you know which devices belong to the same user. From there you will need a push notification service that can do targeted push notifications. There are many services out there and you will need to decide which one is right for your situation.
Push notifications are sent to the device by using the device token Apple provides after the user approves notifications for your app. Each app on each device has their own device token. So in addition to targeted notifications you will want a push service that allows you to setup channels such as parse.com, that way you can setup a channel specific to each user (email, username, or ...). Then when your user logs in on any device and approves getting push notifications, their channel will be set to (whatever option you choose) and you can trigger the push notification to the specific channel and will send the notification to any device.
There are other consideration but this is a good place to start.
Local notification is just that, local to that device. Remote notification is what you need. You will either need to create a server for this purpose or use one of the variety of third-party services (Urban Airship, Parse, etc) to provide that functionality.
Clarification point -- when you say:
I want their iphone, and every other device that they have to receive a notification that a new pdf has been created
it is assumed that you mean "every device of theirs that is running your app and has approved notifications from your app". If you're trying to piggy-back on some magic AppleID-related foo, that won't be possible.
A very simple task that took me 30 minutes to implement on an android.
A web server sends a message to device. Without user interaction a receipt is sent back. User understands that this is a desired behavior. When user opens the app he/she can send additional acknowledgement.
My understanding is that as long as I am not using location service I cannot run app in background continuously (or periodically). Push notifications will require user interaction, otherwise it's just a badge and a message.
This seems like a trivial problem but makes my head hurt and want me to give up.
Is Enterprise subscription the only way for me to get the app to our company users?
First you need to ask user permission to send PUSH notifications. Once the user agrees for you to send PUSH notifications to his device, you need to get the device ID and store it in your servers. This is the FIRST phase of PUSH-NOTIFICATION
In the next phase (SECOND phase), lets say you want to notify the user about something, what you do is get all deviceIDs for that user (he might have registered more than 1 iOS device) and send some X message to his device(s) leveraging apple's PUSH infrastructure. You need to pass the deviceID's to Apple (along with a bunch of other stuff) as this is how it identifies which device gets this X message.
Also initially while registering for PUSH, you need to write a little code to configure how your PUSH notification will look like. Would it have SOUND, BADGE, MESSAGE etc.
For all this to happen you as a app developer do not need to concern whether you app is ACTIVE or not. iOS takes care of it. After the initial PUSH registration the user too is not involved. You dont need to run your app in the background nor do you need to register for continuous location updates.
Have I understood your question correctly?