Class ExpoUnifiedPushModule

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

Hierarchy

  • _default<ExpoUnifiedPushModuleEvents>
    • ExpoUnifiedPushModule

Indexable

  • [key: string]: any

Constructors

  • Creates a new event emitter instance.

    Returns ExpoUnifiedPushModule

Methods

  • Adds a listener for the given event name.

    Type Parameters

    • EventName extends "message"

    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 "message"

    Parameters

    Returns void

  • Get the list of UnifiedPush 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 UnifiedPush. 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 "message"

    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: "message"

    Returns void

  • Removes a listener for the given event name.

    Type Parameters

    • EventName extends "message"

    Parameters

    Returns void

  • Select a distributor for using UnifiedPush. 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 "message"

    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 "message"

    Parameters

    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