Dragonpass Hybrid SDK
- iOS SDK
- Android SDK
iOS SDK
Compatibility
Your project must target iOS 13 or later.
Swift projects should use Swift 5.6 or later, and CocoaPods 1.8.1 or later is required.
Installation
For manual installation with Swift Package Manager:
- In Xcode, select
File → Add Package Dependencies… - Enter the repository URL for the Dragonpass Hybrid SDK:
Terminal
https://github.com/bigBandFE/dpsdk-ios-spm - Set the
Dependency RuletoBranch→main. - Click Add Package, select product
DPSDKKit.
Use this AI-assisted workflow to inspect the host app, add DPSDKKit, initialize DPSDK, set the auth code, open DPApps, and verify the build. Install the skill with:
hermes skills install --category devops --yes \
"https://raw.githubusercontent.com/bigBandFE/dpsdk-ai-skill/main/SKILL.md"
Launch DPApp
-
Import the SDK
Swiftimport DPSDKKit -
Initialize the SDK Replace
client_idwith your actual client ID:SwiftDPSDK.start(clientId: "client_id") -
Set Auth Code After obtaining the auth code from Connect, pass it to the SDK:
SwiftDPSDK.shared.setAuthCode(token: "xxxxx")See Connect for the full authentication flow.
-
Open DPApp
UIKit
SwiftDPSDK.open(
appId: "app_id",
params: ["path": "introduction"],
from: viewController
)SwiftUI
Swift// If using SwiftUI, you must obtain the current UIViewController.
struct ContentView: View {
var body: some View {
VStack {
Button("Open DPSDK (Create)") {
openDPSDKWithCreate()
}
}
}
private func openDPSDKWithCreate() {
guard let viewController = getCurrentViewController() else {
print("Unable to get current ViewController")
return
}
DPSDK.createViewController(
appId: "your_app_id",
path: "home",
params: ["demo": "custom_navigation"]
) { createdViewController, error in
guard let DPAppVC = createdViewController else {
print("Creation failed: \(error?.localizedDescription ?? "Unknown error")")
return
}
DispatchQueue.main.async {
if let navController = viewController.navigationController {
navController.pushViewController(DPAppVC, animated: true)
} else {
let nav = UINavigationController(rootViewController: DPAppVC)
nav.modalPresentationStyle = .fullScreen
viewController.present(nav, animated: true)
}
}
}
}
private func getCurrentViewController() -> UIViewController? {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first else {
return nil
}
return window.rootViewController?.topMostViewController()
}
}
Language Configuration
DPSDKConfigManager.shared.setLanguage("en-US")
DPApp URL Listener
// To listen for URL change events:
DPApp.delegate = self
extension ViewController: DPAppCustomDelegate {
func didDPAppChangeUrlEvent(DPApp: DPApp, url: URL) {
if url.path.components(separatedBy: "/").contains("details") {
print("Search url: \(url)")
}
}
}
Custom Event Handling
func dpAppHandleCustomEvent(_ event: SparkAppCustomEvent, completion: @escaping (SparkAppResponse) -> Void) {
switch event.type {
case "getUserInfo":
if !isLogin() || getUserInfo() == nil {
completion(SparkAppResponse(statusCode: 0, errCode: "USER_NOT_LOGIN", msg: "User is not logged in"))
} else {
let userInfo: [String: Any] = [
"id": getUserInfo()?["id"] ?? "",
"firstName": getUserInfo()?["firstName"] ?? "",
"lastName": getUserInfo()?["lastName"] ?? ""
]
completion(SparkAppResponse(statusCode: 1, data: userInfo))
}
default:
completion(SparkAppResponse(statusCode: 0, errCode: "APP_10001", msg: "Unknown event type: \(event.type)"))
}
}
Append Custom Params to DPApp URL
let config = [
"path": "introduction",
"orderId": "123123"
]
DPSDK.open(
appId: "app_id",
params: config,
from: viewController
)
DPApp Lifecycle Events
DPApp.delegate = self
extension ViewController: DPAppCustomDelegate {
func dpAppDidLaunch(_ event: DPAppLifecycleEvent) {}
func dpAppDidShow(_ event: DPAppLifecycleEvent) {}
func dpAppDidHide(_ event: DPAppLifecycleEvent) {}
func dpAppDidResume(_ event: DPAppLifecycleEvent) {}
func dpAppDidClose(_ event: DPAppLifecycleEvent) {}
func dpAppDidError(_ event: DPAppLifecycleEvent, error: String) {}
}
Android SDK
Compatibility
Your project must target Android 5.0 (API level 21) or higher.
Installation
For manual installation with Gradle / JitPack:
Add JitPack to dependency resolution:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
Add the dependency to your app module:
dependencies {
implementation("com.github.bigBandFE:dpsdk-android:2.0.0")
}
Add the following to gradle.properties:
android.enableJetifier=true
Use this AI-assisted workflow to inspect the host app, add the SDK dependency, initialize DPSDK, set the auth code, open DPApps, and verify the build. Install the skill from the official GitHub SKILL.md URL:
hermes skills install --category devops --yes \
"https://raw.githubusercontent.com/bigBandFE/dpsdk-ai-skill/main/SKILL.md"
Launch DPApp
-
Initialize in Application Class
Kotlinclass MyApplication : Application() {
override fun onCreate() {
super.onCreate()
DPSDK.init(this).setDPSdkConfig(
DPSDKConfig.Builder()
.setClientId("<client_id>")
.build()
)
}
} -
Register in AndroidManifest.xml
XML<application
android:name=".MyApplication"
...> -
Set Auth Code After obtaining the auth code from Connect, pass it to the SDK:
KotlinDPSDK.setAuthCode("xxxxx")See Connect for the full authentication flow.
-
Open DPApp
Kotlinval appId = "<app_id>"
DPSDK.getDPApp(appId).open(this)
Language Configuration
DPSDK.getDPSdkConfig().setLanguage("en-US")
DPApp URL Listener
val appId = "<app_id>"
val dpApp = DPSDK.getDPApp(appId)
dpApp.setUrlChangeListener { activity: FragmentActivity, url: URL? ->
Log.e("URL Path", url?.path ?: "")
}.open(this)
Custom Event Handling
val appId = "<app_id>"
val dpApp = DPSDK.getDPApp(appId)
dpApp?.setCustomEventListener { activity, data, jsCustomEventMsgEntity, callBackFunction ->
val eventType = jsCustomEventMsgEntity.eventType
when (eventType) {
"getUserInfo" -> {
getUserInfo(activity, data, jsCustomEventMsgEntity, callBackFunction)
}
}
}
private fun getUserInfo(
activity: FragmentActivity,
data: String?,
jsCustomEventMsgEntity: JsCustomEventMsgEntity,
function: CallBackFunction?
): Boolean {
if (!LoginUtils.isLogin() || LoginUtils.getUserInfo() == null) {
function?.onFailure("errorCode", "errorMsg")
} else {
val hashMapOf = hashMapOf<String, Any?>()
hashMapOf["id"] = "xxxxx"
hashMapOf["firstName"] = "xxxxx"
hashMapOf["lastName"] = "xxxxx"
function?.onSuccess(hashMapOf)
}
return true
}
Append Custom Params to DPApp URL
val appId = "<app_id>"
val dpApp = DPSDK.getDPApp(appId)
dpApp?.setDPAppConfig(
DPAppConfig.Builder()
.setExtraUrlParams(hashMapOf<String, String>().apply {
put("order_no", "xxx")
})
.build()
)?.open(mContext, "order-detail")
DPApp Lifecycle Events
val appId: String = "<app_id>"
val dpApp: DPApp = DPSDK.getDPApp(appId)
dpApp.setDPAppLifecycleListener(object : DPAppLifecycleListener {
override fun onLaunch(activity: FragmentActivity, dpApp: DPApp?, pageName: String) {}
override fun onResume(activity: FragmentActivity, dpApp: DPApp?, pageName: String) {}
override fun onPause(activity: FragmentActivity, dpApp: DPApp?, pageName: String) {}
override fun onClose(activity: FragmentActivity, dpApp: DPApp?, pageName: String) {}
override fun onError(activity: FragmentActivity, dpApp: DPApp?, pageName: String) {}
})