akr cf
akr cf

Reputation: 31

How to get the open rate of the notification sent from the Firebase notifications console?

I configured and installed the sample Firebase quick start app for android https://github.com/firebase/quickstart-android/tree/master/messaging and ios https://github.com/firebase/quickstart-ios/tree/master/messaging.

I was able to send notifications from the Firebase console but when I open the notification, I can't see the open rate in the Firebase console backend.

According to the documentation, the open event is automatically fired, when a user clicks on the notification.

Are there any more steps involved to see the open rate of the notifications sent from the console?

Also is there a way to send a notification from the API and still get the open rate for those notifications?

Upvotes: 3

Views: 3606

Answers (2)

Simon Wang
Simon Wang

Reputation: 1156

If you have implemented UNUserNotificationCenterDelegate on iOS 10, you need to call

Messaging.messaging().appDidReceiveMessage(userInfo) // it sends confirming message to Firebase Cloud Messging

in these two delegate methods

public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    let userInfo = notification.request.content.userInfo
    Messaging.messaging().appDidReceiveMessage(userInfo)
}

public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
    let userInfo = response.notification.request.content.userInfo
    Messaging.messaging().appDidReceiveMessage(userInfo)
    completionHandler()
}

otherwise, you need to implement this UIApplicationDelegate method:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
   [[FIRMessaging messaging] appDidReceiveMessage:userInfo];
   completionHandler(UIBackgroundFetchResultNoData);
}

Upvotes: 2

Arun Ramachandran
Arun Ramachandran

Reputation: 510

You need to include firebase analytics related dependancy in gradle. Open rate is part of analytics library.

Check if you have included both of these : compile 'com.google.firebase:firebase-core:9.4.0' compile 'com.google.firebase:firebase-messaging:9.4.0'

Upvotes: 0

Related Questions