0

I'm trying to use MKStoreKit to implement in-app purchases in an app of mine. It is working great for the most part, except for one thing that I can't figure out. I'm using the following method to restore transactions.

-(void)restoreToFullVersion:(UIViewController *)sender{
    [MBProgressHUD showHUDAddedTo:sender.view animated:TRUE];
    [[MKStoreManager sharedManager] restorePreviousTransactionsOnComplete:^{
        [MBProgressHUD hideHUDForView:sender.view animated:TRUE];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"userDidUpgradeNotification" object:nil userInfo:nil];
        [self upgradeSuccessful];
    } onError:^(NSError *error) {
        [MBProgressHUD hideHUDForView:sender.view animated:TRUE];
    }];
}//end method

I have nslogged the completion block and the above code all works as expected except for if you then call

[MKStoreManager isFeaturePurchased:kMainNoncomsumable];

it returns false. Am I correct in thinking that after the restore process has completed MKStoreManager should return true for isFeaturePurchased or am I missing something?

I am only implementing one non-consumable in-app purchase and included MKStoreManager into my project using Cocoa-pods.

It seems as if other people on SO are having the same problem, but I have not found a valid solution yet.

Thanks in advance for all the help!

4

2 回答 2

1

据我所知,无论是否恢复了任何购买, MKStoreKit 都会调用完成块。您会看到,即使没有遇到任何错误,也可能没有任何购买可以恢复。

测试恢复功能应该做的是:

  1. 添加到-application:didFinishLaunchingWithOptions:您的应用委托的方法中:

    [[MKStoreManager sharedManager] removeAllKeychainData];
    
  2. 在 iTunesConnect 上创建一个新的测试帐户。

  3. 使用此测试帐户在您的应用中进行购买。
  4. 致电+isFeaturePurchased:以确保购买成功(应返回YES)。
  5. 强制关闭您的应用程序并重新启动它以便-removeAllKeychainData被调用。
  6. 致电+isFeaturePurchased:以确保应用程序不知道该产品已被购买(应该返回NO)。
  7. 打电话-restorePreviousTransactionsOnComplete:onError:
  8. 致电+isFeaturePurchased:以确保产品已恢复(应返回YES)。

确保您在整个过程中使用相同的测试帐户。

顺便说一句,MKStoreKit不会在 iOS7 上进行任何收据检查,因此您可能想尝试使用更新的库,例如RMStore(似乎在 cocoapods 中也可用)。

于 2014-01-07T05:49:15.273 回答
0

我让它工作了,以防万一将来有人遇到同样的问题,这就是我所做的。我删除了应用内购买并在 iTunes Connect 中创建了一个新的,使用可可豆荚重新安装了 MKStoreKit,将应用内购买 ID 重新输入到 MKStoreKit plist 文件中,并等待了一天,现在一切正常!

于 2014-01-08T17:39:26.220 回答