How to recognize specific apk build, even if user update apk in Google Play
Asked Answered
H

4

8

I need to recognize users with specific apk build. This build has some features comparing to normal apk (like some functions are PRO at start).

build for GooglePlay------>
                           ----> next version of apk
build for some Customers-->

I thought about saving some data to database, so even if I update apk I, will have pernament data no matter what version user will have.

The problem happens when the user didn't run the application but immediately updated to next version. User didn't initialize sqlite, so no data was stored.

Is there any way to keep data and reuse it even if user updated base apk to newer version?

Herbivore answered 11/8, 2017 at 11:39 Comment(13)
i didn't understood your question properly. Do you want to migrate your database properly? if no db_version found, can't you just update your db incrementally?Binion
What part of question You don't understand?Herbivore
why is it necessary to initialize the db? what happens if not initialized before updating?Binion
It was only first idea. My aim is to recognize separate builds in two devices. One of the build should have premium features. So far so good. However I would like to have opportunity update both versions without losing old preferences on both devices. Updating version might delete features on premium apk build.Herbivore
ok, why don't you use separate build flavor for premium and non-premium version?Binion
in this case I would have to take care of both versionsHerbivore
u will have to maintain only flavor specific code, rest of the code will be common. same as in any other case.Binion
yes but both apps should be updated by Google Play service, from one address. How separate flavour would help here?Herbivore
I think there's provision for that too!Binion
I am not following YouHerbivore
According to my understanding your question. Either you want to keep mobile reference or another data. If you want to save mobile reference you can save its MAK address in another place(remote server) and calling it after you update your App by web request. And after compare current MAK address with that you save you will know which device you are in. Or if you want save another data it will be easier.Remittance
@Herbivore what I meant was that you probably can use one google play service address and maintain multiple app flavors.Binion
@Herbivore also, I didn't understood 1 thing in your ques: suppose I am a new user who installed your app, but didn't opened it, now suppose I update the app. Now whatever features you provided for free with the new version will also be available to me whenever I open the app. And regarding maintaining the list of premium features, is it something that you are maintaining on your own server or you are using in-app purchases or something similar?Binion
W
3

You can't, at least not without root or any other "patch"-solutions.

There are a few solutions which doesnt work well and need some preparation.

Solution 1:

Create a second App which must be preinstalled and have a PACKAGE_ADDED receiver. Onec it receives the installation of your App it will run it at least onec.

Solution 2:

Create a BOOT_COMPLETED receiver but this means that the device need to reboot to get activated. Even with this solution it may or may not work. Since Android 3.1 google have added a security policy to require (the most devices) that the App has been started at least one time to get in activate-state (some manufacturer dont have this security policy).

Solution 3: (Only working solution)

Create a different Package for your "Customers-App". Onec the app is installed from Playstore and started, it will validate if an app with the customers-namespace is installed. If yes, then it will start to do your Customers-Sqlite-Stuff and uninstall the app after.

Example:

com.myapp.customer -> installed com.myapp.playstore -> installed -> started -> validate if com.myapp.customer is installed and activate the "customers routine" -> remove com.myapp.customer

Edit:

Using Androids Gradle Plugin 3+ allows your to create flavors which allows you to create different package names / builds easily. https://developer.android.com/studio/build/build-variants.html

Wavemeter answered 13/8, 2017 at 21:22 Comment(0)
C
1

In my understanding, your app is completely offline.

If it is offline. You can only identify the user is a pro by asking them.

You can make users get pro features by entering Promo code. get the promo code from the user and provide them pro features.

If your app is Online and has web services.

Then you can simply check pro users when they open the app by calling your server and provide them Pro features.

Another idea is checking Build Number and provide the pro features.

Get the version number by calling BuildConfig.VERSION_CODE

Crate answered 19/8, 2017 at 15:28 Comment(1)
I dont think this will answer his question since he didnt ask how to define "pro"-services, but asked how to get state of a preinstalled app when installing / updating to another version from the playstore.Wavemeter
N
1

In the case of your customer did not run the app before updating it through the store, there's any code of your "pro" variant that can be execute, so I'll try to use the only thing that is "done" when app is installed, the permissions.

Maybe try to add one permission only in "pro" variant that is not really necessary in your app, but that you can check later if user had accept it through first install, and so know which apk it was.

You can also give a try through Install Referrer that is normally used to identify source of your install origin (often used by market tools). Have a look at this Get referrer after installing app from Android Market

Nils answered 19/8, 2017 at 16:36 Comment(0)
A
1

This solution depends on if you have access to your special users through email for example.

Android supports deeplinking, for your PRO users you could point them to a link to enable the PRO features. If a user opens this link, then your app would open. You can store the unlock in SharedPreferences so it survives updating to newer versions later on.

Optionally, you could also send your users to a login page (the link you send them). If they login successfully it redirects to the deeplink.

Another alternative in the same direction is by associating your app to an unusual file extension (i.e: .fff) and mail a .fff file to your PRO users. That will prompt them to open the file with your app which will allow you once again to record their activation of the pro features.

Both solutions allow you to activate different feature set if, for example, you have different feature group (pro, business, superpro, ...)

Antipasto answered 20/8, 2017 at 3:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.