Reputation: 1230
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.
Upvotes: 8
Views: 2122
Reputation: 1962
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
Upvotes: 4