5

I am trying to set up dynamic links so that a link will deep link the user to the app if they already have it installed and the play store if they don't. I expect the link to survive the play store installation process and be sent to the launcher activity with the link. The dynamic link works when the app is already installed. However, when the app is not installed, it sends the user to the play store but the dynamic link does not survive the installation process. I have read that the "Open" button is supposed to change to "Continue" when the user is sent to the play store with a dynamic link, but when I do it, it still says "Open". Here is my activity in AndroidManifest.xml.

        <activity android:name=".share.DeepLinkActivity"
        android:theme="@style/AppTheme"
        >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <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="housebook.com"
                android:scheme="https"/>
            <data
                android:host="housebook.com"
                android:scheme="http"/>
        </intent-filter>
        <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="housebook.page.link"
                android:scheme="https"/>
            <data
                android:host="housebook.page.link"
                android:scheme="http"/>
        </intent-filter>

    </activity>

Here is my DeepLinkActivity

package chenige.chkchk.wairz.share

import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import chenige.chkchk.wairz.BaseActivity
import chenige.chkchk.wairz.landing.LandingActivity
import chenige.chkchk.wairz.model.ShareDeepLink
import chenige.chkchk.wairz.sign_in.SignInActivity
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.dynamiclinks.FirebaseDynamicLinks

class DeepLinkActivity : BaseActivity() {

    companion object {
        const val SHARE_DEEP_LINK = "SHARE_DEEP_LINK"
    }
    var mAuth = FirebaseAuth.getInstance()

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


        if(intent.data != null){
            FirebaseDynamicLinks.getInstance().getDynamicLink(intent).addOnSuccessListener { pendingDynamicLinkData ->

                if(pendingDynamicLinkData != null) {

                    val houseId = pendingDynamicLinkData.link!!.getQueryParameter("House")
                    val shareId = pendingDynamicLinkData.link!!.getQueryParameter("Share")
                    goIntoAppWithShare(houseId!!, shareId!!)
                }else{
                    goIntoApp()
                }

            }.addOnFailureListener {failure ->
                showErrorRetrievingLink(failure.message!!)
            }

        }else{
            goIntoApp()
        }

    }


    fun goIntoAppWithShare(houseId: String, shareId: String){
        val intent : Intent
        if (mAuth.currentUser != null) {
            intent = Intent(this, LandingActivity::class.java)
        }else{
            intent = Intent(this, SignInActivity::class.java)
        }

        intent.putExtra(SHARE_DEEP_LINK, ShareDeepLink(houseId, shareId))
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        startActivity(intent)
        finish()
    }

    fun goIntoApp(){

        val intent : Intent
        if (mAuth.currentUser != null) {
            intent = Intent(this, LandingActivity::class.java)
        }else{
            intent = Intent(this, SignInActivity::class.java)
        }
        startActivity(intent)
        finish()
    }


    fun showErrorRetrievingLink(error: String) {

        val dialog = AlertDialog.Builder(this).setTitle("Error Retrieving House").setMessage("HouseBook has had an issue retrieving the shared house.")
                .setPositiveButton("Ok.") { dialog, i ->
                    goIntoApp()
                }

        dialog.show()
    }
}

I have added a dynamic link in the Firebase console as https://housebook.page.link enter image description here

I have added a 256 SHA certificate fingerprint.

A link that I expect to work but does not is https://housebook.page.link/nvfVf7N91D7dgBLV7

Debugging with https://housebook.page.link/nvfVf7N91D7dgBLV7?d=1 shows just one warning about phishing. I have tried adding a configuration to make this warning go away, but it does not help. Does anybody know why the link is not surviving the installation process? I have been struggling with this for like 2 weeks now.

Cameron Henige
  • 368
  • 2
  • 17
  • 1
    Clicking the "expected to work" link produces ERR_CONNECTION_REFUSED. Maybe that's related? – Kato Jan 31 '20 at 16:37
  • Yes, that happens when you click it on a laptop. However, if you click on it on a phone, it goes to my app in the play store. – Cameron Henige Jan 31 '20 at 16:39
  • @CameronHenige have you found an answer? – b2mob Jun 17 '20 at 09:39
  • Does anyone found any solution over here? @CameronHenige – Datta Kunde Sep 11 '20 at 05:54
  • @CameronHenige Were you able to resolve the issue? Please let me know how. I have the same exact issue. Thank you. Any help is appreciated. – Mike Oct 12 '20 at 17:34
  • Does anyone got an answer for this? Because this is very prevalent and kind of reduces the overall impact of firebase dynamic link. A very broken experience. – SDK4551 May 25 '21 at 11:57
  • I believe the issue is being tracked here: https://github.com/firebase/firebase-android-sdk/issues/920 Let's see if we can add enough thumbs for them to notice :) – Martin Rajniak Nov 11 '21 at 19:44

0 Answers0