Goals

The goal of this guide is to set up:

  • basic push notifications handling via Firebase Cloud Messaging SDK

  • sending registration_id (push_token in Firebase Cloud Messaging system) to the Adjust system

Prerequisites

It is expected that you’ve already implemented:

Firebase Cloud Messaging SDK

  1. Make sure that you’ve implemented the Firebase Cloud Messaging SDK according to this instruction

  2. Pay specific attention to this part of instruction, especially to the part about handling silent push notifications

  3. Make sure that images in push notifications are handled properly

Adjust SDK

  1. To be notified whenever the token is updated, to send it to the Adjust afterward, supply a delegate conforming to the messaging delegate protocol. The following example registers the delegate and adds the proper delegate method:

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { 
print("Firebase registration token: \\(String(describing: fcmToken))")

let dataDict: [String: String] = ["token": fcmToken ?? ""]
NotificationCenter.default.post(
name: Notification.Name("FCMToken"),
object: nil, userInfo: dataDict
)
// TODO: If necessary send token to application server.
// Note: This callback is fired at each app startup and whenever a new token is generated.
Adjust.setDeviceToken(fcmToken)
}

Refer to this part of Firebase Push Cloud Messaging documentation for details

Did this answer your question?