【问题标题】:Branch deep link notification is not working分支深层链接通知不起作用
【发布时间】:2016-07-23 13:33:11
【问题描述】:

我试图在读取分支 io deeplink 的参数后进行自定义重定向

 Intent resultIntent = new Intent(context, BlankBranchShareActivity.class);
    resultIntent.putExtra("branch", "https://bnc.lt/EcMh/POIo83vYev");

    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    String title = "DeepLink";
    String message = "messageDeepLink";
    String summaryText = "summaryText";
    NotificationUtility.createNotification(context, title,
            message, summaryText,
            mNotificationId++, resultPendingIntent,
            CancelNotificationResponse.getPendingIntent(context, messageType));

通知即将到来并显示,当我单击通知时,它会重定向到 BlankBranchShareActivity.class

public class BlankBranchShareActivity extends AppCompatActivity {

private static final String TAG = BlankBranchShareActivity.class.getName();
private Branch branch;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    branch = Branch.getInstance();
}


@Override
public void onStart() {
    super.onStart();
    branch.initSession(branchReferralInitListener, this.getIntent().getData(), this);
}

Branch.BranchReferralInitListener branchReferralInitListener = new Branch.BranchReferralInitListener() {
    @Override
    public void onInitFinished(JSONObject referringParams, BranchError error) {

        String label = "";
        if (referringParams != null)
            label = "ReferringParams" + referringParams.toString();

        if (error == null) {
            JSONObject json = referringParams;
            onCodeResume(json);
            return;
        }

        if (AppConstants.DEBUG) {
            Log.i(TAG, "onStart()" + label + ",Error:" + error);
        }
        openMainActivity();
    }
};

protected void onCodeResume(JSONObject json) {
    super.onResume();

    try {
        Log.i(TAG, "onResume: " + "Called" + json.toString());

        /*If nothing is their to-launch immediately Launch Main activity */
        if (json == null || json.toString().equals("{}") || (!json.has(JsonKeys.BRANCH_IO_JOB_SHARE_KEY) && !json.has(JsonKeys.BRANCH_IO_SHARE_TYPE_SHARE_KEY))) {
            return;
        }

        //Do Operation 

    } catch (JSONException e) {
        Crashlytics.logException(e);
        Log.e(TAG, "onResume: " + e.toString());
    }

}

private void openMainActivity() {
    Intent in = new Intent(this, MainActivityList.class);
    startActivity(in);
}

@Override
public void onNewIntent(Intent intent) {
    this.setIntent(intent);
}

@Override
protected void onStop() {
    super.onStop();
    if (branch != null) {
        branch.closeSession();
    }
}

}

每当我点击链接时,它都会为重定向提供正确的参数,但是 当我发送带有通知的相同链接时,我收到了

{"+is_first_session":false,"+clicked_branch_link":false}

我可能做错了什么

    <activity
        android:name=".BlankBranchShareActivity"
        android:launchMode="singleTask"
        android:noHistory="true"
        android:theme="@style/RegisterActivityTheme">

        <!-- App Link your activity to Branch links-->
        <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" />

            <!--Test key-->
            <data
                android:host="bnc.lt"
                android:pathPrefix="/cdMh"
                android:scheme="https" />

            <!--Production key-->
            <data
                android:host="bnc.lt"
                android:pathPrefix="/EcMh"
                android:scheme="https" />

            <data
                android:host="bnc.lt"
                android:pathPrefix="/EcMh"
                android:scheme="workindia" />
        </intent-filter>
        <meta-data
            android:name="io.branch.sdk.auto_link_keys"
            android:value="@string/branch_meta_all_keys_for_marking_on_manifest" />

        <!-- Deep link path for auto deep linking -->
        <meta-data android:name="io.branch.sdk.auto_link_path" android:value="workindia/*" />
    </activity>

【问题讨论】:

  • Alex from Branch here:通过推送通知发送分支链接是我们实际上并不经常看到的功能之一,即使它受支持。您能submit a ticket 让我们的集成工程团队看看吗?

标签: android deep-linking branch.io


【解决方案1】:

获取“clicked_branch_link:false”是键不匹配的结果。如果您正在单击测试实例中的链接,但您的应用正在使用 Live 密钥进行初始化,您将获得 clicked_branch_link:false。

【讨论】:

    猜你喜欢
    • 2018-04-11
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 2016-06-26
    • 1970-01-01
    • 2022-11-18
    相关资源
    最近更新 更多