通过Google
手动链接实现Google AppInvite
。
启动Invite Activity
并在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)
然后我在onActivityResult
方法中添加一个Log.d,并进入LogCat:
onActivityResult: requestCode=0, resultCode=3
有人能帮我吗?我试着在两周左右把它修好。
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");
}
}
}
是否包含json配置文件?
在项目设置下的firebase控制台中,找到"证书指纹(SHA-1)"部分,并从帮助图标中指向https://developers.google.com/android/guides/client-auth并为发布和调试证书指纹输入生成的SHA1密钥。然后resultCode 3将消失,您将发送邀请。
您可能需要在发布模式而不是调试模式下生成APK。
您是否在Google Developers Console中仔细检查了项目的OAuth客户端ID?
请确保正确放置项目的SHA-1和包名称。我建议您创建两个客户端ID:一个使用SHA-1用于debug
密钥,另一个用于release
密钥。
您还可以安全地删除应用级build.gradle
文件中的google-services.json
文件和apply plugin: 'com.google.gms.google-services'
代码,因为"它只是一个快速启动的助手,可以生成一些基本的android-resource文件,以便更容易地集成特定的Google API功能。"如本文所述。
我认为,如果您已将Firebase与Google Play上的应用程序连接,但必须从Google Play下载应用程序,那么它应该自动工作。我也遇到了同样的问题,但在我的情况下它不起作用,因为我有一个应用程序的版本,它是我直接从计算机上安装的(调试模式)。