我正在使用从此处创建的google-services.json文件:https : //developers.google.com/mobile/add?platform=android&cntapi=gcm&cnturl=https :% 2F% 2Fdevelopers.google.com%2Fcloud- messaging %2Fandroid%2Fclient&cntlbl =继续%20Adding%20GCM%20Support&%3Fconfigured%3Dtrue
在JSON结构中,有一个称为客户端的JSON数组。如果您有多种口味,只需在此处添加不同的属性。
{
"project_info": {
"project_id": "PRODJECT-ID",
"project_number": "PROJECT-NUMBER",
"name": "APPLICATION-NAME"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:PROJECT-NUMBER:android:HASH-FOR-FLAVOR1",
"client_id": "android:PACKAGE-NAME-1",
"client_type": 1,
"android_client_info": {
"package_name": "PACKAGE-NAME-1"
}
},
"oauth_client": [],
"api_key": [],
"services": {
"analytics_service": {
"status": 1
},
"cloud_messaging_service": {
"status": 2,
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 1
},
"ads_service": {
"status": 1
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:PROJECT-NUMBER:android:HASH-FOR-FLAVOR2",
"client_id": "android:PACKAGE-NAME-2",
"client_type": 1,
"android_client_info": {
"package_name": "PACKAGE-NAME-2"
}
},
"oauth_client": [],
"api_key": [],
"services": {
"analytics_service": {
"status": 1
},
"cloud_messaging_service": {
"status": 2,
"apns_config": []
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"google_signin_service": {
"status": 1
},
"ads_service": {
"status": 1
}
}
}
],
"client_info": [],
"ARTIFACT_VERSION": "1"
}
在我的项目中,我使用相同的project-id,并且在上述url中添加第二个包名称时,google为我提供了一个在json-data中包含多个客户端的文件。
抱歉,紧凑型JSON数据。我无法正确格式化...