确定日期(或版本)的应用程序从谷歌Play商店购买 - iOS设备appStoreReceiptURL等效 [英] Determine date (or version) that app was purchased from Google Play Store - equivalent of iOS appStoreReceiptURL

查看:682
本文介绍了确定日期(或版本)的应用程序从谷歌Play商店购买 - iOS设备appStoreReceiptURL等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确定我的Andr​​oid版本应用程式最初是从谷歌购买的用户Play商店。我需要这个信息,以帮助支持付费应用模式转向免费增值模式。

I'd like to determine which version of my Android app a user originally purchased from the Google Play Store. I need this info to help support moving from a paid app model to a freemium model.

在iOS7起,您可以通过使用做到这一点 [一个NSBundle appStoreReceiptURL] 返回App Store的收据,可以检查的URL。

In iOS7 onwards, you can do this by using [NSBundle appStoreReceiptURL] which returns a URL of the App Store receipt that can be examined.

有没有在谷歌API的等效?

Is there an equivalent in the Google APIs?

推荐答案

您可以通过使用获得的时间和第一次安装应用程序的日期


Getting Time and Date Install


You can get the time and date of the first install of the app by using

long installTime = context.getPackageManager()
                   .getPackageInfo("com.some.package.name", 0)
                   .firstInstallTime;

以及版本

PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
version = pInfo.versionName;

不幸的是,每当应用程序被卸载并重新安装该日期将重置。

Unfortunately this date will reset whenever the app is uninstalled and reinstalled.

如果你去

PackageManager pm = context.getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo("app.package.name", 0);
String appFile = appInfo.sourceDir;
long installed = new File(appFile).lastModified();

您还会发现出的当应用程序被安装日期的,但是回来的时候每包更新时会发生变化。

you will also find out the date when an application was installed, but the time returned will change every time the package is updated.

一个解决方案可能是您的应用程序,在那里你可以存储每个用户ID 使用的 AccountPicker ,其首次安装与方法如上所述,在登录使用它们。您也可以使用应用授权服​​务

A solution could be an online database for your application, where you can store each user's ID using AccountPicker, their first-time-install with the methods described above and use them at login. You can also use the App Licensing Service.

http://developer.android.com/reference/android/content/pm/PackageInfo.html#firstInstallTime

这篇关于确定日期(或版本)的应用程序从谷歌Play商店购买 - iOS设备appStoreReceiptURL等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆