I was under the impression that the GCM registration is always the same for the same combination of device, application and application version.
But now I realized that it always changes when I uninstall the application and then install it again.
The Problem
My app create a profile for each device the user uses. So if a user install the app, uninstall it and install it again, the app will have two profiles for the same user in the same device.
I am currently storing the registration id in the shared preferences to update the profile if the registration id changes, but when the app is uninstalled the shared preferences are lost.
The Question
Is there anyway to preserve the registration id after the app is uninstalled?
Any other idea of how can I update one of the existing profiles (identified by the old registration id) instead of creating a new one?
You can use Google Backup Services to preserve data of application even after uninstall
Ref: http://developer.android.com/guide/topics/data/backup.html#BackupKey
OnBackup() // can save GCMId
OnRestore() // can retrive the same
Related
I want my application to know if it was installed & started already on the device. Currently, I store a unique user ID key in the shared preferences on the device. Restarting the application loads the user ID from the shared pref and hence, the application knows it was started previously. But after an uninstall and re-install, that shared preferences are gone byebye. Im aware I could write some file in external/internal storage of the device and those will not be removed on uninstall. But is there a more common technique to achieve my requirements? Other applications may read the contact's phone number use it server-sided to determine it, but I dont want to add such personal permissions to my app.
I am new to cordova app development and I am not sure how to approach this application workflow.
The workflow is that:
1. user download and installs the app
2. he ca use basic feature without registration
During this time (unregistered user with app installed) on backend we have to track the user activity and in case he register using email to upgrade his profile and keep his previous activity.
A solution to this will be to generate a user GUID on mobile when user first install the app. Send it to backend and use this as a future reference of the user.
Where can I store this GUID to be reliable and not to be cleared by the browser/application cache. If user clears the application data I would like the GUID to stay.
It will be great if this setting will stay if user upgrade the app or uninstall and reinstall later.
V Best,
Radu
You shouldn't storage data in a device when the user uninstall it, but if you still want it, check this plugin:
https://github.com/apache/cordova-plugin-file
You can save in different locations, even in the external storage of the device, which doesn't get deleted when the app is unistalled
Cordova unique device id plugin generate a UUID that remains the same after app uninstall and works on iOS and Android.
On iOS it generates a UUID and store it in the Keychain.
On Android it concatenates various IDs unique to the device but needs the android.permission.READ_PHONE_STATE permission.
I have a Cordova app built in version 5 that I am testing on my Android device - it has a login system that uses an API to authenticate a username & password.
It has logged in but when I uninstall the app then re-install it the app still is logged in??!
I have even tried to empty the cache for the app but I am always still logged into the same account - can anyone suggest what I am doing?
Any advice appreciated.
-- update --
The app has a login screen (username/password) which basically connects to an external API - this API queries a database which returns the account details & sets a token which is used for subsequent requests to retrieve the same user account.
The app doesn't have any logout functionality (it should do really) but it should logout once the app has been re-installed.. really odd.
I've tried the 'Clear Data' and 'Clear Cache' options within the App settings but the same problem persists.
-- Update --
This is the js file that appears to do all the logic with the storage (I am not quite sure how this works.. it was developed by a different group of developers)
https://gist.github.com/gkimpson/f234ac2f33f9455e7291
I want to update an app. but I want to check either this user new or old( had ever been install my app?) I thought I can check the sharedpreferences. but maybe the user cleared the data.
any other ideas?
Regards
If you're looking to see if a user has previously installed your application and are worried about the user possibly altering the state of your phone, you can contact a separate database to retrieve which device ID has previously installed the application.
Upon first use of your application, you can save the device ID.
To determine the unique device ID, you can look at
Is there a unique Android device ID?
Can I define that application was installed earlier? For example I can check whether application is installed or not installed but if application was installed and later was uninstalled. Is there way to check it or not?
Phone does not store any information about the uninstalled app. If ur app has a backend, then try saving UDID in the server when app is installed. So that u can check next time whether the app is once installed and uninstalled in a phone. But if ur app is a stand alone app with out any server, u cant do that.
Uninstalled apps are per default leaving no trace on the phone.
If it is your own app you want to check whether was installed and later uninstalled you could code your app to leave a trace, either on a server (sending the phone ID to the server) or on the SD Card. Both methods requires permissions.
If it isnt your own app you want to check whether was installed and later uninstalled you are out of luck, sorry.
You could create a file on the SD card when the application is installed the first time.
Then when it's reinstalled, your application will check the presence of this file.
If you are supporting FCM in your app .
Than have a look at the server side api for sending the notifications
If sending fails to a user , we can consider that user has uninstalled the app.
Have a look at the following article.
https://medium.com/what-is-singleton-pattern-and-why-we-need-them/how-to-track-uninstalled-users-from-app-using-fcm-afdba7301116
I haven't gone though backend apis for FCM. not sure whether we get this info while pushing out a notification to a single user or a group of users.
my intention is that try for FCM if it useful for you to determine the install/uninstall status