Messaging

class Messaging : NSObject

Firebase Messaging lets you reliably deliver messages at no cost.

To send or receive messages, the app must get a registration token from FIRInstanceID. This token authorizes an app server to send messages to an app instance.

In order to receive FIRMessaging messages, declare application:didReceiveRemoteNotification::fetchCompletionHandler:.

  • Delegate to handle FCM token refreshes, and remote data messages received via FCM direct channel.

    Declaration

    Swift

    weak var delegate: MessagingDelegate? { get set }
  • When set to YES, Firebase Messaging will automatically establish a socket-based, direct channel to the FCM server. Enable this only if you are sending upstream messages or receiving non-APNS, data-only messages in foregrounded apps. Default is NO.

    Declaration

    Swift

    var shouldEstablishDirectChannel: Bool { get set }
  • Returns YES if the direct channel to the FCM server is active, and NO otherwise.

    Declaration

    Swift

    var isDirectChannelEstablished: Bool { get }
  • FIRMessaging

    Declaration

    Swift

    class func messaging() -> Self

    Return Value

    An instance of FIRMessaging.

  • FIRMessagingExtensionHelper

    Use FIRMessagingExtensionHelper to populate rich UI contents for your notifications. e.g. If an image URL is set in your notification payload or on the console, call FIRMessagingExtensionHelper API to render it on your notification.

    Declaration

    Swift

    class func serviceExtension() -> FIRMessagingExtensionHelper

    Return Value

    An instance of FIRMessagingExtensionHelper that handles the extensions API.

  • Unavailable. Use +messaging instead.

  • This property is used to set the APNS Token received by the application delegate.

    FIRMessaging uses method swizzling to ensure that the APNS token is set automatically. However, if you have disabled swizzling by setting FirebaseAppDelegateProxyEnabled to NO in your app’s Info.plist, you should manually set the APNS token in your application delegate’s -application:didRegisterForRemoteNotificationsWithDeviceToken: method.

    If you would like to set the type of the APNS token, rather than relying on automatic detection, see: -setAPNSToken:type:.

    Declaration

    Swift

    var apnsToken: Data? { get set }
  • Set APNS token for the application. This APNS token will be used to register with Firebase Messaging using FCMToken or tokenWithAuthorizedEntity:scope:options:handler.

    Declaration

    Swift

    func setAPNSToken(_ apnsToken: Data, type: MessagingAPNSTokenType)

    Parameters