1

I have successfully implemented In-App billing with Anjlab iab v3 and tested it successfully, but how do I unlock my paid flavor version within the same app.

Flavors

flavorDimensions "default"
    productFlavors {
        free {
            minSdkVersion 15
            targetSdkVersion 27
        }
        paid {
            minSdkVersion 15
            targetSdkVersion 27
        }
    }

Checked resources here, here, here

I don't want to:

intent.setData(Uri.parse("market://search?q=pname:MyApp")); 

Not sure, if that will work: I thought to put everything in Free Ver. (with paid version features kept as invisible) and set it to visible mode if the purchase is successful. But then, what's the point of putting Flavors in the first place.

It would be great if we can get simpler version of how to implement In-App in Google Play, since Documentation & Sample seems little hard to implement, also we are getting info on this in bits-&-pieces here on SO.

If the payment is successful, what should be the next steps for unlocking Paid version. Right now I passed my intent, which is not a efficient way to do it.

@Override
    public void onProductPurchased(@NonNull String productId, @Nullable TransactionDetails details) {
        Intent paid = new Intent(this, Test_Paid.class);
        startActivity(paid);
    }

What I want is when the payment is successful it should always open the paid version instead of free version, which is not the case right now.

Thanks!

In-app purchase successful

1 Answer 1

2

There are two ways to achieve paid and free versions of the app:

  1. Different product flavours: If u go this route, then basically your paid and free versions are two different apps altogether. User has to download one or the other independently from play store. Product flavour is a build time property. Once an apk is generated, you cannot switch the product flavour.

  2. Keep paid features invisible: If you want a single apk, this is the way to go. Once a user pays for the subscription, you can store this data at your backend and notify the client at launch via an api if the client is a paid one or not.

If you don't have a backend, you can save the hasUserPaid flag in a local sqlite db with some level of encryption/security. Drawback of this is that the db will be cleared once user uninstalls or clears data of the app. To repopulate, you will have to verify with the play services if the user had purchased your subscription.

2
  • Thanks @Udit can you elaborate on your 2nd point as in if I don't want sqlite db, is there nothing else? Jul 10, 2018 at 5:40
  • 1
    you have to use on disk storage of some sort. if not that, you can look into shared preferences. If sqlite is syntax heavy, try room
    – Udit
    Jul 10, 2018 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.