Dav*_*vid 8 android push-notification google-cloud-messaging google-play-services
我正在使用Google Cloud Messaging在Android手机上接收推送通知.我成功了,一切似乎都运作良好.但是,Google建议检查Google Play服务是否已更新到上一版本(因为推送通知是一项新功能).
使用Nexus 7(4.4.4)并在活动开始时启用版本检查我需要更新我的Google Play服务,因为有更新的版本.但是,推送通知在没有更新的情况下完美运行.如果不是绝对必要,我不想要求我的用户更新Google Play服务.
我的问题:为了从GCM接收推送通知,我应该检查Google Play服务的最低版本是什么?
这是代码:
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
备注:我不需要检查最新版本的Google Play服务,但支持推送通知的最低版本
编辑:由于评论,我做了一些澄清
我有一个启用了 GCM 的应用程序。正如我在数据库中看到的,存在 Google Play 服务版本高于3.0.27.
但使用时要小心GcmNetworkManager,因为它至少需要google play服务7.5.0
| 归档时间: |
|
| 查看次数: |
1648 次 |
| 最近记录: |