DeepLinkNow Android SDK

DeepLinkNow Android SDK provides powerful deep linking and attribution capabilities for Android applications. The SDK enables seamless handling of deep links, deferred deep links, and user attribution tracking.

Requirements

  • Android API level 21+ (Android 5.0+)
  • Kotlin 1.5+

Installation

Add this to your project's build.gradle:

dependencies {
    implementation 'com.deeplinknow:deeplinknow-android:0.1.0'
}

Initialization

Initialize the SDK in your Application class:

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        DeepLinkNow.initialize(this, "your-api-key-here")
    }
}

Deep Linking

The SDK provides comprehensive deep linking capabilities.

Creating Deep Links

Create deep links with custom parameters:

val customParams = DLNCustomParameters().apply {
    this["referrer"] = "social_share"
    this["is_promo"] = true
    this["discount"] = 20
}

val deepLink = DeepLinkNow.getInstance().createDeepLink(
    path = "/product/123",
    customParameters = customParams
)

Handling Deep Links

Register and handle deep links with the router:

val router = DLNRouter()

router.register("product/:id") { uri, params ->
    val parsed = DeepLinkNow.getInstance().parseDeepLink(uri)

    // Access route parameters
    val productId = params["id"]

    // Access custom parameters
    val referrer = parsed.parameters.string("referrer")
    val isPromo = parsed.parameters.boolean("is_promo") ?: false
    val discount = parsed.parameters.int("discount")
}

Deferred Deep Linking

Check for deferred deep links during app launch:

DeepLinkNow.getInstance().checkDeferredDeepLink { uri, attribution ->
    uri?.let { deepLink ->
        // Handle the deferred deep link
        handleDeepLink(deepLink)
    }

    attribution?.let { attr ->
        // Access attribution data
        println("Channel: ${attr.channel}")
        println("Campaign: ${attr.campaign}")
        println("Install Time: ${attr.installTimestamp}")
    }
}

Clipboard Deep Links

Check clipboard for deep links:

val clipboardLink = DeepLinkNow.getInstance().checkClipboard()
clipboardLink?.let {
    // Handle clipboard deep link
}

Device Fingerprinting

The SDK automatically collects device information for attribution:

val fingerprint = DLNDeviceFingerprint.generate(context)
println("Device Model: ${fingerprint.deviceModel}")
println("System Version: ${fingerprint.systemVersion}")
println("Screen Resolution: ${fingerprint.screenResolution}")

Custom Parameters

The DLNCustomParameters class provides type-safe access to parameters:

val parameters = DLNCustomParameters()

// Setting parameters
parameters["string_param"] = "value"
parameters["int_param"] = 42
parameters["bool_param"] = true

// Reading parameters
val stringValue = parameters.string("string_param")
val intValue = parameters.int("int_param")
val boolValue = parameters.boolean("bool_param")

Error Handling

The SDK provides specific error types:

try {
    // SDK operation
} catch (e: DLNError) {
    when (e) {
        is DLNError.NotInitialized -> // Handle initialization error
        is DLNError.InvalidUrl -> // Handle invalid URL error
        is DLNError.ServerError -> // Handle server error
        is DLNError.ClipboardAccessDenied -> // Handle clipboard access error
    }
}

Custom URL Schemes

Register your app's custom URL scheme in AndroidManifest.xml:

<activity>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="your-scheme" />
    </intent-filter>
</activity>

Best Practices

Follow these best practices for optimal SDK usage:

Early Initialization

Initialize the SDK as early as possible in your Application class

Error Handling

Always implement proper error handling for SDK operations

Type Safety

Use the provided type-safe methods when accessing parameters

Testing

Test deep links thoroughly in both cold and warm app launch scenarios