HomeGuidesAPI ReferenceChangelog
Log InChangelog
Guides

WalletCallback

Most methods return a callback when the SDK finishes, either with error or success
information. Methods for onSuccess and onError must be implemented for WalletCallback. OnSuccess, the WalletCallback will in some cases include a data object, documented under “Models” section. For more information on WalletSuccess and WalletException, see Success and Error types sections.

Android Example

When success returns a model, the model must be provided in the callback, or 'Unit' if no data is expected. See expected return data in 'SDK Methods' and definitions under 'Definitions'.

import com.aerahost.aerawalletssdk.external.model.callback.WalletCallback
import com.aerahost.aerawalletssdk.external.model.callback.success.WalletSuccess
import com.aerahost.aerawalletssdk.external.model.callback.exception.WalletException
import com.aerahost.aerawalletssdk.external.model.SDKInfo

val callback = object : WalletCallback<String> {
  override fun onSuccess(walletSuccess: WalletSuccess<String>) {
    val dynamicSDKId = walletSuccess.data
    if (dynamicSDKId != null) {
      Log.d("getDynamicSDKId: ", dynamicSDKId)
    } else {
			Log.d("getDynamicSDKId: ", "Unexpected dynamicSDKId")
    }
  }
  override fun onError(walletException: WalletException) {
    Log.d("getDynamicSDKId: ", walletException.message)
  }
}

return walletsSDK.getDynamicSDKId(callback)

🆕 iOS Example

import aerawalletssdk

AeraWalletsSDK.shared.getDynamicSDKId(
   keychainGroup: keychainGroup,
   callback: { (walletSuccess: WalletSuccess?, walletException: WalletException?) in
   if let walletSuccess {
      let dynamicSDKId = walletSuccess.data as? String
      print("dynamicSDKId: \(dynamicSDKId)")
   }
   if let walletException {
   		print("error: \(walletException.type)")
   }
	}
)