首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用RMStore获取应用程序的原始购买日期的正确方法是什么?

使用RMStore获取应用程序的原始购买日期的正确方法是什么?
EN

Stack Overflow用户
提问于 2014-07-09 07:45:21
回答 2查看 1.2K关注 0票数 0

我发布了我的应用程序的更新版本,我正在从付费到免费过渡。为了给现有用户提供免费广告体验,我希望跟踪他们最初购买该应用程序的时间。

我正在查看RMStore,但我不清楚如何从收据中读取原始的购买日期。我想出了一些我认为应该有效的简单代码,但是我没有一个很好的方法来测试它。

代码语言:javascript
复制
[[RMStore defaultStore] refreshReceiptOnSuccess:^{

    NSURL *url = [RMStore receiptURL];

    NSData *data = [NSData dataWithContentsOfURL:url];

    RMAppReceipt* r =[[RMAppReceipt alloc] initWithASN1Data:data];

    // Cheap and easy conversion to a float...
    //  IRL do a real comparison with the strings...

    if ([[r originalAppVersion] floatValue] < 2.0)
    {
        //  Do something for early-adopters
    }

} failure:^(NSError *error) {
    // Ruh-roh!
}];

我有两个问题:

  1. 我没有有效的收据。拿到一个的程序是什么?我需要一个已经在运行的应用程序包ID吗?有测试收据吗?
  2. 如果我想将逻辑建立在日期而不是版本号的基础上,我可以这样做吗?在originalPurchaseDate上没有RMAppReciept属性。(我确实提交了一个关于GitHub的问题。)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-07-09 09:31:14

使用RMStore获取应用程序的原始购买日期的正确方法是什么?

收据中没有这类信息。不过,你可以获得应用程序内购买的购买日期。RMStore通过RMAppReceiptIAP对象帮助您完成这个任务。

为了给现有用户提供免费广告体验,我希望跟踪他们最初购买该应用程序的时间。

按照@sergio的建议,您可以从应用程序收据中读取原始的应用程序版本。请记住,收据只在iOS 7中提供。

我没有有效的收据。拿到一个的程序是什么?我需要一个已经在运行的应用程序包ID吗?有测试收据吗?

沙箱环境中的应用程序将有测试收据,但您不能操作它的字段。

作为一种选择,您可以配置RMAppReceipt或模拟它来测试您的各种工作流。

如果我想将逻辑建立在日期而不是版本号的基础上,我可以这样做吗?在originalPurchaseDate上没有RMAppReceipt属性。

没有应用程序收据,因为在应用程序级别没有这样的字段。

顺便说一句,避免在启动时刷新收据,因为它会显示Apple密码提示。只有当您找不到收据或信息丢失时才刷新。

票数 2
EN

Stack Overflow用户

发布于 2014-07-09 08:03:02

也许你想试试:

代码语言:javascript
复制
RMAppReceipt* appReceipt = [RMAppReceipt bundleReceipt];    
if ([[appReceipt originalAppVersion] floatValue] < 2.0)


/**
 Returns the app receipt contained in the bundle, if any and valid. Extracts the receipt in ASN1 from the PKCS #7 container, and then parses the ASN1 data into a RMAppReceipt instance. If an Apple Root certificate is available, it will also verify that the signature of the receipt is valid.
 @return The app receipt contained in the bundle, or nil if there is no receipt or if it is invalid.
 @see refreshReceipt
 @see setAppleRootCertificateURL:
 */
+ (RMAppReceipt*)bundleReceipt;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24648031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档