question

pcyanide avatar image
pcyanide asked

Using Application SKU with In-App purchaing SDK v2

I want to check programmatically, if my application was really purchased from Amazon AppStore Since not only an In-App item, but the application itself has an SKU at Amazon Appstore, will this SKU be recognized by Amazon In-App purchases SDK v 2? In other words, can I use the application SKU (instead of item SKU) for checking the purchase with Amazon In-App purchase SDK v 2?
iap
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DougM@Amazon avatar image
DougM@Amazon answered
Hello pcyanide, The SKU you use for your application would not be able to obtain as to whether or not it was installed by the Amazon Appstore, nor when it was last installed. In order to do this, our recommended approach would be to utilize the Android PackageManager class. final PackageManager pm = getPackageManager(); try{ String installerPackageName = pm.getInstallerPackageName("com.your.packagename"); if(installerPackageName.startsWith("com.amazon")){ //code to handle being installed by the Amazon Appstore here } PackageInfo packageInfo = pm.getPackageInfo("com.your.packagename",0); Date installDate = new Date(packageInfo.firstInstallTime); } catch(PackageManager.NameNotFoundException e){ e.printStackTrace(); } This way you can handle both which AppStore installed the app, and when the last fresh install of the app is. While that won't fully determine when your app was purchased, it should at least give you a good idea in most cases.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

pcyanide avatar image
pcyanide answered
Thank you, Doug Actually I considered checking installer, but this has several drawbacks 1. In user makes a backup of APK and installs it on a new device, the installer package name will be inadequate. 2. The information about installer package can be tampered. I can imagine a hack replacing installer package name by the one you like. I mark this question as answered, but still I am not quite satisfied, since I strongly believe that obtaining data from the site where the purchase was made is the only safe way to validate the purchase. In order to be competitive Amazon has to provide their answer to Google License Validation Library (LVL). Having application as another purchased item seems to be a logical way to go. Alternatively, there could be a special function within InApp Purchase library to query the purchase of current app. Probably I am not the only one who complains about that, so hopefully something will be done in the future.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.