Restore In App Purchases on New Devices / Deleted Apps on the same device using restoreCompletedTransactions
我在App Store中有一个应用,并且我要带
当用户购买产品时,我设置了一个
对我来说很好。
我的问题是关于恢复。
我对此有很多疑问,但是我对解决方案还不清楚。
如果用户购买了IAP,它将存储
1 2 3 4 5 6 7 | - (void)restoreThePurchase { // Similar to the purchase // Ask the App Store to restore rather than create a payment. We call it via the SKPaymentQueue. // When we've sent that ot the App Store, the App Store will get back to the App Delegate and get back to the paymentQueue updated:Transactions to the restore. [[SKPaymentQueue defaultQueue]restoreCompletedTransactions]; } |
我有三个班级:
-
IAPViewController 包含购买和恢复的UIButton -
e100EntriesPurchase 包含诸如购买和还原之类的IAP方法。 -
eUnlimitedEntriesPurchase 包含用于无限购买以及进行购买和还原的IAP方法。
按下还原按钮时,我检查设备具有哪个IAP,然后调用适当的还原方法。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - (IBAction)iapRestorePurchaseButton:(id)sender { // When the restorePurchase button is tapped, we will run a few tests. if (([[NSUserDefaults standardUserDefaults] boolForKey:@"FullVersion100Entries"]) && (![[NSUserDefaults standardUserDefaults] boolForKey:@"FullVersionUnlimitedEntries"])) { [self.e100EntriesPurchase restoreThePurchase]; NSLog(@"100 yes but unlmited no restore!!!!!!!!!!!!!!!!!!!!!"); } else if ((![[NSUserDefaults standardUserDefaults] boolForKey:@"FullVersion100Entries"]) && ([[NSUserDefaults standardUserDefaults] boolForKey:@"FullVersionUnlimitedEntries"])) { [self.eUnlimitedEntriesPurchase restoreThePurchase]; } else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Restore Unsuccessful" message:@"Your Apple ID doesn't have an active purchase for upgrading to Pro." delegate:nil cancelButtonTitle:@"Thanks" otherButtonTitles:nil, nil]; [alertView show]; } } |
因此,当我删除并重新安装该应用程序时,我将面对
我不确定该怎么做,但是我怀疑当我购买商品时,我不仅需要做一个
任何有关此问题的指导都将非常有帮助。
当用户点击"恢复购买"按钮时,您应该执行以下操作:
1 | [[SKPaymentQueue defaultQueue]restoreCompletedTransactions]; |
新交易将被推送到状态为"已恢复"的付款队列,应用应将其视为任何新购买的交易。