【问题标题】:App rejected for not having "Restore" Purchases feature应用因没有“恢复”购买功能而被拒绝
【发布时间】:2015-08-06 22:43:18
【问题描述】:

我的应用因未实现“恢复购买”功能而被拒绝。

苹果说

我们发现您的应用提供可恢复的应用内购买 但它不包括允许用户恢复的“恢复”功能 之前购买的应用内购买。恢复以前 购买的应用内购买产品,应提供 一个“恢复”按钮并在“恢复”时启动恢复过程 按钮被点击。

所以我最终决定添加它,我发现我们必须使用

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

但这无济于事! 我搜索了类似的问题,但没有发现适用于我的应用程序。 这些是我到目前为止堆叠的以下链接:

Restore already bought in-app-purchases on iPhone?

iOS6 - In app purchase with download from Apple server

请帮忙!!提前谢谢..

【问题讨论】:

  • 顺便说一句,您需要一个可见的“恢复按钮”,而不仅仅是自动恢复的代码
  • 是的,我已经添加了!!

标签: ios objective-c in-app-purchase restore


【解决方案1】:

尝试以下方法:

点击恢复按钮 -->

- (IBAction)retoreinApp:(id)sender
{
    //set  addTransactionObserver to self. 
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

}

这将调用

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {

    UIAlertView *alert ;
    if(queue.transactions.count >0)
    {
        for (SKPaymentTransaction *transaction in queue.transactions)
        {
            NSString *productId = transaction.payment.productIdentifier;

          NSLog(@" ProductIdentifier is %@",productId);
            if([productId isEqualToString:@"com.xy.yourProductId"])
            {//add code to add it to your account
             }
          alert = [[UIAlertView alloc ] initWithTitle:@"Restore Transactions" message:@"All your previous transactions are restored successfully." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

  }
    else
    {
        alert = [[UIAlertView alloc ] initWithTitle:@"Restore Transactions" message:@"No transactions in your account to be restored." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    }
    [alert show];

}

【讨论】:

    【解决方案2】:

    更新@user4936766 对Swift 5

    的回答
    import StoreKit
    
    class ViewController: UIViewController {
    
        @IBAction func retoreinApp(_ sender: UIButton) {
    
            SKPaymentQueue.default().add(self)
            SKPaymentQueue.default().restoreCompletedTransactions()
        }
    }
    
    extension ViewController: SKPaymentTransactionObserver{
    
        func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) { }
    
        func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Error) { }
    
        func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
            var alert: UIAlertController!
            if(queue.transactions.count > 0){
                for transaction in queue.transactions{
                     let productId = transaction.payment.productIdentifier
                     print(" ProductIdentifier is \(productId)")
                     if productId == "com.xy.yourProductId"{
                        //add code to add it to your account
                     }
                }
                alert = UIAlertController(title: "Restore Transactions", message: "All your previous transactions are restored successfully.", preferredStyle: UIAlertController.Style.alert)
             }
             else{
                alert = UIAlertController(title: "Restore Transactions", message: "No transactions in your account to be restored.", preferredStyle: UIAlertController.Style.alert)
             }
             let cancel = UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: nil)
             alert.addAction(cancel)
             present(alert, animated: true){}
        }
    }
    

    中文视频播放应用iQiYi中的“恢复购买”按钮样式。

    【讨论】:

      猜你喜欢
      • 2018-10-18
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-18
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      相关资源
      最近更新 更多