0

I use deeplinking with branch.io in my app. App generates url and open it with custom scheme. It goes ok on native android brawser, firefox and opera-mini, but it fails on chrome-android with ERR_UNKNOWN_URL_SCHEME

code below: manifest

        <activity
        android:launchMode="singleTask"
        android:name=".ui.activity.ShareActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <data android:scheme="myapp" android:host="open" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Code that generates url (doc: https://dev.branch.io/getting-started/creating-links-in-apps/guide/android/):

    public static void generateShortUrl(@NonNull Context aContext,
                                    @Nullable String aMediaId,
                                    @Nullable String aCollectionId,
                                    @NonNull CanonicalIdentifier aCanonicalIdentifier,
                                    @NonNull String aDesktopUrl,
                                    @NonNull Branch.BranchLinkCreateListener aListener){

    BranchUniversalObject branchUniversalObject = new BranchUniversalObject()
            .setCanonicalIdentifier(String.valueOf(aCanonicalIdentifier.ordinal() + 1))
            .setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
            .addContentMetadata(SHARE_MEDIA_ID, aMediaId);


    if(BuildConfig.DEBUG){
        Log.e("BranchConfigTest","share date:"+branchUniversalObject.convertToJson().toString());
    }

    if(!TextUtils.isEmpty(aCollectionId))
        branchUniversalObject.addContentMetadata(SHARE_COLLECTION_ID,aCollectionId);

    if(!TextUtils.isEmpty(aMediaId))
        branchUniversalObject.addContentMetadata(SHARE_MEDIA_ID,aMediaId);

    LinkProperties linkProperties = new LinkProperties()
            .setFeature("sharing")
            .addControlParameter("$desktop_url", aDesktopUrl);

    branchUniversalObject.generateShortUrl(aContext,linkProperties,aListener);
}
George
  • 26
  • 7
  • Alex from Branch here...couple quick questions: 1. Do you have [App Links](https://dev.branch.io/getting-started/universal-app-links/guide/android/) configured in your app? 2. If you paste a link directly into the Chrome address bar (**not** opening it from an external app) do you still get the `ERR_UNKNOWN_URL_SCHEME` error? – Alex Bauer Mar 04 '16 at 17:55
  • Hi Alex, i just configured App Links, so now I have two causes: 1. I paste generated link directly in chrome address bar - and got scheme error. 2 I paste somewhere else (bug tracker) and then open it with chrome from my device - got redirect on playmarket page – George Mar 06 '16 at 11:28
  • Hmm...are these our standard `bnc.lt` links, or are you using a custom domain? Can you confirm that the link you are opening is httpS, and not just http? – Alex Bauer Mar 06 '16 at 18:10
  • I use bnc.lt domain. Here is the sample of link that i generated on app side https://bnc.lt/P2Gk/TgPzPohdvr Test device is sm-t311 Android 4.4.1 – George Mar 06 '16 at 19:08

1 Answers1

3

Alex with Branch here: unfortunately this is a known issue with Chrome. Basically, in some release of Chrome 40, it was decided that typed and pasted URLs should prevent automated redirects like the one Branch uses to open the Play Store or launch your app. We worked on a solution with the Chromium team last summer, but it came to our attention a few weeks ago that the issue was only fixed for typed-in URLs, and not for URLs that users paste directly into Chrome's address bar.

The good news is that in the wild, this is extremely, extremely rare. It is usually only triggered by developers in the testing stages of a Branch integration — the vast majority of your users will only click links (rather than pasting URLs) and therefore will never encounter this. Obviously this is still a less than ideal solution, so if you'd like, feel free to file a radar with Chromium. We can get behind it and ask our team to provide examples as well.

Alex Bauer
  • 13,147
  • 1
  • 27
  • 44