Amplify JS API Documentation
    Preparing search index...
    onTokenReceived: OnTokenReceived

    Registers a listener that will be triggered when a token is received. A token will be received:

    1. On every app launch, including the first install
    2. When a token changes (this may happen if the service invalidates the token for any reason)

    A callback handler to be invoked with the token.

    • An object with a remove function to remove the listener.
    // Register a listener
    onTokenReceived(message => {
    doSomething(message);
    });
    // Register multiple listeners
    onTokenReceived(message => {
    doSomething(message);
    });

    onTokenReceived(message => {
    doSomethingElse(message);
    });