Is com.google.android.c2dm.intent.RECEIVE still in use?
Solution 1
Yes, com.google.android.c2dm.intent.RECEIVE
is still in use. It is used when receiving a broadcast from GCM server that contains a GCM message. Even though C2DM is long deprecated, GCM still uses some names that contain c2dm
.
As you can see in this manifest sample (taken from the GCM guide), there are multiple places that still use names containing c2dm
or 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>
Solution 2
the com.google.android.c2dm.intent.RECEIVE
is also used by the firebase cloud messaging
Solution 3
As for the Receiver declaration
<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>
Google suggested to replace BroadcastReceiver with the com.google.android.gms.gcm.GcmReceiver, just like below.
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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>
Carlos
HFT Finance, low latency, Equity/FX/Futures, Market Making. Feed handlers, strategy code. Highly scalable real-time web arch for exchanges. C++, Rust, Python/Django/numpy/scikit, Java/Scala/Android/Kotlin, ObjC/Swift, etc. Management, dozens of reports. Side projects in mobile, games. Currently crypto HFT.
Updated on July 09, 2022Comments
-
Carlos almost 2 years
I've seen that c2dm itself is deprecated. But the new method, Google Cloud Messaging, seems to send intents with com.google.android.c2dm.intent.RECEIVE as the action.
My code is using this to get the registration key:
gcm = GoogleCloudMessaging.getInstance(getApplicationContext()); gcm.register(SENDER_ID);
Things are arriving correctly, but I'm wondering if I've left something in a half-deprecated state.
-
Carlos over 9 yearsOk cool, I've got those as well. It's confusing when you Google it and there's a big red paragraph telling you it's deprecated.
-
Gavriel about 5 yearswhat should be the category? "com.example.gcm" or should I put there my app's package name?