Common SDK Operations
SDK Initialization
All mCard SDKs (with the exception of the Auth SDK) are initialized with the following parameters:
- Access token (JWT-standard)
- Debugging flags
- Token refresh callback used to refresh the token on demand
SDK Debugging
Each SDK supports 2 kinds of debugging, and they are not mutually exclusive.
- Firebase - if you have integrated your app with firebase you can set a logging callback on each sdk which will return exceptions and strings for you to log to your firebase instance.
- IDE Log - The SDK will print all logging text and exceptions to the IDE Log, using the SDK package name as the logging tag. This is controlled by the debug flag during sdk initialization.
Async Paradigms
The majority of SDK data-only operations use async return value patterns.
iOS
- Swift closures of the form Result<T, Error>
- Result is a stateful wrapper provided by Swift that contains a boolean result with associated data values for each case
Android
- RxJava Single<SdkResult<T>>
- SdkResult provides roughly the same functionality as a Swift Result
Importing the SDKs
iOS
iOS SDKs are provided as binary frameworks via SPM. Each framework is hosted in a separate repo to which you will be given access, allowing you to import the framework.
Android
Android SDKs are provided as maven artifacts in a Bill of Materials. The BoM is provided as a package of all five SDKs with a single version, so that individual SDK versions do not need to be specified. If you don’t wish to use certain SDKs, simply don’t declare them.
Example build.gradle declaration (groovy):
implementation(platform("com.mcards.sdk:bom:1.0.0"))
implementation "com.mcards.sdk:auth"
implementation "com.mcards.sdk:cards"
implementation "com.mcards.sdk:history" // e.g. remove this line to not import the history SDK
implementation "com.mcards.sdk:accounts"
implementation "com.mcards.sdk:fm"Then the BoM dependency must be declared as a repository in settings.gradle (groovy):
maven {
url = uri("https://maven.pkg.github.com/mymcard/sdk-bom-android")
credentials {
username = GITHUB_USERNAME
password = GITHUB_TOKEN
}
}SDK Instances
All SDKs are provided as singleton instances and cannot be instantiated directly by clients. These patterns are followed for all SDKs on each platform. These instances are accessible as described below.
iOS
iOS instances are provided via shared properties.
let cardsSdk = CardsSdkProvider.shared
let historySdk = HistorySdkProvider.shared
// pattern continues for all 5 SDKsAndroid
Android instances are provided via static factory methods.
val cardsSdk = CardsSdkProvider.getInstance()
val historySdk = HistorySdkProvider.getInstance()
// pattern continues for all 5 SDKsDemo Projects
Each SDK has a basic demo project on both iOS and android. The demo projects are runnable, standalone apps with their own documentation which illustrate how to import and initialize that SDK. The demo then illustrates two or three SDK operations, using placeholder UI, showing how to fully integrate with the data provided by that SDK.
Updated 5 months ago