androidkotlindeep-linkingandroid-deep-link

Android deeplinks aren't being registered, browser loading URL


I'm trying to have my android app open any urls that are at ex. mysite.com/users/12345 with an activity called LinksActivity, then (for now) just log everything in the intent. Instead when I send the test URL via android studio or open the URL in the browser it just loads the 404 for that page.

I have added the .well-known/assetlinks.json file to my site, and I'm not certain I got the SHA keys right, but I don't think that's the issue since when I change the URL to some URL nobody owns, it doesn't work that way either. And it doesn't work on the debug or the release versions of the app.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android">
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.ValuesRank">
    <activity
        android:name=".ui.links.LinksActivity"
        android:exported="true">
        <tools:validation testUrl="https://mywebsite.com/users" />
        <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:scheme="https"
                android:host="raderie.me"
                android:pathPrefix="/users" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ui.share.ShareActivity"
        android:exported="false">
        <meta-data
            android:name="android.app.lib_name"
            android:value="" />
    </activity>
    <activity android:name=".ui.results.ResultsActivity" />
    <activity
        android:name=".ui.main.MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

LinksActivity.kt

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.airbnb.deeplinkdispatch.DeepLink
import com.orhanobut.logger.Logger
import org.clarkecollective.raderie.R

class LinksActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_links)
  }

  override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    handleIntent(intent)
  }

  private fun handleIntent(intent: Intent) {
    val appLinkAction = intent.action
    val appLinkData: Uri? = intent.data

    Logger.d("App Link Action: %s  \n \n App Link Data: %s", appLinkAction, appLinkData)
  }
}

mysite.com/.well-known/assetlinks.json

[{
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target" : { "namespace": "android_app", "package_name": "org.site.mypackagename",
                 "sha256_cert_fingerprints": ["The SHA for the Release Package is here"] }
  }, {
         "relation": ["delegate_permission/common.handle_all_urls"],
         "target" : { "namespace": "android_app", "package_name": "org.site.mypackagename",
                      "sha256_cert_fingerprints": ["The SHA for the Debug Package is here"] }
       }]

Solution

  • I needed to make sure my debug key was added to my assetlinks.json, and enable autoVerify=true.