3

Google AppInvite通过Google手动链接实现。

启动 InviteActivity并在 LogCat 中获取下一个:

E/AppInviteAgent: Get suggested invitees failed due to error code: 3
            No Android client ID is found for package name <MY_PACKAGE_NAME>. (APPINVITE_CLIENT_ID_ERROR)

E/AppInviteAgent: Create invitations failed due to error code: 3
            No Android client ID is found for package name <MY_PACKAGE_NAME>. (APPINVITE_CLIENT_ID_ERROR)

然后我在方法中添加一个 Log.donActivityResult并进入 LogCat:

onActivityResult: requestCode=0, resultCode=3

有人可以帮助我吗?我尝试修复它大约 2 周。

UPD0

// my `build.gradle` file (project level)
  dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0-beta6'
    classpath 'com.google.gms:google-services:2.0.0-beta6'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
// my `build.gradle` file (app level)

compileSdkVersion 23
buildToolsVersion '23.0.2'
// ... some code
dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
     testCompile 'junit:junit:4.12'
     compile 'com.android.support:appcompat-v7:23.2.0'
     compile 'com.android.support:design:23.2.0'
     compile 'com.google.android.gms:play-services-ads:8.4.0'
     compile 'com.google.android.gms:play-services-appinvite:8.4.0'
     // for in-app-billing v3
     compile 'com.anjlab.android.iab.v3:library:1.0.31'
}
// and in the end of the file
// for Google Invite
apply plugin: 'com.google.gms.google-services'

// my methods in the MainActivity
private void onInviteClicked() {
        Intent intent = new AppInviteInvitation.IntentBuilder(
                getString(R.string.txt_invitation_title))
                .setMessage(getString(R.string.txt_invitation_message))
                .setCallToActionText(getString(R.string.txt_invitation_cta))
                .build();
        startActivityForResult(intent, REQUEST_INVITE);
}
// where REQUEST_INVITE - private static final int and equal 0;

// and onActivityResult - copy from `Google` manual
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    new MyLogs("onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode);

    if (requestCode == REQUEST_INVITE) {
        if (resultCode == RESULT_OK) {
            // Check how many invitations were sent and log a message
            // The ids array contains the unique invitation ids for each invitation sent
            // (one for each contact select by the user). You can use these for analytics
            // as the ID will be consistent on the sending and receiving devices.
            String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
            new MyLogs(getString(R.string.sent_invitations_fmt, ids.length));
        } else {
            // Sending failed or it was canceled, show failure message to the user
            new MyLogs("send_failed");
        }
    }
}
4

5 回答 5

1

您是否包含了 json 配置文件?

于 2016-03-26T15:00:31.477 回答
1

在 Project Settings 下的 firebase 控制台中,找到“Certificate Fingerprints (SHA-1)”部分,然后从帮助图标中您将被定向到https://developers.google.com/android/guides/client-auth并输入生成的 SHA1 密钥发布和调试证书指纹。然后 resultCode 3 将消失,您将发送邀请。

于 2016-06-14T15:09:57.117 回答
0

如果您已将 Firebase 与 Google Play 上的应用程序连接起来,我认为它应该会自动运行,但您必须从 Google Play 下载您的应用程序。我遇到了同样的问题,但在我的情况下它不起作用,因为我有直接从计算机安装的应用程序版本(调试模式)。

于 2017-05-04T15:47:24.993 回答
0

您是否在Google Developers Console中仔细检查了您项目的OAuth 客户端 ID

确保正确放置项目的SHA-1包名称。我建议您创建两个客户端 ID:一个使用 SHA-1 作为debug密钥,另一个作为release密钥。

您还可以安全地删除应用级文件中的google-services.json文件和代码,因为“它只是生成一些基本的 android 资源文件以便更轻松地集成特定 Google API 功能的快速入门助手。” 如此处所述。apply plugin: 'com.google.gms.google-services'build.gradle

于 2016-03-28T08:00:11.177 回答
0

您可能需要在发布模式而不是调试模式下生成 APK。

于 2016-03-27T10:32:13.873 回答