我正在做一个项目,我想在其中集成 GCM
和 Google sign in
但问题是两者都有 google-services.json
我们需要在项目中添加的配置文件。
So, how can I integrate both
google-services.json
configuration file in my project.
这是我的配置文件之一
{
"project_info": {
"project_id": "default-xxx",
"project_number": "xxx",
"name": "xxx"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:xxx",
"client_id": "x.package",
"client_type": 1,
"android_client_info": {
"package_name": "x.package_name"
}
},
"oauth_client": [],
"api_key": [],
"services": {
"analytics_service": {
"status": 1
},
"cloud_messaging_service": {
"status": 1,
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 1
},
"ads_service": {
"status": 1
}
}
}
],
"client_info": [],
"ARTIFACT_VERSION": "1"
}
最佳答案
最后我做了如下:
第 1 步:打开您想要的 Google 服务页面,在我的例子中是 google sign in和 GCM .将有一个按钮显示获取配置文件,单击该按钮并输入您的详细信息并获取配置文件。
第 2 步: 检查两个配置文件,它在 project_info
对象和 client_info中具有相同的配置
对象。区别在于 services
对象,如果您添加了两个或更多服务,则必须检查状态 status 值将是 2
这意味着它们是已启用的服务。您可以在下面的配置文件中看到我为两项服务生成的配置文件,即 Google 登录 和 GCM。
您只需检查 services 对象中的 status 值,它表示您在项目中集成的所有服务的 2是你必须添加的配置文件。
{
"project_info": {
"project_id": "xxxxxxxxxx",
"project_number": "xxxxxxxx",
"name": "xxxxxxxxxxx"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "xxxxxxxxxxx",
"client_id": "xxxxxxxxxxx",
"client_type": 1,
"android_client_info": {
"package_name": "xxxxxxxxxx"
}
},
"oauth_client": [
{
"client_id": "xxxxxxxxxx",
"client_type": 1,
"android_info": {
"package_name": "xxxxxxxx",
"certificate_hash": "xxxxxxxxxxx"
}
}
],
"api_key": [],
"services": {
"analytics_service": {
"status": 1
},
"cloud_messaging_service": {
"status": 2, <======= this is my gcm service status
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 2 <===== this my google sign in service status
},
"ads_service": {
"status": 1
}
}
}
],
"client_info": [],
"ARTIFACT_VERSION": "1"
}
注意:我正在使用 Google 登录 服务,因此它生成 oauth_client 字段值,如果您仅生成该字段值,您将无法获得用于 GCM。
关于android - 如何使用 Android Studio 为同一项目中的不同谷歌服务集成两个或多个 google-services.json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35012700/