In app purchases restore Button

喜你入骨 提交于 2019-11-28 15:48:04
Nikita Pestrov

Alex, i've been rejected for the same reason last week, and this is right what Apple wanted - after adding such a Restore button they didn't ask any other question on this subject.

Of course, you need not only to call [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];, but implement the restoring itself too (i mean, providing the content to user).

I use a variation of this:

//inside of an IBaction
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];


// Then this is called
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
    NSLog(@"%@",queue );
    NSLog(@"Restored Transactions are once again in Queue for purchasing %@",[queue transactions]);  

    NSMutableArray *purchasedItemIDs = [[NSMutableArray alloc] init];
    NSLog(@"received restored transactions: %i", queue.transactions.count);

    for (SKPaymentTransaction *transaction in queue.transactions) {
        NSString *productID = transaction.payment.productIdentifier;
        [purchasedItemIDs addObject:productID];
        NSLog (@"product id is %@" , productID);
        // here put an if/then statement to write files based on previously purchased items
        // example if ([productID isEqualToString: @"youruniqueproductidentifier]){write files} else { nslog sorry}
    }  
}

Sorry, I'm on my iPad if this makes no sense.

Alternative to restore button could be a restore switch in app settings bundle. It does not overwhelm UI and seems like Apple welcomes it (but be sure to mention that you have implemented mechanics this way).

BOOL shouldRestorePurchases = [[NSUserDefaults standardUserDefaults] boolForKey:@"restorePurchasesKey"];

I've been rejected for the same reason. It's due to the fact that you can be signed in with the same Apple ID on different ios devices.

For example, let's say I'm logged into test@iCloud.com on an iPad. When I download your application I realize that I would like to remove the ads (let's say you have ads on your app if you don't), so I remove them for 99¢. One year later, I decide to buy an iPhone, and sign into test@iCloud.com on that account, and I download your app again. The ads are still there, though, even though I already payed for them. Who would like to pay for the same thing twice? With the restore feature, I can restore the purchases that I made on my iPad, and make them work on my iPhone.

To restore the purchase, you could use:

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

After that, you need to also provide the content that the user bought.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!