如何从使用Firebase的dynamic链接获取额外的参数?

我已经手动创build了dynamic链接,并在链接上设置了一些额外的参数,如下所示: https : //XXXXX.goo.gl/? link =https%3A%2F%2Fairbanq.send.com%2Fsendmoney&apn=com.xxxx。 XXXX&AMV = 1&用户名= Adri&量= 7.00

但是,当应用程序打开,我只是得到:“https:// airbanq.send.com/sendmoney”没有addiotional参数

我使用这个示例代码https://github.com/firebase/quickstart-android/tree/master/dynamiclinks

请任何帮助,

谢谢

我的代码

public String buildDeepLink() { // Get the unique appcode for this app. String appCode = AirBanqApp.mContext.getString(R.string.app_code); // Get this app's package name. String packageName = AirBanqApp.mContext.getPackageName(); // Build the link with all required parameters Uri.Builder builder = new Uri.Builder() .scheme("https") .authority(appCode + ".app.goo.gl") .path("/") .appendQueryParameter("link", deepLink) .appendQueryParameter("apn", packageName); // If the deep link is used in an advertisement, this value must be set to 1. if (isAd) { builder.appendQueryParameter("ad", "1"); } // Minimum version is optional. if (minVersion > 0) { builder.appendQueryParameter("amv", Integer.toString(minVersion)); } if (!TextUtils.isEmpty(androidLink)) { builder.appendQueryParameter("al", androidLink); } if (!TextUtils.isEmpty(playStoreAppLink)) { builder.appendQueryParameter("afl", playStoreAppLink); } if (!customParameters.isEmpty()) { for (Map.Entry<String, String> parameter : customParameters.entrySet()) { builder.appendQueryParameter(parameter.getKey(), parameter.getValue()); } } // Return the completed deep link. return builder.build().toString(); } 

Solutions Collecting From Web of "如何从使用Firebase的dynamic链接获取额外的参数?"

那是我的解决办法

我解决了我的问题,我认为“APN”,“用户名”和“数量”他们是参数“链接”的一部分,但没有当我添加“&”我要添加到主要的url的部分,要添加参数到“LINK”字段,我需要先创build像这样的url

https://airbanq.send.com/sendmoney?username=Adri&amount=7.00

然后使用URLEncoder.encode(queryParameters.toString(),“UTF-8”); 生成此https%3A%2F%2Fairbanq.send.com%2Fsendmoney%253Fusername%253DAdri%2526amount%253D7.00

然后附加到主要的url

https://xxxx.app.goo.gl/?link=https%3A%2F%2Fairbanq.send.com%2Fsendmoney%253Fusername%253DAdri%2526amount%253D7.00&apn=com.airbanq.airbanqapp&amv=1

  public String buildDeepLink() { // Get the unique appcode for this app. String appCode = AirBanqApp.mContext.getString(R.string.app_code); // Get this app's package name. String packageName = AirBanqApp.mContext.getPackageName(); String queryParamters = ""; try { queryParamters = generateQueryParameters(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (!TextUtils.isEmpty(queryParamters)) { deepLink = deepLink + queryParamters; } // Build the link with all required parameters Uri.Builder builder = new Uri.Builder() .scheme("https") .authority(appCode + ".app.goo.gl") .path("/") .appendQueryParameter("link", deepLink) .appendQueryParameter("apn", packageName); // If the deep link is used in an advertisement, this value must be set to 1. if (isAd) { builder.appendQueryParameter("ad", "1"); } // Minimum version is optional. if (minVersion > 0) { builder.appendQueryParameter("amv", Integer.toString(minVersion)); } if (!TextUtils.isEmpty(androidLink)) { builder.appendQueryParameter("al", androidLink); } if (!TextUtils.isEmpty(playStoreAppLink)) { builder.appendQueryParameter("afl", playStoreAppLink); } // Return the completed deep link. return builder.build().toString(); } private String generateQueryParameters() throws UnsupportedEncodingException { StringBuilder queryParameters = new StringBuilder(); //server purposes queryParameters.append("?*code*"); if (!customParameters.isEmpty()) { for (Map.Entry<String, String> parameter : customParameters.entrySet()) { queryParameters.append(String.format("&%1s=%2s", parameter.getKey(), parameter.getValue())); } } return URLEncoder.encode(queryParameters.toString(), "UTF-8"); }