Google Cloud IoT Integration in Mobile IoT Applications
Google Cloud IoT Core was officially deprecated on August 16, 2023. If you came here asking "how to integrate GCP IoT Core" — important to know this right now. Projects relying on it should have migrated to alternatives.
What Instead of Google Cloud IoT Core
Google recommends several migration paths:
1. MQTT bridge via Cloud Pub/Sub directly. Devices publish to Cloud Pub/Sub via custom MQTT broker (HiveMQ, EMQX, Mosquitto), not managed GCP IoT Core. Mobile app subscribes to Pub/Sub topics via gRPC API.
2. Partner platforms. Google officially directs to Clearblade IoT Core and Cognite, which offer compatible API. Migration from Cloud IoT Core to Clearblade — minimal client code changes.
3. Switch to different cloud IoT provider — AWS IoT Core or Azure IoT Hub if no GCP lock-in.
We most often recommend Cloud Pub/Sub + custom MQTT broker for clients wanting to stay in GCP ecosystem.
Mobile App Architecture Based on GCP
Direct Cloud Pub/Sub connection via gRPC requires Google Cloud credentials. Can't embed Service Account key in app. Use Firebase Authentication + Cloud Firestore/Realtime Database as transport layer for IoT states.
It works like this: IoT devices publish telemetry → MQTT broker → Cloud Pub/Sub → Cloud Function → Firestore. Mobile app reads states from Firestore via realtime subscriptions and writes commands there. Separate Cloud Function listens for Firestore changes and publishes commands back to MQTT broker to device.
On Flutter via cloud_firestore package:
FirebaseFirestore.instance
.collection('devices')
.doc(deviceId)
.snapshots()
.listen((snapshot) {
final state = DeviceState.fromJson(snapshot.data()!);
// update UI
});
On React Native — @react-native-firebase/firestore with same API.
Cloud Run + MQTT for IoT
More correct production architecture: EMQX or HiveMQ on Cloud Run / GKE → Cloud Pub/Sub → Cloud Functions → Firestore. EMQX supports Rule Engine (analog of AWS IoT Rules): can publish to Pub/Sub by conditions directly from broker without separate Lambda/Functions.
Mobile client connects to EMQX via MQTT over WebSocket with JWT auth (issued by Firebase Auth). EMQX validates token via HTTP Authentication hook — request to your backend on every connection.
Firebase Cloud Messaging for IoT Events
Push by IoT events — native strong point of GCP stack. Cloud Function triggered by Pub/Sub message, sends FCM notification via Admin SDK:
await admin.messaging().send({
token: userFcmToken,
notification: { title: 'Motion Sensor', body: 'Motion detected in hallway' },
data: { deviceId: '...', eventType: 'motion' }
});
On Flutter firebase_messaging handles notifications in background via onBackgroundMessage handler. Important: handler must be top-level function, not class method — else crash receiving notification in killed state.
Timeline
Basic architecture (MQTT broker + Pub/Sub + Firestore + mobile client) — 3–4 weeks. Push notifications, Cloud Functions for automation — another 1–2 weeks. Pricing calculated individually, GCP infrastructure billed by message volume and compute.







