Firebase FCM notification received in iOS simulator but as GCM(?) on real iOS device in flutter app

Mobile Technologies Mobile Computing 2 years ago

0 0 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ edit: it is supposed to look like it does on the device log, according to Firebase support I am adding push notifications via FCM to my Flutter app, but the message format is very different on the iOS Simulator vs. my iPhone 5s. When receiving a push notification from the Firebase console to an active/opened app. Problem: What do I need to do to make sure the real device receives the message in the correct format? Log from Simulator (iPhone XR, 12.2) (looks like in the official code examples): onMessage: { from: 123000000000, collapse_key: com.mydomainnamehere, notification: { body: Lorem ipsum, title: Title, e: 1, tag: campaign_collapse_key_9876543210011223344 } } Log from real device (iPhone 5s, 12.2) (can't find any references online to this): onMessage: { google.c.a.c_l: notif_name, google.c.a.e: 1, aps: { alert: { title: Title, body: Lorem ipsum } }, gcm.n.e: 1, google.c.a.c_id: 9876543210011223344, google.c.a.udt: 0, gcm.message_id: 1234567800998877, google.c.a.ts: 1234567800 } The notification is sent from the Firebase console to all devices, the logs are taken from the same notification (but I anonymized the id's). The Device and Simulator is running the same Flutter code from Android Studio, at the same time. Parts of my pubspec.yaml that refers to FCM firebase_core: ^0.4.0+1 firebase_auth: 0.11.1 cloud_firestore: ^0.11.0+2 firestore_ui: ^1.4.0 firebase_messaging: ^5.0.2 Software and SDK Versions Flutter Channel dev, v1.8.4, Mac OS X 10.14.5, Android SDK version 28.0.3, Xcode 10.2.1, Android Studio version 3.4 Flutter message-handling code void initState() { super.initState(); if (Platform.isIOS) { iosSubscription = _fcm.onIosSettingsRegistered.listen((IosNotificationSettings settings) { print("FCM settings received: $settings"); }); _fcm.requestNotificationPermissions(IosNotificationSettings()); } _fcm.configure( onMessage: (Map message) async { print("onMessage: $message"); }, ); getFcmToken(); } void getFcmToken() async { var token = await FirebaseMessaging().getToken(); print("Token $token"); } I was expecting that the JSON format would be the same on both the simulator and a real device. But the real device isn't even receiving all of the notification.

Posted on 16 Aug 2022, this text provides information on Mobile Computing related to Mobile Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (0)

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Mobile Technologies Links