C2DM (Cloud to Device Messaging) is outdated and has been replaced by Firebase Cloud Messaging (FCM). While FCM is excellent for sending push notifications to Android devices (e.g., alerting users of new messages when the app is in the background), it’s not ideal for real-time chat. FCM introduces potential delays, as it relies on Google’s infrastructure to deliver messages, which may not meet the instant delivery needs of a chat app.
Instead of managing your own WebSocket server or relying on FCM, I recommend using HPKV’s real-time pub/sub feature. HPKV is a key-value store that offers real-time key monitoring through a managed WebSocket-based pub/sub system. This approach simplifies your architecture by providing instant updates without the overhead of running your own server or message broker (like RabbitMQ or Kafka)
For more context, check out this article which demonstrates a similar approach with NextJS. While it’s web-based, the principles apply to Android with some adjustments.