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



我正在发布应用的更新版本,我正在从付费模式过渡到免费模式。为了给现有用户一个无广告的体验,我希望追踪他们最初购买应用的时间。

我正在查看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的性质。(我确实在GitHub上提交了一个问题)

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

收据上没有这样的信息。不过,你可以获得应用内购买的购买日期。RMStore通过RMAppReceiptIAP对象帮助您实现这一点。

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

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

我没有有效的收据。办理手续是什么?我是否需要一个已经上线的应用包ID ?有测试收据吗?

沙箱环境中的应用程序会有一个测试收据,但是你不能操作它的字段。

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

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

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

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

也许你想试试:

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;

相关内容

最新更新