user10058688
user10058688

Reputation:

Branch SDK error when generating deep link

When I am generating deep link using branch I am getting error. BranchSDK: Branch API Error: Conflicting resource error code from API

I have followed the instruction provided in their doc but still I am getting error.

Here is my code

manifest

    <meta-data android:name="io.branch.sdk.BranchKey" android:value="branch_key" />
    <meta-data android:name="io.branch.sdk.TestMode" android:value="false" /> 

Application class

Branch.getAutoInstance(this);

This is how I am generating deep link

val buo = BranchUniversalObject()
            .setCanonicalIdentifier(messageId.toString())
            .setTitle("ShutApp")
            .setContentDescription(invite_message)
            .setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
            .setLocalIndexMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
            .setContentMetadata(ContentMetadata().addCustomMetadata("message", messageId.toString()))

    val lp = LinkProperties()
            .setFeature("sharing")
            .setCampaign("content_sharing")
            .setStage("new user")

    buo.generateShortUrl(this, lp, Branch.BranchLinkCreateListener { url, error ->
        if (error == null) {
            Log.i("BRANCH SDK", "got my Branch link to share: $url")
            shareDeepLink(url)
        } else {
            Log.i("BRANCH SDK error", error.message)
        }
    })

Upvotes: 2

Views: 1500

Answers (3)

Pratik Gondil
Pratik Gondil

Reputation: 699

Branch.io returns Branch API Error: Conflicting resource error code from API

After lot of research i found the solution just to enable test mode to true like below.

 <meta-data
        android:name="io.branch.sdk.TestMode"
        android:value="true" />

Upvotes: 1

Francois
Francois

Reputation: 10631

We had the issue on:
io.branch.sdk.android:library:3.2.0
io.branch.sdk.android:library:4.0.0

I have noticed that on our android app when your android_app_link_url has any spaces you will receive the regex error:

I/BranchSDK: returned {"error":{"instrumentation":[],"metadata":[],"android_app_link_url":"doesn't pass regex"}}

I/BranchSDK: Branch API Error: Conflicting resource error code from API

Also as a result of that, as mentioned above the
Branch.getInstance().initSession((referringParams, error)
callback is never called.

Solution1

Make sure you encode your android_app_link_url spaces with %20

Solution2

Wrap the branch initSession() in a timeout. Will timeout afte 3s and continue app startup.

        // branch timeout
        Runnable startTheAppTask = () -> {
            Timber.e("Branch.getInstance().initSession() has not responded. Please check for related Branch errors!");

            // continue with loading your app here
        };
        ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
        ScheduledFuture<?> branchTimeoutSchedule = executor.schedule(startTheAppTask, 3, TimeUnit.SECONDS);


        // branch init
        Branch.getInstance().initSession((referringParams, error) -> {
            // did get a response, cancel timeout
            branchTimeoutSchedule.cancel(true);

            // normal operation handling the callback
       }, getActivity().getIntent().getData(), getActivity());

Upvotes: 0

Jackie Choi
Jackie Choi

Reputation: 432

Can you try installing and running the Branch Android test app to see if the issue is reproduced? https://docs.branch.io/apps/android/#sample-testing-apps

Upvotes: 0

Related Questions