expo-unified-push
    Preparing search index...

    Class ExpoUnifiedPushModule

    The native module that is used to bridge the kotlin native code with the javascript code.

    Hierarchy

    • _default
      • ExpoUnifiedPushModule

    Indexable

    • [key: string]: any
    Index

    Constructors

    • Creates a new event emitter instance.

      Returns ExpoUnifiedPushModule

    Methods

    • Adds a listener for the given event name.

      Type Parameters

      • EventName extends never

      Parameters

      Returns EventSubscription

    • Synchronously calls all of the listeners attached to that specific event. The event can include any number of arguments that will be passed to the listeners.

      Type Parameters

      • EventName extends never

      Parameters

      Returns void

    • Get the list of Unified Push distributors available on the device. The list will always include a low-priority distributor that uses Firebase Cloud Messaging (FCM).

      Returns Distributor[]

      a list of distributor identifiers.

    • Get the distributor selected for using Unified Push. If no distributor has been selected, it will return null.

      Returns null | string

      The selected distributor identifier or null.

    • Returns a number of listeners added to the given event.

      Type Parameters

      • EventName extends never

      Parameters

      Returns number

    • Register a device for push notifications, connecting to the selected distributor.

      The returned promise will automatically be rejected if app is running inside an emulator or no distributor is selected. If you had already registered your device with a distributor, this ensures the connection is working, hence why you should always call this method on application startup. External distributors will be favored over embedded distributors.

      Parameters

      • vapid: string

        The VAPID public key that identifies the server that will be sending the push notifications. This key can be generated using the web-push package from npm. More information can be found at https://github.com/web-push-libs/web-push.

      • Optionalinstance: string

        This param is used to identify different registrations in the same device, for example if the app has an account swithcer feature, you can set this to the current user ID. This param is not mandatory. If you won't have multiple users on the same device at the same time, you can omit it.

      Returns Promise<void>

    • Removes all listeners for the given event name.

      Parameters

      • eventName: never

      Returns void

    • Removes a listener for the given event name.

      Type Parameters

      • EventName extends never

      Parameters

      Returns void

    • Select a distributor for using Unified Push. This will be saved in the device storage. You can also pass null to clear the saved distributor, but this will clear all instances registered with the distributor.

      Parameters

      • distributor: null | string

        The distributor identifier to select.

      Returns void

    • Function that is automatically invoked when the first listener for an event with the given name is added. Override it in a subclass to perform some additional setup once the event started being observed.

      Type Parameters

      • EventName extends never

      Parameters

      Returns void

    • Function that is automatically invoked when the last listener for an event with the given name is removed. Override it in a subclass to perform some additional cleanup once the event is no longer observed.

      Type Parameters

      • EventName extends never

      Parameters

      Returns void

    • Subscribe to the messages sent from the distributor background service. This callback will be called whenever the distributor sends a message to the device. It will not run if the app is terminated but notifications will still be delivered even if this callback is not registered. It will also receive error messages created when displaying notifications on the background service.

      Parameters

      • fn: Callback

        The function that will receive the distributor messages.

        This function will always receive an object with the properties action and data:

        • data: The data sent from the distributor. Varies depending on the action property.
        • action: The action that was performed by the distributor. Can be one of the following:
          • "message": A push notification was received. Data for this type is MessagePayload. The text in data.message will contain the JSON-encoded payload of the push notification if data.decrypted is true. Otherwise, it will contain the raw encrypted payload.
          • "registered": The device has been registered with a distributor. Data for this type is RegisteredPayload. This is the data that is needed for the backend to send a push notification to a specific device.
          • "unregistered": The device has been unregistered from a distributor. Data for this type is UnregisteredPayload.
          • "error": An error occurred while receiving a message from a distributor. Data for this type is ErrorPayload.

      Returns void

    • Unregister a device for push notifications. This method will remove a registration for a specific instance from the distributor. The distributor subscriber will not receive the unregistered event after calling this method.

      Parameters

      • Optionalinstance: string

        The same instance param that was used on the registerDevice method.

      Returns void