【问题标题】:What's the correct way to use RMStore to get the original purchase date of an app?使用 RMStore 获取应用程序的原始购买日期的正确方法是什么?
【发布时间】:2014-07-09 07:45:21
【问题描述】:

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

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

[[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. 如果我想根据日期而不是版本号来建立逻辑,我可以这样做吗? RMAppReciept 上没有 originalPurchaseDate 属性。 (我确实提交了issue on GitHub。)

【问题讨论】:

  • Apple 文档中(某种程度上)回答了您的所有问题。 RMStore 可以帮助您避免编写样板代码,但我完全建议您在使用之前阅读 Store Kit 文档。

标签: ios objective-c cocoa-touch app-store rmstore


【解决方案1】:

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

收据中没有此类信息。不过,您可以获得应用内购买的购买日期。 RMStore 通过RMAppReceiptIAP 对象帮助您解决此问题。

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

按照@sergio 的建议,您可以从应用收据中读取原始应用版本。请记住,收据仅适用于 iOS 7。

我没有有效收据。领取流程是怎样的?我需要一个已经存在的应用程序包 ID 吗?哪里有测试收据?

沙盒环境中的应用会有一个测试回执,但你不能操作它的字段。

作为替代方案,您可以配置 RMAppReceipt 或模拟它来测试您的各种工作流程。

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

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

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

【讨论】:

    【解决方案2】:

    也许你想试试:

    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;
    

    【讨论】:

      猜你喜欢
      • 2016-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-21
      相关资源
      最近更新 更多