How to share in-app-purchases between two Android apps

旧巷老猫 提交于 2019-12-01 08:40:54

Unfortunately, this is not possible. The in-app purchases are directly tied to the unique package-id used when the applications were first created.

The only way you could preserve app2's in-app purchase would be to merge app1 into app2, thus preserving the app's purchases. Finally, if that won't work, you'd have to hand roll a solution using a service other than Google Play Services.

It is not possible via In-App purchases API, but there are a couple of ways to work around this:

  1. Build your own backend for both apps and synchronize purchases. If you don't want to build entire backend yourself, you can use firebase authentication + firebase database. The obvious drawback, of course, is having to build and maintain backend, make users create an account, which will increase friction.
  2. If your users use will have both apps installed on your device, you could always expose a ContentProvider that shares the purchase information with another app. You can make it secure by checking the signature of a caller package and verifying it's the officially downloaded app. Alternatively to ContentProvider you could expose a service in one of the app and connect to it via AIDL from another app or you could have both apps share the user id and communicate directly. Drawback is having to ask your users to have both apps installed.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!