onDestroy()
The onDestroy() method is used to destroy the instance and release all associated resources.
Declaration
Objective-C
Swift
copy
- (void)onDestroy;Parameters
This method takes no input parameters.
Return value
This method does not return any value.
Usage scenarios
Manual call
In the following cases, call the onDestory() method to release SDK component resources:
- When the buyer leaves the checkout page or switches views, release the component resources created by the createPaymentSession (One-time Payments) or createVaultingSession API.
- When the buyer initiates multiple payments or card binding attempts and the parameters in the
initConfiguration()changes, release the component resources created by the createPaymentSession (One-time Payments) or createVaultingSession API.
Automatic release
In the following cases, you do not need to call the the the onDestory() method, SDK automatically releases resources:
- When the buyer initiates multiple payments or card binding attempts and the parameters in
AMSPaymentElementConfigurationor AMSVaultElementConfiguration have not changed, the SDK will automatically recycle some resources after payment or card binding completion to reset to the state beforecreateComponent().