Skip to content

Callbacks⚓︎

The app will receive callbacks from the Mobile SDK for providing feedback to the user or requesting their input.

Android⚓︎

To listen for callbacks from the mobile SDK, implement the NextAuthObserver and register your observer with the mobile SDK. Do not forget to unregister when done.

... implements NextAuthObserver {

    //register observer
    NextAuth.getNextAuth().addObserver(this);

    //unregister observer
    NextAuth.getNextAuth().removeObserver(this);

    @Override
    public void onCallback(Callback callback) {
        //TODO implement logic
    }

}

Optionally you can also extend the AbstractCallbackHandler and directly listen for specific callbacks

... extends AbstractCallbackHandler implements NextAuthObserver {
    //register observer
    NextAuth.getNextAuth().addObserver(this);

    //unregister observer
    NextAuth.getNextAuth().removeObserver(this);

    @Override
    public void onCallback(Callback callback) {
        callback.trigger(this)
    }

    @Override
    public void onFlowUpdate(SecondFactor callback) {
         //TODO implement logic
    }

    ...
}
Method When Expected Response
FlowUpdate The flow had been updated. Provide the user's input if the flow's State is WAIT_FOR_INPUT, depending on CurrentInteraction. See Interactions for more details.
SessionUpdate A session has been updated.
AccountUpdate An account has been updated.
AccountDeleted An account has been deleted.
TokenResult A token as a result of the getToken() call.
RetrievedMessages The list of messages received from the Message Center triggered by a retrieveMessages() call.
Error An error that is not related to a flow occurred.
Panic An unrecoverable error occurred.

iOS⚓︎

On iOS, the Mobile SDK has three mechanisms to notify the application when user interaction is required or when an entity has been updated. The former is implemented through the common delegate pattern1, while the latter broadcasts notifications through NSNotificationCenter2. Finally, flow updates are available as a Combine Publisher

Delegate⚓︎

Whenever the Mobile SDK requires some interaction from the user, it will call the relevant method on its configured delegate. It is therefore important that include a class in your app which conforms to the NextAuthDelegate. You should also ensure that you assign an instance of this class to NextAuth.default.delegate. Given that the delegate methods will need to interact with the UI, one possible approach is to build a view controller which will always be present in the view hierarchy and have it conform to this protocol.

Method When
didReceive The Mobile SDK returns the requested upstream token.
didReturn An error occurs which should be displayed to the user.
didThrow The Mobile SDK encounters a fatal exception.

Notifications⚓︎

The following notification will be broadcasted on the listed event. When posting the notification, the updated instance will be included and is therefore accessible through NSNotification.object.

Notification When
NotificationNames.accountUpdate An account has been updated (or deleted, before Mobile SDK v1.8.0).
NotificationNames.accountDelete An account has been deleted (available from Mobile SDK v1.8.0).
NotificationNames.sessionUpdate The status of a session has changed.

Publishers⚓︎

The following Combine publishers will deliver elements to subscribers, enabling you to build event-processing chains.

Publisher When Expected Response
FlowService.flowPublisher The flow had been updated. Provide the user's input if the flow's state is WAIT_FOR_INPUT, depending on currentInteraction. See Interactions for more details.