restoreTransactions method

Future<void> restoreTransactions({
  1. String? applicationUserName,
})

Restore previously purchased transactions.

Use this to load previously purchased content on a new device.

This call triggers purchase updates on the set SKTransactionObserverWrapper for previously made transactions. This will invoke SKTransactionObserverWrapper.restoreCompletedTransactions, SKTransactionObserverWrapper.paymentQueueRestoreCompletedTransactionsFinished, and SKTransactionObserverWrapper.updatedTransaction. These restored transactions need to be marked complete with finishTransaction once the content is delivered, like any other transaction.

The applicationUserName should match the original SKPaymentWrapper.applicationUsername used in addPayment. If no applicationUserName was used, applicationUserName should be null.

This method either triggers -[SKPayment restoreCompletedTransactions] or -[SKPayment restoreCompletedTransactionsWithApplicationUsername:] depending on whether the applicationUserName is set.

Implementation

Future<void> restoreTransactions({String? applicationUserName}) async {
  await channel.invokeMethod<void>(
      '-[InAppPurchasePlugin restoreTransactions:result:]',
      applicationUserName);
}