通过Firebase动态链接Android传递多个参数 [英] Pass multiple params via Firebase Dynamic links Android

查看:760
本文介绍了通过Firebase动态链接Android传递多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了Firebase Dynamics链接,可以打开我的应用,转到商店或转到某个网址。但是当我通过链接传递一些参数时,我只能得到第一个参数。
这是我的动态链接:

  https://xx.app.goo.gl/?link=http: //xx.com/?usn=abc&pass=def&apn=com.xx&afl=http://google.com 

我使用这段代码来获取链接:

  //使用AppInvite API构建GoogleApiClient用于接收深层链接
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this,this)
.addApi(AppInvite.API)
.build();

//检查此应用是否从深层链接启动。将autoLaunchDeepLink设置为true
//如果找到,则会自动启动深层链接。
boolean autoLaunchDeepLink = false;
appInvite.AppInviteApi.getInvitation(mGoogleApiClient,this,autoLaunchDeepLink)
.setResultCallback(
result - > {
if(result.getStatus()。isSuccess()){
//从Intent提取深层链接
Intent intent = result.getInvitationIntent();
String deepLink = AppInviteReferral.getDeepLink(intent);
Logger.e(deepLink);
}
}
);

和日志打印: http://xx.com/?usn=abc (pass = def已经丢失)
任何人都可以解决这个问题?

解决方案

您需要 URL编码 link 参数的值,否则系统将无法确定动态链接的参数是什么,以及<$ $的子参数是什么这意味着最终的URL看起来像 https:/ / c $ c> link 动态链接的参数。 /xx.app.goo.gl/?link=http%3A%2F%2Fxx.com%2F%3Fusn%3Dabc%26pass%3Ddef&apn=com.xx&afl=http://google.com $ b $ p
$ b

重要提示:如果您(正如我怀疑的那样)试图通过明文链接参数传递用户名和密码,是一个非常糟糕的主意。严重的是, 不要这样做 。阅读这个答案,以获得像这样的要求的正确方法。


I've used Firebase Dynamics link and it can open my app, go to play store or go to an URL. But when I pass some parameters through link, I can only get first parameter. Here's my dynamic links:

https://xx.app.goo.gl/?link=http://xx.com/?usn=abc&pass=def&apn=com.xx&afl=http://google.com

And I used this code to get the link:

// Build GoogleApiClient with AppInvite API for receiving deep links
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, this)
                .addApi(AppInvite.API)
                .build();

        // Check if this app was launched from a deep link. Setting autoLaunchDeepLink to true
        // would automatically launch the deep link if one is found.
        boolean autoLaunchDeepLink = false;
        AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
                .setResultCallback(
                        result -> {
                            if (result.getStatus().isSuccess()) {
                                // Extract deep link from Intent
                                Intent intent = result.getInvitationIntent();
                                String deepLink = AppInviteReferral.getDeepLink(intent);
                                Logger.e(deepLink);
                            }
                        }
                );

And the log print: http://xx.com/?usn=abc (the pass=def was lost) Anyone resolve this issue?

解决方案

You need to URL encode the value of the link parameter, otherwise the system can't tell what is a parameter of the Dynamic Link and what is a sub-paramater of the link parameter of the Dynamic Link.

This means the final URL should look like https://xx.app.goo.gl/?link=http%3A%2F%2Fxx.com%2F%3Fusn%3Dabc%26pass%3Ddef&apn=com.xx&afl=http://google.com

Important note: if you are (as I suspect) attempting to pass usernames and passwords through as plaintext link parameters, this is an incredibly bad idea. Seriously, do not do this. Read this answer for the proper approach to a requirement like this.

这篇关于通过Firebase动态链接Android传递多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆