FIRMessagingDelegate

@protocol FIRMessagingDelegate <NSObject>

A protocol to handle token update or data message delivery from FCM.

  • This method will be called once a token is available, or has been refreshed. Typically it will be called once per app start, but may be called more often, if token is invalidated or updated. In this method, you should perform operations such as:

    • Uploading the FCM token to your application server, so targeted notifications can be sent.

    • Subscribing to any topics.

    Declaration

    Objective-C

    - (void)messaging:(nonnull FIRMessaging *)messaging
        didReceiveRegistrationToken:(nonnull NSString *)fcmToken;
  • This method is called on iOS 10+ devices to handle data messages received via FCM direct channel (not via APNS). For iOS 9 and below, the direct channel data message is handled by the UIApplicationDelegate’s -application:didReceiveRemoteNotification: method. You can enable all direct channel data messages to be delivered in FIRMessagingDelegate by setting the flag useMessagingDelegateForDirectMessages to true.

    Declaration

    Objective-C

    - (void)messaging:(nonnull FIRMessaging *)messaging
        didReceiveMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage;