Question

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!

Was it helpful?

Solution 2

I got it working, and just in case anyone in the future is having the same problem, here is what I did. I deleted the in-app purchase and created a new one in iTunes Connect, reinstalled MKStoreKit using cocoa pods, re-entered the in-app purchase id into the MKStoreKit plist file, and waited a day and now everything is working just fine!

OTHER TIPS

From what I can see, MKStoreKit calls the completion block whether or not any purchases were restored. You see, there may not have been any purchases to restore even if no errors were encountered.

What you should do to test the restore feature is:

  1. Add to the -application:didFinishLaunchingWithOptions: method of your app delegate:

    [[MKStoreManager sharedManager] removeAllKeychainData];
    
  2. Create a new test account on iTunesConnect.

  3. Use this test account to make a purchase in your app.
  4. Call +isFeaturePurchased: to make sure the purchase was successful (should return YES).
  5. Force close your app and relaunch it so that -removeAllKeychainData gets called.
  6. Call +isFeaturePurchased: to make sure that the app doesn't know that the product has been purchased (should return NO).
  7. Call -restorePreviousTransactionsOnComplete:onError:.
  8. Call +isFeaturePurchased: to make sure the product was restored (should return YES).

Make sure you are using the same test account throughout this process.

As an aside, MKStoreKit doesn't do any receipt checking on iOS7 so you may want to try a more recent library like RMStore instead (appears to be available in cocoapods too).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top