开发者

Tracking auto-renewable subscriptions for magazins

I'm trying to implement 开发者_如何转开发the auto-renewable subscriptions but something is not really clear for me.

If I have for example a magazine like app and want to track the subscriptions even if they are invalid now, do I have to save the receipts in my app (e.g. Core Data)? I have to track them all because I have to give the user access to old issues even if the subscription is invalid. So either it has the status code 0 oder 21006.

Another question is why Apple uses the 21006 status code for canceled subscriptions that were canceled by Apple because for example somebody mistakenly made a subscription. How can I determine if that happend when I only know that it's invalid now? It could also be invalidated because it is out of the subscription period. I have this Information from the WWDC 2011 Video on iTunes U.

Any help would be appreciated ;-)


Apple recommends you store and verify all receipts on your server, not necessarily on the app. To check on the status of someones subscription, just verify any receipt you have stored for that user. (it must be a receipt from the same subscription family) Then Apple will respond with the latest receipt in that subscription. You can use this information to provide the user with all issues of the magazine up until the expiration date of that receipt. You can do this all on the app if you want, but Apple discourages it since you'd have to store your iTunes verification secret in the app itself.

As for your second question, my assumption is that Apple sees refunds as outside-the-norm. So they don't want to make any concessions for it. They don't want to make it easier or automated. That's why you don't get a special code that means 'the user's subscription was cancelled due to refund.' I would hope that this is rare enough that simply providing the magazine articles for free to refunded users, won't make you broke. (and since your receipt verification will show that their account isn't renewing, you don't have to give them new issues).


Apple recommends you store and verify all receipts on your server.

(OR)

RMStore delegates transaction persistence and provides two optional reference implementations for storing transactions in the Keychain or in NSUserDefaults. You can implement your transaction, use the reference implementations provided by the library or, in the case of non-consumables and auto-renewable subscriptions, get the transactions directly from the receipt.

  -(void) startProductPurchase{

 [[RMStore defaultStore] requestProducts:[NSSet setWithArray:_products] success:^(NSArray   *products, NSArray *invalidProductIdentifiers) {

    _productsRequestFinished = YES;
    NSLog(@"Product Request Finished");
    [self buyApplication:products];
   } failure:^(NSError *error) {

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Products Request Failed", @"")
                                                        message:error.localizedDescription
                                                       delegate:nil
                                              cancelButtonTitle:NSLocalizedString(@"OK", @"")
                                              otherButtonTitles:nil];
    [alertView show];
   }];

Refresh receipt notifications (iOS 7+ only)

 - (void)storeRefreshReceiptFailed:(NSNotification*)notification;
 {
 NSError *error = notification.rm_storeError;
}

 - (void)storeRefreshReceiptFinished:(NSNotification*)notification { }

Receipt verification

RMStore doesn't perform receipt verification by default but provides reference implementations. You can implement your own custom verification or use the reference verificators provided by the library.

Both options are outlined below. For more info, check out the wiki.

Reference verificators

RMStore provides receipt verification via RMStoreAppReceiptVerificator (for iOS 7 or higher) andRMStoreTransactionReceiptVerificator (for iOS 6 or lower). To use any of them, add the corresponding files from RMStore/Optional into your project and set the verificator delegate (receiptVerificator) at startup. For example:

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
  const BOOL iOS7OrHigher = floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1;
_receiptVerificator = iOS7OrHigher ? [[RMStoreAppReceiptVerificator alloc] init] : [[RMStoreTransactionReceiptVerificator alloc] init];
[RMStore defaultStore].receiptVerificator = _receiptVerificator;
// Your code
return YES;
 }

For more details follow the below links.

iOS In-App purchases made easy

A lightweight iOS library for In-App Purchases

Welcome.

Hope it will help you.............

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜