I'm trying to implement chat with Google Firebase. I'm following the tutorials but I cannot continue because an undeclared variable is being used and I cannot find its origin anywhere. The variable is called kGCMMessageIDKey
.
It is being used first in here as:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if (userInfo[kGCMMessageIDKey]) {
NSLog(@"Message ID: %@", userInfo[kGCMMessageIDKey]);
}
In the sample project, kGCMMessageIDKey
is declared in the AppDelegate as
NSString *const kGCMMessageIDKey = @"gcm.message_id";
.
I have a feeling that this is a constant I should obtain from the Firebase dashboard but I cannot find any corresponding ID there either.
A sender ID: set in the code of your app. Android Studio uses automatically the Sender ID of your Firebase Project. If you are still using GCM, you have probably set manually the sender ID in the code of your app. The sender ID identifies your app to Firebase Cloud Messaging when it asks for a token.
By default, the FCM SDK generates a registration token for the client app instance on app launch. Similar to the APNs device token, this token allows you to send targeted notifications to any particular instance of your app.
Support for multiple platformsAPNs and WNS do not support multiple platforms. They are designed to work with their native platforms. But, FCM supports multiple platforms such as Android and iOS and even supports Chrome web apps.
FCM allows a maximum of four different collapse keys per device to be used by the app server at any given time. In other words, the FCM connection server can simultaneously store four different collapsible send-to-sync messages per device, each with a different collapse key.
The value should be the unique id for the message and should match the message_id parameter for the message that you'd see while interacting with Firebase Cloud Messaging APIs. You can also use that value to reference the message when using the FCM API/services from the device.
Yes, it seems that you either need to paste that constant declaration into your code, or replace it with @"gcm.message_id"
. The value does not seem significant and this code snippet is mainly for debugging.
I would encourage you to set a breakpoint in didReceiveRemoteNotification
and examine the contents of userInfo
to familiarize yourself with the message payload and the various attributes available to you from both FCM and iOS. When the breakpoint is hit, type the following into the debugger:
(lldb) po userInfo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With