Event handling
The Flutter Plugin exposes a StreamController
over which we broadcast the Mobile SDK related events that should be handled. It is up to the user to decide how to integrate this functionality within their application structure.
Each event that we expose is an extension of an OWEvent and may contain additional event related information within their attributes:
Obtaining the StreamController
The plugin exposes one main StreamController
over which the different Mobile SDK related events are sent. The controller can be obtained by accessing the variable through:
var owEventController = Onegini.instance.owEventStreamController;
Listening to events
A developer can decide to use one listener or add and handle specific listeners for each event based on their preference. In the following example, we will respond to one specific event, the OpenPinCreation
event, which can occur during the user registration flow.
var owEventController = Onegini.instance.owEventStreamController;
// We filter on the desired event
StreamSubscription<OWEvent> openPinSubscription = owEventController.stream.where((event) => event is OpenPinCreationEvent).cast<OpenPinCreationEvent>().listen((event) {
// Your logic to handle the open pin registration event
// For example navigate to a new screen where a user can fill in their pin
});
// ... additional logic for pin registration
// start the registration flow
await Onegini.instance.userClient.registerUser(
identityProviderId,
["read"],
);
// after finishing close the listener again
openPinSubscription.cancel();
Event overview
Each event that we expose is an extension of an OWEvent
and may contain additional event related information within their attributes:
OWEvent | Attribute(s) | Scenario |
---|---|---|
HandleRegisteredUrlEvent | String url | Registration with Browser IDP |
InitCustomRegistrationEvent | OWCustomInfo, customInfo, String providerId | Registration with custom IDP |
FinishCustomRegistrationEvent | OWCustomInfo, customInfo, String providerId | Registration with custom IDP |
OpenFingerprintEvent | Authenticate using Fingerprint | |
CloseFingerprintEvent | Authenticate using Fingerprint | |
ShowScanningFingerprintEvent | Authenticate using Fingerprint | |
nextFingerprintAuthenticationAttempt | Authenticate using Fingerprint | |
OpenAuthOtpEvent | String message | Mobile authentication with OTP |
CloseAuthOtpEvent | Mobile authentication with OTP | |
OpenPinCreationEvent | Create Pin | |
ClosePinCreationEvent | Create Pin | |
PinNotAllowedEvent | auto$ error | Create Pin |
OpenPinAuthenticationEvent | Authenticate using Pin Flow | |
ClosePinAuthentication | Authenticate using Pin Flow | |
NextPinAuthenticationAttemptEvent | OWAuthenticationAttempt authenticationAttempt | Authenticate using Pin Flow |