解析应用内购买还原功能

时间:2015-06-19 08:19:56

标签: ios parse-platform in-app-purchase

我的应用程序被Apple拒绝,因为没有为应用程序内购买恢复功能。

我正在使用Parse实现here,如果用户通过Alert控制器进行了先前的购买,并且用户选择了购买按钮时显示了恢复选项,则允许恢复购买。

所以我有两个问题:

  1. 通过ALert控制器恢复选项是否足以满足Apple指南?
  2. 如果没有,Parse In App Purchase API中是否有允许通过单击按钮进行恢复的功能?因为我在文档中找不到一个。
  3. Thansk In Advance

2 个答案:

答案 0 :(得分:2)

隐藏在文档的深处是:

 PFPurchase.restore();

如果已经购买,它会在观察者中执行该块 -

PFPurchase.addObserverForProduct("purchases.cases", block: { (transaction : SKPaymentTransaction!) -> Void in
            //set boolean to user defaults when in app p[urcahse is made, access agian in Tablevoew to relase cases

            let userDefaults = NSUserDefaults.standardUserDefaults();

            userDefaults.setBool(true, forKey: "inAppPurchaseMade");

            userDefaults.synchronize();

        })


        return true
    }

答案 1 :(得分:1)

link可能会有所帮助

另一件事是,苹果已恢复UIAlertController您不需要自己添加,只需编写恢复处理代码和按钮。

//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}
    }  
}