FirebaseMessaging Framework Reference

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:(nullable NSString *)fcmToken;
  • This method will be called once the registration is created or refreshed. When auto init is enabled, it will be automatically called once per app start, but may be called more often, if registration is invalidated or updated.

    Furthermore, this method also serves as the callback for a direct call to registerWithCompletion. 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
        didReceiveRegistration:(nullable NSString *)installationId;

    Parameters

    messaging

    The Firebase Messaging instance.

    installationId

    The Firebase Installation ID of the current app instance.

  • This method will be called once the unregistration is been successfully unregistered from FCM via a call to unregisterWithCompletion.

    This method confirms that the specified FID is no longer active for receiving FCM messages. In this method, you should consider notifying your backend server about the unregistration.

    Declaration

    Objective-C

    - (void)messaging:(nonnull FIRMessaging *)messaging
        didUnregister:(nonnull NSString *)installationId;

    Parameters

    messaging

    The Firebase Messaging instance.

    installationId

    The Firebase Installation ID of the current app instance that was unregistered with FCM.