2016-07-23 157 views
1

我試圖做的自定義重定向讀取分支的參數後IO深層連結科深層鏈接通知不工作

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> 
+0

亞歷克斯從分支這裏:通過推送通知發送分支鏈接是我們實際上看不到太多的功能之一,即使它支持。您可以[提交一張票](https://support.branch.io/support/tickets/new)讓我們的集成工程團隊看看嗎? –

回答

0

獲得「clicked_branch_link:假」是一個關鍵的不匹配造成的。如果你點擊你的Test實例的鏈接,但你的應用正在用你的Live鍵進行初始化,你會得到clicked_branch_link:false。