firebase android有时未决的dynamiclink数据为空

时间:2018-09-13 08:11:41

标签: android firebase-dynamic-links

我的Android应用程序dynamiclink具有邀请码。 如果有人通过此链接安装myapp,则会显示邀请页面。 但有时未决的动态链接数据为空。 重复做不对我感到困惑。 某些身体可以帮助我

这是我的代码

* checkinvite

 public void checkInviteLink(){

        FirebaseDynamicLinks.getInstance()
                .getDynamicLink(this.getIntent())
                .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                    @Override
                    public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {

                        Uri deepLink = null;
                        if (pendingDynamicLinkData == null) {
                            //Toast.makeText(SplashActivity.this, "초대장이 없습니다", Toast.LENGTH_SHORT).show();
//                            deepLink = pendingDynamicLinkData.getLink();
//
//                            if (deepLink.getBooleanQueryParameter("invitedby", false))
//                            {
//                                Prefs.putString(Preferences.FirstInviteCoop, deepLink.getQueryParameter("invitedby"));
//                               // Toast.makeText(SplashActivity.this, "초대장을 받았습니다"+Prefs.getString(Preferences.FirstInviteCoop, ""), Toast.LENGTH_SHORT).show();
//                                Log.e("INVITELINK@@@@@@@@@@@", "OOOOOOOOOOOOOOO" + "    " + Prefs.getString(Preferences.FirstInviteCoop, ""));
//                            }
                        }else{
                           // Toast.makeText(SplashActivity.this, "invite초대장이 없습니다", Toast.LENGTH_SHORT).show();
                            //Toast.makeText(SplashActivity.this, "초대장을 받았습니다", Toast.LENGTH_SHORT).show();
                            deepLink = pendingDynamicLinkData.getLink();

                            if (deepLink.getBooleanQueryParameter("invitedby", false))
                            {
                                Prefs.putString(Preferences.FirstInviteCoop, deepLink.getQueryParameter("invitedby"));
                                // Toast.makeText(SplashActivity.this, "초대장을 받았습니다"+Prefs.getString(Preferences.FirstInviteCoop, ""), Toast.LENGTH_SHORT).show();
                                Log.e("INVITELINK@@@@@@@@@@@", "OOOOOOOOOOOOOOO" + "    " + Prefs.getString(Preferences.FirstInviteCoop, ""));
                            }
                        }
                        startApp();
                    }

                })
                .addOnCompleteListener(this, new OnCompleteListener<PendingDynamicLinkData>() {
                    @Override
                    public void onComplete(@NonNull Task<PendingDynamicLinkData> task) {
                    }
                }).addOnFailureListener(this,new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                startApp();
               // Toast.makeText(SplashActivity.this, "초대장 실패", Toast.LENGTH_SHORT).show();
            }
        });

*进行动态链接

public void sendInvite(int coop_num){

    Utils.showProgressDialog(this);

    final Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(Uri.parse("http://ecoops.co.kr/coop/invite/"+coop_num+"?invitedby="+coop_num))
            .setDynamicLinkDomain("ajc64.app.goo.gl")
            //.setNavigationInfoParameters(new DynamicLink.NavigationInfoParameters.Builder().setForcedRedirectEnabled(true).build())
            .setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
            .setIosParameters(new DynamicLink.IosParameters.Builder("com.whoopersoft.coops-ios")
                    .setAppStoreId("1330850886")
                    .build())

            // Set parameters
            // ...
            .buildShortDynamicLink(2)
            .addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() {
                @Override
                public void onComplete(@NonNull Task<ShortDynamicLink> task) {

                    if (task.isSuccessful()) {
                        Log.e("MAKE DYNAMICLINK","SUCCESS");
                        // Short link created

                        String text = coop_name + " 쿱으로 당신을 초대합니다.\n" +
                                "아래 링크를 눌러 초대장을 확인하세요.\n\n";
                        String link = task.getResult().getShortLink().toString();
                        Intent intent = new Intent(android.content.Intent.ACTION_SEND);
                        intent.setType("text/plain");
                        intent.putExtra(Intent.EXTRA_TEXT, text + link);
                        Intent chooser = Intent.createChooser(intent, "쿱으로 초대");

                        Utils.dismissProgressDialog();

                        startActivity(chooser);

                    } else {
                        Log.e("MAKE DYNAMICLINK","FIAL");
                        // Error
                        // ...
                    }
                }
            })
            .addOnFailureListener(this, new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.e("DYNAMICLINK",e.toString());
                }
            });
}

* manifast

 <activity
        android:name=".SplashActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <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="ajc64.app.goo.gl" android:scheme="https"/>
            <data android:scheme="coops" />
        </intent-filter>

        <meta-data
            android:name="android.app.shortcuts"
            android:resource="@xml/shortcuts" />
    </activity>

在具有相同经验或能力的人的帮助下 谢谢

0 个答案:

没有答案