AMSVaultElement
AMSVaultElement is the core class of Vaulting Element and is the main class used to integrate the Antom Vaulting Element independent card binding component in iOS applications. Merchants can complete SDK initialization configuration, create card binding components, submit card binding, reset, and destroy operations through this class.
Declaration
@interface AMSVaultElement : AMSProductBaseAccess singleton
@property (class, nonatomic, readonly, strong) AMSVaultElement *shared;
@endName | Type | Description |
shared | AMSVaultElement |
|
Instance methods
AMSVaultElement singleton instance provides the following methods:
Method name | Description |
| Used to initialize SDK configuration. | |
Used to preload WebApp pages and KYC page resources. | |
Used to create and display the card binding component UI. | |
Used to reset the card binding process and clear the current state. | |
Used to destroy the instance and release all associated resources. |
Property
@property (nonatomic, weak, nullable) id<AMSVaultProtocol> paymentDelegate;Name | Type | Description |
paymentDelegate | AMSPaymentProtocol? | Payment protocol delegate, refer to |
Usage instructions
- Access the instance through
AMSVaultElement.shared. - Before calling the
createComponent(_:)method,initConfiguration(_:)must be called first. - All UI-related methods (
createComponent(),reset(),onDestroy()) need to be called from the main thread.
Usage example
#import <AMSFoundation/AMSFoundation-Swift.h>
#import <AMSElement/AMSElement-Swift.h>
@interface VaultViewController () <AMSPaymentProtocol>
@end
@implementation VaultViewController
- (void)viewDidLoad {
[super viewDidLoad];
// 1. Create configuration
AMSVaultElementConfiguration *config = [AMSVaultElementConfiguration new];
config.locale = @"en_US";
config.options = @{
@"sandbox": @YES,
@"showLoading": @YES
};
// 2. Initialize SDK (with callback)
[[AMSVaultElement shared] initConfiguration:config completion:^(AMSStatusResult * _Nonnull result) {
if (result.status == AMSStatusResultTypeSUCCESS) {
NSLog(@"Initialization successful");
} else {
NSLog(@"Initialization failed: %@", result.error.message);
}
}];
// 3. Set delegate
[AMSVaultElement shared].paymentDelegate = self;
// 4. (Optional) Preload resources
[[AMSVaultElement shared] preload];
}
- (void)startVaultingWithSessionData:(NSString *)sessionData {
// 5. Create card binding component (with callback)
[[AMSVaultElement shared] createComponent:sessionData completion:^(AMSStatusResult * _Nonnull result) {
if (result.status == AMSStatusResultTypeSUCCESS) {
NSLog(@"Component created successfully");
}
}];
}
- (void)submitVaulting {
// 6. Submit card binding
[[AMSVaultElement shared] submit:nil];
}
#pragma mark - AMSPaymentProtocol
- (void)onSubmitPayCallback:(AMSStatusResult * _Nullable)eventResult {
switch (eventResult.status) {
case AMSStatusResultTypeSUCCESS:
NSLog(@"Binding successful");
break;
case AMSStatusResultTypeFAIL:
NSLog(@"Binding failed: %@", eventResult.error.message);
break;
case AMSStatusResultTypePROCESSING:
NSLog(@"Binding processing");
break;
case AMSStatusResultTypeCANCELLED:
NSLog(@"Binding cancelled");
break;
default:
break;
}
}
- (void)onEventCallback:(NSString * _Nonnull)eventCode eventResult:(AMSEventResult * _Nonnull)eventResult {
NSLog(@"Event callback: %@", eventCode);
}
- (void)dealloc {
[[AMSVaultElement shared] onDestroy];
}
@end