Firebase动态链接不会在特定情况下启动我的应用程序 [英] Firebase dynamic links is not launching my app in specific situation

查看:306
本文介绍了Firebase动态链接不会在特定情况下启动我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我点击HTML页面中的链接时,链接正在工作,使用<

这意味着,如果应用程序未安装,请转到Play商店,否则打开应用程序,我可以收到深层链接地址。



但是,当链接是完全相同的其他地方如Facebook的信使或电子邮件等我点击链接,那么它不工作。
$ b

即使我的应用程序已经安装,它总是被重定向到Play Store。



有什么问题



我的代码在这里。


  • .java用于接收深层链接

    pre $ lt; code> GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
    .enableAutoManage(this,this)
    .addApi(AppInvite.API)
    .build();

    boolean autoLaunchDeepLink = false;
    AppInvite.AppInviteApi.getInvitation(mGoogleApiClient,this,autoLaunchDeepLink)
    .setResultCallback(
    new ResultCallback< AppInviteInvitationResult>(){
    @Override $ b $ public void onResult(@ NonNull AppInviteInvitationResult结果){
    if(result.getStatus()。isSuccess()){
    //从Intent提取深层链接
    Intent intent = result.getInvitationIntent();
    String deepLink = AppInviteReferral.getDeepLink(intent);

    Log.e(sf,### deep link:+ deepLink);
    } else {
    Log .d(asdf,getInvitation:no deep link found。);
    }
    }
    });


  • 意图AndroidManifest.xml中的一部分活动

     < intent-filter> 

    < category android:name =android.intent.category.DEFAULT/>
    < category android:name =android.intent.category.BROWSABLE/>

    < data
    android:host =mycode.app.goo.gl/
    android:scheme =https
    android:pathPattern = */>
    < / intent-filter>


  • 动态连结

    https://mycode.app.goo.gl/?link= 网页地址 & al = 我的自定义共享方案& apn = 我的android应用程序包名称

    https://firebase.google.com/docs/dynamic-links/rel =nofollow noreferrer> https://firebase.google.com/docs/dynamic-links/ ,他们正在正常工作除了Facebook和Facebook Messenger应用以外的所有情况。



    首先,我们生成一个动态链接到我们的应用程序:

    <$ p $ b $ Builder builder = new Builder()
    .scheme(https)
    .authority(winged-guild-133523.appspot.com)
    .appendPath(share)
    .appendQueryParameter(query,query);

    然后我们产生长的动态链接:

      Builder builder = new Builder()
    .scheme(https)
    .authority(zkkf4.app.goo.gl)
    .appendPath()
    .appendQueryParameter(link,deepLink)
    .appendQueryParameter(apn,com.mydomain.myapp);然后我们用一个简短的链接在
    firebasedynamiclinks.googleapis.com/v1/shortLinksrel =nofollow noreferrer> https://firebasedynamiclinks.googleapis.com/v1/shortLinks 并使用意向分享:

      Intent intent = new Intent(Intent.ACTION_SEND); 
    intent.setType(text / plain);
    intent.putExtra(Intent.EXTRA_TEXT,text);
    startActivity(Intent.createChooser(intent,null));

    如果我们使用Facebook应用程式分享这个连结:


  • 短链接已被正确共享

  • 如果未安装应用程序,点击Facebook应用程序中的链接即可正常使用Google Play,应用程序的深层链接处理正确。

  • 如果安装了应用程序,点击Facebook应用程序中的链接也会进入Google Play,点击打开按钮后,深层链接没有转移到应用程序,因为如果安装没有执行,Google Play不会将引荐信息传递给应用程序。 如果我们分享这个使用Facebook Messenger应用程序进行链接:





    所以我在这里看到三个问题:


    • Facebook应用程序未正确检测到应用程序已安装。

    • Facebook Messenger应用程序共享一个长动态链接,而不是一个简短的链接。

    • Facebook Messenger应用程序可以检测到该应用程序已安装,但转到链接而不是Google Play如果应用程序没有安装。



    有谁知道怎么解决这些问题?
    $ b

    PS:尽管这是无关的,因为应用程序中的深层链接处理正常工作,这是我们的清单意图过滤器:

     < intent-filter> 
    < category android:name =android.intent.category.LAUNCHER/>
    < / intent-filter>

    < intent-filter android:label =@ string / app_name>
    < category android:name =android.intent.category.DEFAULT/>
    < category android:name =android.intent.category.BROWSABLE/>
    < data android:scheme =http/>
    < data android:scheme =https/>
    < data android:host =winged-guild-133523.appspot.com/>
    < data android:host =www.winged-guild-133523.appspot.com/>
    < data android:pathPattern =/ share。*/>
    < / intent-filter>


    I've made a dynamic link for users to share some contents in my app.

    The link is working when I click a link in an HTML page using href tag on Android device.

    It means, if the app is not installed, go to Play Store, else opening the app and I could receive deep link address.

    But when the link is exactly same on other places like a facebook messenger or email etc. I click the link, then it's not working.

    It's always redirected to Play Store even if my app is already installed.

    What's the problem?

    My code is here.

    • .java for receiving deep link

      GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
              .enableAutoManage(this, this)
              .addApi(AppInvite.API)
              .build();
      
      boolean autoLaunchDeepLink = false;
      AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
              .setResultCallback(
                      new ResultCallback<AppInviteInvitationResult>() {
                          @Override
                          public void onResult(@NonNull AppInviteInvitationResult result) {
                              if (result.getStatus().isSuccess()) {
                                  // Extract deep link from Intent
                                  Intent intent = result.getInvitationIntent();
                                  String deepLink = AppInviteReferral.getDeepLink(intent);
      
                                  Log.e("sf", "### deep link : " + deepLink );
                              } else {
                                  Log.d("asdf", "getInvitation: no deep link found.");
                              }
                          }
                      });
      

    • intent part of activity in AndroidManifest.xml

          <intent-filter>
              <action android:name="android.intent.action.VIEW" />
      
              <category android:name="android.intent.category.DEFAULT" />
              <category android:name="android.intent.category.BROWSABLE" />
      
              <data
                  android:host="mycode.app.goo.gl/"
                  android:scheme="https"
                  android:pathPattern=".*" />
          </intent-filter>  
      

    • dynamic link

      https://mycode.app.goo.gl/?link=web page address&al=my custom scheme for sharing&apn=my android app's package name

    解决方案

    We have implemented Firebase Dynamic Links according to this documentation https://firebase.google.com/docs/dynamic-links/ and they are working properly in all cases except of Facebook and Facebook Messenger app.

    First we generate a dynamic link to our app:

    Builder builder = new Builder()
      .scheme("https")
      .authority("winged-guild-133523.appspot.com")
      .appendPath("share")
      .appendQueryParameter("query", query);
    

    Then we generate the long dynamic link:

    Builder builder = new Builder()
      .scheme("https")
      .authority("zkkf4.app.goo.gl")
      .appendPath("")
      .appendQueryParameter("link", deepLink)
      .appendQueryParameter("apn", "com.mydomain.myapp");
    

    Then we exchange the long dynamic link with a short link at https://firebasedynamiclinks.googleapis.com/v1/shortLinks and share it using intent:

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, text);
    startActivity(Intent.createChooser(intent, null));
    

    If we share this link using Facebook app:

    • The short link is properly shared.
    • If the app is not installed, clicking on the link in Facebook app goes properly to Google Play and after installing the app the deep link is handled correctly.
    • If the app is installed, clicking on the link in Facebook app goes also to the Google Play and after clicking on open button, the deep link is not transferred to the app because Google Play do not pass referrer information to the app if installation has not been performed.

    If we share this link using Facebook Messenger app:

    So I see three problems here:

    • Facebook app is not properly detecting that the app is installed.
    • Facebook Messenger app shares a long dynamic link instead of short one.
    • Facebook Messenger app can detect that the app is installed but goes to the link instead of Google Play if the app is not installed.

    Do anyone have any idea what is going on an how to solve those issues?

    PS: Although this is irrelevant because the deep link handling in the app is working properly this is our manifest intent filter:

      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    
      <intent-filter android:label="@string/app_name">
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="http"/>
        <data android:scheme="https"/>
        <data android:host="winged-guild-133523.appspot.com"/>
        <data android:host="www.winged-guild-133523.appspot.com"/>
        <data android:pathPattern="/share.*"/>
      </intent-filter>
    

    这篇关于Firebase动态链接不会在特定情况下启动我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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