Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
[OWP-41] Example app changes to include Biometric authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
swetha-gadiraju committed Oct 14, 2024
1 parent 60f5c67 commit 4351f23
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package com.onegini.mobile.onegini_example
import android.content.Intent
import com.onegini.mobile.sdk.flutter.handlers.BrowserRegistrationRequestHandler
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity : FlutterActivity() {
class MainActivity : FlutterFragmentActivity() {

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
Expand All @@ -14,4 +15,4 @@ class MainActivity : FlutterActivity() {
BrowserRegistrationRequestHandler.handleRegistrationCallback(intent.data!!)
}
}
}
}
4 changes: 3 additions & 1 deletion example/lib/ow_broadcast_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:onegini/events/onewelcome_events.dart';
import 'package:onegini/onegini.dart';
import 'package:onegini_example/subscription_handlers/biometric_subscriptions.dart';
import 'package:onegini_example/subscription_handlers/browser_registration_subscriptions.dart';
import 'package:onegini_example/subscription_handlers/create_pin_subscriptions.dart';
import 'package:onegini_example/subscription_handlers/custom_registration_subscriptions.dart';
Expand All @@ -29,8 +30,9 @@ class OWBroadcastHelper {
BuildContext context) {
var pinAuthSubs = initPinAuthenticationSubscriptions(context);
var fingerprintSubs = initFingerprintSubscriptions(context);
var biometricSubs = initBiometricSubscriptions(context);

return pinAuthSubs + fingerprintSubs;
return pinAuthSubs + fingerprintSubs + biometricSubs;
}

static void stopListening(List<StreamSubscription<OWEvent>>? subscriptions) {
Expand Down
27 changes: 27 additions & 0 deletions example/lib/subscription_handlers/biometric_subscriptions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:onegini/events/biometric_event.dart';
import 'package:onegini/events/onewelcome_events.dart';
import 'package:onegini_example/ow_broadcast_helper.dart';
import 'package:onegini/callbacks/onegini_biometric_callback.dart';

// Event Subscriptions related to biometric prompt
List<StreamSubscription<OWEvent>> initBiometricSubscriptions(
BuildContext context) {

var openSub = _getOpenBiometricSub(context);
var closeSub = _getCloseBiometricSub(context);
return [openSub, closeSub];
}

StreamSubscription<OWEvent> _getOpenBiometricSub(BuildContext context) {
return OWBroadcastHelper.createStream<StartBiometricAuthEvent>().listen((event) {
OneginiBiometricCallback().showBiometricPrompt("Biometric Authentication", "Authenticate user", "Use PIN");
});
}

StreamSubscription<OWEvent> _getCloseBiometricSub(BuildContext context) {
return OWBroadcastHelper.createStream<FinishBiometricAuthEvent>().listen((event) {
});
}

0 comments on commit 4351f23

Please sign in to comment.