Android Question Advertising ID alternative?

marcick

Well-Known Member
Licensed User
Longtime User
Hi all
I was using the advertising ID to identify a device for licence purposes.
Now I see that is better to abandon this method (in the future a list of zero can be returned when users choose to delete their advertising ID in order to opt out of personalization advertising).
So I’m looking for an alternative. I don’t want to use a random code that is lost if the user uninstall and reinstall the app. Any idea ?
 

Bladimir Silva Toro

Active Member
Licensed User
Hello @marcick

Personally I use the Phone library, you can generate an ID and then combine it with a random number and with that I get a unique serial.

Try this code:
B4X:
Dim MyPhone As Phone
Dim IDAndroid As String=MyPhone.GetSettings("android_id")
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Thank you. I see it can change after an hardware or factory reset, but that's better than nothing
 
Upvote 0

PassionDEV

Well-Known Member
Licensed User
You can check this thread


But from many cases i have experienced this may return zero on phones that doesn't have Google service in it.

Best way to identify the user is to use firebase authentication, client sign in, grab the token, encrypt the token, send it to your backend and check the token to return the registered client id. Preventing multiple accounts creation can be a big hassle though..
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
You can check this thread


But from many cases i have experienced this may return zero on phones that doesn't have Google service in it.

Best way to identify the user is to use firebase authentication, client sign in, grab the token, encrypt the token, send it to your backend and check the token to return the registered client id. Preventing multiple accounts creation can be a big hassle though..
Hello @PassionDEV

Excuse me, is it the same as the FirebaseInstanceId? ´

Link: https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId

since this solution has the following problems:

1649434213130.png
 
Upvote 0

udg

Expert
Licensed User
Longtime User
I was using the advertising ID to identify a device for licence purposes.
I may be wrong, but if your customer pays you for a license fee (monthly, yearly, whatever) you know its unique data already (e.g. for an invoice).
So, why not derive a unique identifier from its data (or simply use his/her email) and let the user enter it as a first-time configuration step?
This way, even if the device is resetted or substituted with a new model, the customer has simply to enter that "registration code" you once gave him/her.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I may be wrong, but if your customer pays you for a license fee (monthly, yearly, whatever) you know its unique data already (e.g. for an invoice).
So, why not derive a unique identifier from its data (or simply use his/her email) and let the user enter it as a first-time configuration step?
This way, even if the device is resetted or substituted with a new model, the customer has simply to enter that "registration code" you once gave him/her.
really the app is free and there is nothing to pay, but I want to identify each single device that is running the app.
And I want if the user uninstall and reinstall the app is already registered without asking again user data.
On IOS I generate a random ID and store it in Keychain, butI can't see this possibility on Android.

But I'll think about what you say. Thanks.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Well, in that case, you could generate your unique ID and show it to the customer warning him/her to keep it safe somewhere in case he/she needs to reinstall the app.
If among the user data you collect an email, you could send that unique ID by email as part of the registration process.
On reinstall, an option asks to enter the "previous" ID or complete the registration form.
 
Upvote 0

PassionDEV

Well-Known Member
Licensed User
Hello @PassionDEV

Excuse me, is it the same as the FirebaseInstanceId? ´

Link: https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId

since this solution has the following problems:

View attachment 127676
No its not similar to FirebaseInstanceId. It returns the mediadrm uuid
But this may fail and return null on some Android versions. And in some cases it returns zero value. But for me this is a fail solution for apps that needs to trace and validate who is using there apps without registration.
Firebase authentication is the best you can do to identify your application users or better yet you can build your own web registration api and generate a user id to each registered user and store it in a database in your backend server.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Hello @marcick

Personally I use the Phone library, you can generate an ID and then combine it with a random number and with that I get a unique serial.

Try this code:
B4X:
Dim MyPhone As Phone
Dim IDAndroid As String=MyPhone.GetSettings("android_id")

but ... if you combine it with a random number why do you disturb android_id ?
This way also your id will change if the user uninstall and reinstall the app.
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Hello @marcick

You're right. Look I explain what I do in free applications.

When registering your application on a new device, make sure you take the android id (android_id) and request the email and a password to enter your application.

With that you can already identify that user by email and mobile by android id. If the android id (android_id) changed, something happened with the mobile and you can know it
 
Upvote 0

Similar Threads

Top