difference between deprecated gcm and new gcm whic

2019-09-13 02:53发布

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'
}

2条回答
成全新的幸福
2楼-- · 2019-09-13 03:23

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.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-09-13 03:28

When using the new gcm library you should include the individual dependency not the entire play-services library.

use:

compile 'com.google.android.gms:play-services-gcm:8.4.0'

instead of:

compile 'com.google.android.gms:play-services:8.4.0'

Same for other Play Services libraries eg: play-services-drive

查看更多
登录 后发表回答