Skip to content

A self-hosted dynamic link service for app download tracking, deep linking, and engagement analytics for android - an alternative to Firebase Dynamic Links

License

Notifications You must be signed in to change notification settings

apps-on-air/AppsOnAir-android-AppLink

Repository files navigation

pub package

AppsOnAir-android-AppLink

AppsOnAir-android-AppLink enables you to handle deep links, and in-app routing seamlessly in your Android app. With a simple integration, you can configure, manage, and act on links from the web dashboard in real time and for more detail refer documentation.

🚀 Features

  • ✅ Deep link support (URI scheme, AppLinks)
  • ✅ Fallback behavior (e.g., open Play Store)
  • ✅ Custom domain support
  • ✅ Referral tracking
  • ✅ Seamless migration from Firebase Dynamic Links to AppLink

Note: For comprehensive instructions on migrating Firebase Dynamic Links to AppLink, refer to the documentation.

Minimum Requirements

  • Android Gradle Plugin (AGP): Version 8.0.2 or higher
  • Kotlin: Version 1.7.10 or higher
  • Gradle: Version 8.0 or higher

How to use?

Add AppsOnAir AppLink dependency to your gradle.

dependencies {
   implementation 'com.github.apps-on-air:AppsOnAir-android-AppLink:TAG'
}

Add below code to setting.gradle.

dependencyResolutionManagement {
   repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
   repositories {
       google()
       mavenCentral()
       maven {
           url = uri("https://jitpack.io")
       }
   }
}

Add meta-data to the app's AndroidManifest.xml file under the application tag.

Make sure meta-data name is “AppsonairAppId”.

Provide your application id in meta-data value.

</application>
    ...
    <meta-data
        android:name="AppsonairAppId"
        android:value="********-****-****-****-************" />
</application>

Add below code to the app's AndroidManifest.xml file under the activity tag of your main activity.

 <intent-filter android:autoVerify="true">
   <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.DEFAULT" />
   <category android:name="android.intent.category.BROWSABLE" />
    <data
     android:host="your domain"
     android:scheme="https" />
 </intent-filter>

Add below code if you are using custom uri scheme.

 <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:host="open"
     android:scheme="your scheme" />
</intent-filter>

Example :

Initialize the AppLink

    private lateinit var appLinkService: AppLinkService

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // Initialize deeplink service and set listener for deep link and referral link events
        appLinkService = AppLinkService.getInstance(this)
        // Initialize the AppLink to track the deeplink
        appLinkService.initialize(this, intent, object : AppLinkListener {
            override fun onDeepLinkProcessed(uri: Uri, result: JSONObject) {
                // Perform your action on deep link
            }

            override fun onDeepLinkError(uri: Uri?, error: String) {
                // Handle error when deep link processing fails
            }
            // Optional method
            override fun onReferralLinkDetected(result: JSONObject) {
                 // Perform your action on referral data
            }
        })
    }
    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
        appLinkService.handleDeepLink(
            intent,
            "com.example.appsonair_android_applink"
        ) 
    }

For creating the AppLink

    val socialMeta = mapOf(
        "title" to "link title",
        "description" to "link description",
        "imageUrl" to "https://image.png"
    )

   
CoroutineScope(Dispatchers.Main).launch {
    val result = appLinkService.createAppLink(
        name = "AppsOnAir",
        url = "https://appsonair.com",
        urlPrefix = "YOUR_DOMAIN_NAME", //shouldn't contain http or https
        shortId = "LINK_ID", // If not set, it will be auto-generated
        socialMeta = socialMeta,
        androidFallbackUrl = "https://play.google.com",
        isOpenInAndroidApp = true,
        isOpenInBrowserAndroid = false
    )
  }

To retrieving the referral link

CoroutineScope(Dispatchers.Main).launch {
    val referral = appLinkService.getReferralInfo()
}

Note:

The install referral data is available for up to 90 days. If you need access to it beyond that, you must store it locally within your app.

To test referral functionality, your app must be live on the Play Store. If it's not, you can use the application ID of any live app instead for testing purposes.

For testing:

  • Click the referral link, which should redirect you to the Play Store.

  • Do not press the "Install" button. Instead, open the app directly from your IDE (e.g., Android Studio) on the device.

About

A self-hosted dynamic link service for app download tracking, deep linking, and engagement analytics for android - an alternative to Firebase Dynamic Links

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages