so I am working in an app in flutter that is using inappwebview, this is a simple navigator in the app to allow users to access the web platform directly from a native app (A company request).
The app that is trying to be accessed has biometric authentication as an option to grant access to the user.
The problem is that the app does not have permission to access biometric credentials and i dont know how to grant them. I have added signin cappabilities to All (Release, debug and profile) stages in xcode and also the NSFaceIDUsageDescription
to the Info.plist.
This is the error that xcode shows when clicking on activate in the flutter app.
< code > ASAuthorizationController credential request failed with error: Error Domain=com. apple . AuthenticationServices . AuthorizationError Code= 1004 "(null)"
<code>ASAuthorizationController credential request failed with error: Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1004 "(null)"
</code>
ASAuthorizationController credential request failed with error: Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1004 "(null)"
The app error
The expected behavior, this is what happen then trying to access from a normal browser and click on “activate”
This is the flutter code to launch the inappwebview
< code > import 'package:flutter/material.dart' ;
import 'package:flutter_inappwebview/flutter_inappwebview.dart' ;
import 'dart:io' show Platform;
class HomePageWidget extends StatefulWidget {
const HomePageWidget ({ super. key }) ;
_HomePageWidgetState createState () = > _HomePageWidgetState () ;
class _HomePageWidgetState extends State < HomePageWidget > {
late MyInAppBrowser browser;
final settings = InAppBrowserClassSettings (
browserSettings: InAppBrowserSettings (
hideDefaultMenuItems: true ,
presentationStyle: ModalPresentationStyle. OVER_FULL_SCREEN ) ,
webViewSettings: InAppWebViewSettings (
userAgent: Platform. isAndroid
? "Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.82 Mobile Safari/537.36"
: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1" ,
isElementFullscreenEnabled: true ,
// Assuming this is the correct type
browser = MyInAppBrowser ( onBrowserExit: () {
// Handle browser exit if needed
void openBrowser () async {
await browser. openUrlRequest (
"https://linktowebapp" )) ,
// Additional logic if necessary
Widget build ( BuildContext context ) {
// Your build method as before, but replace the onPressed method:
// Modify the MyInAppBrowser class to accept a callback
class MyInAppBrowser extends InAppBrowser {
final VoidCallback onBrowserExit;
MyInAppBrowser ({ required this . onBrowserExit }) ;
print ( "Browser closed!" ) ;
onBrowserExit () ; // Call the provided callback
// The rest of your MyInAppBrowser implementation...
<code> import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'dart:io' show Platform;
class HomePageWidget extends StatefulWidget {
const HomePageWidget({super.key});
@override
_HomePageWidgetState createState() => _HomePageWidgetState();
}
class _HomePageWidgetState extends State<HomePageWidget> {
late MyInAppBrowser browser;
final settings = InAppBrowserClassSettings(
browserSettings: InAppBrowserSettings(
hideToolbarBottom: true,
hideCloseButton: true,
hideUrlBar: true,
hideTitleBar: true,
hideDefaultMenuItems: true,
presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN),
webViewSettings: InAppWebViewSettings(
userAgent: Platform.isAndroid
? "Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.82 Mobile Safari/537.36"
: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1",
cacheEnabled: true,
javaScriptEnabled: true,
isElementFullscreenEnabled: true,
));
// Assuming this is the correct type
@override
void initState() {
super.initState();
browser = MyInAppBrowser(onBrowserExit: () {
setState(() {
// Handle browser exit if needed
});
});
openBrowser();
}
void openBrowser() async {
await browser.openUrlRequest(
urlRequest: URLRequest(
url: WebUri(
"https://linktowebapp")),
settings: settings);
// Additional logic if necessary
}
@override
Widget build(BuildContext context) {
// Your build method as before, but replace the onPressed method:
return const Scaffold(
body: Center(),
);
}
}
// Modify the MyInAppBrowser class to accept a callback
class MyInAppBrowser extends InAppBrowser {
final VoidCallback onBrowserExit;
MyInAppBrowser({required this.onBrowserExit});
@override
void onExit() {
super.onExit();
print("Browser closed!");
onBrowserExit(); // Call the provided callback
}
// The rest of your MyInAppBrowser implementation...
}
</code>
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'dart:io' show Platform;
class HomePageWidget extends StatefulWidget {
const HomePageWidget({super.key});
@override
_HomePageWidgetState createState() => _HomePageWidgetState();
}
class _HomePageWidgetState extends State<HomePageWidget> {
late MyInAppBrowser browser;
final settings = InAppBrowserClassSettings(
browserSettings: InAppBrowserSettings(
hideToolbarBottom: true,
hideCloseButton: true,
hideUrlBar: true,
hideTitleBar: true,
hideDefaultMenuItems: true,
presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN),
webViewSettings: InAppWebViewSettings(
userAgent: Platform.isAndroid
? "Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.82 Mobile Safari/537.36"
: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1",
cacheEnabled: true,
javaScriptEnabled: true,
isElementFullscreenEnabled: true,
));
// Assuming this is the correct type
@override
void initState() {
super.initState();
browser = MyInAppBrowser(onBrowserExit: () {
setState(() {
// Handle browser exit if needed
});
});
openBrowser();
}
void openBrowser() async {
await browser.openUrlRequest(
urlRequest: URLRequest(
url: WebUri(
"https://linktowebapp")),
settings: settings);
// Additional logic if necessary
}
@override
Widget build(BuildContext context) {
// Your build method as before, but replace the onPressed method:
return const Scaffold(
body: Center(),
);
}
}
// Modify the MyInAppBrowser class to accept a callback
class MyInAppBrowser extends InAppBrowser {
final VoidCallback onBrowserExit;
MyInAppBrowser({required this.onBrowserExit});
@override
void onExit() {
super.onExit();
print("Browser closed!");
onBrowserExit(); // Call the provided callback
}
// The rest of your MyInAppBrowser implementation...
}