不赞成使用谷歌播放服务的gcm和new gcm之间的区别 [英] difference between deprecated gcm and new gcm which uses google play service

查看:142
本文介绍了不赞成使用谷歌播放服务的gcm和new gcm之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不推荐使用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与旧版本相比具有许多优点和改进,并且效果很好(我在生产中测试了几个月)。



https://developers.google.com/instance-id/#key_features $ b


实例ID,标识和授权



实例ID(IID)允许您为每个
应用实例检索一个唯一标识符,提供一种机制来验证和授权
操作,即使您的应用没有用户注册并且
账户。例如,这允许您通过包含实例ID令牌来唯一确定哪个应用
实例正在发送请求。
我们还可以轻松处理边缘案例,以确保您
包含有效的实例ID令牌。


以下是服务器端非常有趣的部分:

https://developers.google.com/instance-id/reference/server#get_information_about_app_instances



关于图书馆的规模和作为@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

Instance ID, Identity, and Authorization

Instance ID (IID) allows you to retrieve a unique identifier for every app instance, providing a mechanism to authenticate and authorize actions, even if your app does not have user registration and accounts. For example, this allows you to uniquely determine which app instance is sending a request from by including the Instance ID token. We’ve also made it easy to handle edge cases to ensure that you’ll have valid Instance ID tokens.

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之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆