问题描述
不推荐使用gcm,现在可以使用,并且可能会关闭?我的意思是gcm,它不依赖于Google Play服务(gcm.jar-GCMRegistar版本)。
我测试了最新的gcm版本,发现bulit apk的大小超过了2.0 MB,这比旧的gcm.jar大得多。
此外,旧的gcm不需要谷歌播放服务,一些较旧的设备尚未安装谷歌播放服务,因此旧的gcm可以在更多设备上运行。
这里是gradle文件:
apply plugin:'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion23.0.2
defaultConfig {
applicationIdcom.example.mygcm
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName1.0
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard -android.txt'),'proguard-rules.pro'
}
}
}
依赖关系{
编译'com.google.android .gms:play-services:8.4.0'
}
GCMRegistrar
API仍将受支持,但您绝对应该更改为新的GCM API。新的 InstanceId
API与旧版本相比具有许多优点和改进,并且效果很好(我在生产中测试了几个月)。 $ b
以下是服务器端非常有趣的部分:
关于图书馆的规模和作为@Arthur指出,你应该只是使用你需要从播放服务库。在这里,您可以使用库列表,您可以从gradle引用整个捆绑包。
Is deprecated gcm reliable to use now and when probably will be down?I mean gcm which has no depency on google play service(gcm.jar-GCMRegistar version).I tested latest gcm version and found out that the bulit apk is more than 2.0 mb size ,which is very bigger than old gcm.jar.Furthermore the old gcm does not need google play service and some older devices has not installed google play service,so the old gcm can run on more devices.Here is the gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.mygcm"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:8.4.0'
}
Although the old GCMRegistrar
API will still be supported, you should definitely change to the new GCM API. The new InstanceId
API has many advantages and improvements comparing to the old one and works very well (I tested it in production for months).
https://developers.google.com/instance-id/#key_features
And here is the very interesting part from the server side:
https://developers.google.com/instance-id/reference/server#get_information_about_app_instances
About the library size and as @Arthur pointed out you should just use what you need from the Play Services library. Here you have the list of individual libraries you can refer from gradle instead the whole bundle.
这篇关于不赞成使用谷歌播放服务的gcm和new gcm之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!