简体   繁体   English

如何在addSuccesListener之前识别firebase动态链接?

[英]How to recognize firebase dynamic link before addSuccesListener?

In my application, many link handled in same Activity,在我的应用程序中,许多链接在同一个活动中处理,

So, I need to know what link when link received.所以,我需要知道收到链接时的链接是什么。

I know that I will recognize after success listener,我知道成功后我会认出听众,

FirebaseDynamicLinks.getInstance()
                .getDynamicLink(intent)
                .addOnSuccessListener(activity, new OnSuccessListener<PendingDynamicLinkData>() {
                    @Override
                    public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
                        if (pendingDynamicLinkData != null) {
                            Uri deepLink = pendingDynamicLinkData.getLink();

but, My app's UI thread have to know before success listener, because of UI thread's next operations.但是,由于 UI 线程的下一个操作,我的应用程序的 UI 线程必须在成功侦听器之前知道。

So, I handle intent like that,所以,我这样处理意图,

if(intent.getExtras() != null
            && intent.getExtras().toString().contains("firebase")) { // this comes from firebase dynamic links.

Could I handle intent in this way?我可以这样处理意图吗? And, Firebase framework will aways put extra data include firebase string?而且,Firebase 框架会把额外的数据包括 firebase 字符串吗?

Could you please, let me know any other solution?你能告诉我任何其他解决方案吗? The bast ways, I hope to know my apps' host "(app).goo.gl" before success callback..最好的方法是,我希望在成功回调之前知道我的应用程序的主机“(app).goo.gl”。

您可以检查意向附加内容是否包含特殊常量

getIntent().hasExtra("com.google.firebase.dynamiclinks.DYNAMIC_LINK_DATA")

The accepted answer is actually incorrect.接受的答案实际上是不正确的。 The correct way to check for Firebase Dynamic link is to look inside getIntent().getData() .检查 Firebase 动态链接的正确方法是查看getIntent().getData()内部。 This will contain a Uri when app is opened via a Firebase Dynamic Link当应用程序通过 Firebase 动态链接打开时,这将包含一个 Uri

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM