FIRMessagingDelegate

@protocol FIRMessagingDelegate <NSObject>

A protocol to handle events from FCM for devices running iOS 10 or above.

To support devices running iOS 9 or below, use the local and remote notifications handlers defined in UIApplicationDelegate protocol.

  • This method will be called whenever FCM receives a new, default FCM token for your Firebase project’s Sender ID. You can send this token to your application server to send notifications to this device.

    Declaration

    Swift

    func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String)

    Objective-C

    - (void)messaging:(nonnull FIRMessaging *)messaging
        didRefreshRegistrationToken:(nonnull NSString *)fcmToken;
  • This method is called on iOS 10 devices to handle data messages received via FCM through its direct channel (not via APNS). For iOS 9 and below, the FCM data message is delivered via the UIApplicationDelegate’s -application:didReceiveRemoteNotification: method.

    Declaration

    Swift

    optional func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage)

    Objective-C

    - (void)messaging:(nonnull FIRMessaging *)messaging
        didReceiveMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage;
  • The callback to handle data message received via FCM for devices running iOS 10 or above.

    Declaration

    Swift

    optional func application(received remoteMessage: MessagingRemoteMessage)

    Objective-C

    - (void)applicationReceivedRemoteMessage:
        (nonnull FIRMessagingRemoteMessage *)remoteMessage;