com.google.android.c2dm.intent.RECEIVE是否仍在使用?

Car*_*los 11 android push-notification android-intent google-cloud-messaging

我已经看到c2dm本身已被弃用.但是新方法Google Cloud Messaging似乎发送了以com.google.android.c2dm.intent.RECEIVE作为操作的意图.

我的代码使用它来获取注册密钥:

gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
gcm.register(SENDER_ID);
Run Code Online (Sandbox Code Playgroud)

事情正确到达,但我想知道我是否已经离开了处于半弃状态的东西.

Era*_*ran 14

是的,com.google.android.c2dm.intent.RECEIVE仍在使用中.从GCM服务器接收包含GCM消息的广播时使用它.尽管C2DM已被弃用,但GCM仍然使用一些包含的名称c2dm.

正如您在此清单示例中所看到的(取自GCM指南),有多个地方仍然使用包含c2dm或的名称C2D:

<manifest package="com.example.gcm" ...>
...
<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

<application ...>
    <receiver
        android:name=".GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.example.gcm" />
        </intent-filter>
    </receiver>
    <service android:name=".GcmIntentService" />
</application>
Run Code Online (Sandbox Code Playgroud)

  • 好的很酷,我也有.当你使用谷歌时它会让人感到困惑,并且有一个很大的红色段落告诉你它已被弃用了. (2认同)

小智 5

com.google.android.c2dm.intent.RECEIVEfirebase 云消息传递也使用它