Clearing purchases from iOS in-app purchase sandbox for a test user

前端 未结 8 1001
臣服心动
臣服心动 2020-12-02 07:18

Does anyone have any ideas on how to reset and/or clear the iOS in-app purchase sandbox?

I have an app that I\'m testing with the sandbox, and I\'d like to test new

8条回答
  •  孤街浪徒
    2020-12-02 07:53

    Well, technically you don't need that.

    If you get SKPaymentTransactionStateRestored, it is 100% equivalent to the app store verifying the user and granting him the purchase. I have a switch like:

    - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
    {
      for( SKPaymentTransaction *purch in transactions )
      {
        switch( purch.transactionState )
        {
          case SKPaymentTransactionStateRestored:
            info( "PURCHASE RESTORE" ) ;
            // fall thru
          case SKPaymentTransactionStatePurchased:
            [[SKPaymentQueue defaultQueue] finishTransaction:purch];
            // Do regular changes to app state for this purchase,
            // register in keychain, etc.
            break ;
    
           //.. other cases
         }
      }
    }
    

    The question of having your app logic / take back the purchase is simple: if you're caching purchases in keychain, delete your keychain. If you're doing it some other how, just change your local app state to pretend like the user never purchased it before. The request to purchase dialog is still exactly the same, the only difference is when you punch YES, it gives you SKPaymentTransactionStateRestored instead of SKPaymentTransactionStatePurchased.

提交回复
热议问题