Pan*_*kaj 6 android google-play-services android-studio
我在做一个项目,我想整合GCM和Google sign in但问题是都有google-services.json这就需要我们在我们的项目中添加的配置文件.
那么,我如何
google-services.json在我的项目中集成两个配置文件.
这是我的配置文件之一
{
"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"
}
Run Code Online (Sandbox Code Playgroud)
最后我做了如下:
第1步:在我的案例中打开您想要的谷歌服务页面谷歌登录和GCM.将有一个按钮说获取配置文件,单击它并输入您的详细信息并获取配置文件.
步骤2:检查两个配置文件,它在project_info对象和client_info对象中具有相同的配置.区别在于services您必须检查状态,如果您已添加两个或更多服务状态值,2这意味着它们是启用的服务.您可以在下面的配置文件中看到我为Google登录和GCM两项服务生成的文件.
你只需要检查你的状态中值的服务对象,其中跟它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"
}
Run Code Online (Sandbox Code Playgroud)
注意:我正在使用Google登录服务,因此如果您仅为GCM生成,那么它还会生成oauth_client字段值.
您不需要两个不同的google-services.json文件.两者都具有相同的配置.无论您激活了多少服务,这些配置文件对于每个项目都是唯一的.
在生成配置文件之前,请确保已激活这两项服务.生成的配置文件对两者都有效.
按照"下载并安装配置"链接下方的"继续登录"链接,获取有关下一步操作的文档.
| 归档时间: |
|
| 查看次数: |
10676 次 |
| 最近记录: |