动态链接提取

时间:2017-11-06 10:47:49

标签: android firebase-dynamic-links

点击启动我的Android应用程序时,我有以下链接。

https://example.app.goo.gl/?link=https://whatever.com/customers?id=MTgy&token=MTI2MzI1M&apn=com/foo.bar&isi=1045116743&ibi=com.foo.bar&efr=1

在活动中,我可以https://whatever.com/customers?id=MTgy(使用FirebaseDynamicLinks)。但是如何获得整个原始链接?

1 个答案:

答案 0 :(得分:2)

// [START get_deep_link] in OnCreate() method
    FirebaseDynamicLinks.getInstance()
            .getDynamicLink(getIntent())
            .addOnSuccessListener(this,this) //implement OnSuccessListener<PendingDynamicLinkData> for this
            .addOnFailureListener(this,this); // implement OnFailureListener for this




   @Override
   public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
    // Get deep link from result (may be null if no link is found)
    Uri deepLink = null;
    if (pendingDynamicLinkData != null) {
        deepLink = pendingDynamicLinkData.getLink();
    }
    // Handle the deep link. For example, open the linked
    // content, or apply promotional credit to the user's
    // account.
    // ...

    // [START_EXCLUDE]
    // Display deep link in the UI
    if (deepLink != null) {
        //now you have your dynamicLink here in Uri object
    } else {
        Log.e(TAG, "getDynamicLink: no link found");
    }
    // [END_EXCLUDE]
   }

  @Override
  public void onFailure(@NonNull Exception e) {
    Log.e(TAG, "getDynamicLink:onFailure", e);
  }

你可以从链接获得的是现在只执行动作你想要执行什么