flutter inappwebview : "window.flutter_inappwebview.callHandler" dosn't work in ios - flutter

javascript call “ window.flutter_inappwebview.callHandler('handlerFoo') ”
version: ^5.7.2+2
android is ok,but can't use in ios;
In addition, it is found that consoleMessage is invalid under ios.
my options:
options = InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
useShouldInterceptFetchRequest: true,
),
android: AndroidInAppWebViewOptions(
useHybridComposition: true,
),
ios: IOSInAppWebViewOptions(
allowsInlineMediaPlayback: true,
),
);
enter image description here
enter image description here
by the way ,There is a very old project in which he uses webview interaction within ios:
"window.webkit.messageHandlers.openScan.postMessage({})"
How to intercept the request "window.webkit.messageHandlers.openScan.postMessage ({})" without modifying the original web page project?
Thank you very much for your help
Can you run it for me?

Related

Flutter app is crash when adding YoutubePlayer in some cases

I used youtube_player_flutter to load youtube video.But in some cases app is crash when i open the screen containing youtube video .Some time it working perfectly.
I got the below exception,
[ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel.
Code to load youtube video ,
YoutubePlayer(
controller: YoutubePlayerController(
initialVideoId: YoutubePlayer.convertUrlToId(
controller.reelsList[index].url.toString())
.toString(),
flags: const YoutubePlayerFlags(
autoPlay: false,
mute: false,
hideControls: false,
showLiveFullscreenButton: false),
),
showVideoProgressIndicator: true,
)
compileSdkVersion 33
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
i got the same trouble some weeks ago when i was implementing the same feature.
First, run on your terminal:
flutter clean
then
flutter pub get
then build your application again
This did the work for me,
By the way, i got some trouble with useHybridComposition making my app laggy on my physic device, so i've set it to false.
I've implemented this way, but i don't really think your code have any mistakes at all;
YoutubePlayer(
controller: YoutubePlayerController(
initialVideoId: videoModel.url,
flags: const YoutubePlayerFlags(
useHybridComposition: false,
mute: false,
autoPlay: false,
disableDragSeek: true,
loop: false,
isLive: false,
forceHD: false,
enableCaption: false,
showLiveFullscreenButton:
false),
),
showVideoProgressIndicator: true,
progressIndicatorColor:
colorScheme.secondary,
progressColors: progressColors,
),
Update me, we can discuss further if this doesn't work for you.

Flutter_Stripe: Apple Pay and Android Pay true does nothing

So I have configure the plugin to be able to pay with stripe with a credit card. When I turn on Apple Pay and Android Pay to true, nothing changes. What extra configuration do I have to apply? From documentation I am not able to do by myself
Using the following payment sheet without extra configuration:
// 2. initialize the payment sheet
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
// Main params
paymentIntentClientSecret: data['paymentIntent'],
merchantDisplayName: 'Flutter Stripe Store Demo',
// Customer params
customerId: data['customer'],
customerEphemeralKeySecret: data['ephemeralKey'],
// Extra params
applePay: true,
googlePay: true,
style: ThemeMode.dark,
primaryButtonColor: Colors.redAccent,
billingDetails: billingDetails,
testEnv: true,
merchantCountryCode: 'DE',
),
);
and when PaymenSheet appears, I expect a button to select android pay or apple pay based on the platform.
Probably missing basic configuration, but I am not able to find any tutorial o configuration for flutter_stripe

How to save sessionId of first login and doesn't make me login every time in inappwebview flutter

I want to write an application that makes me register from app and send post request and get response to inappwebview just like exam below
InAppWebView(
initialUrl: widget.initUrls,
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
mediaPlaybackRequiresUserGesture: false,
debuggingEnabled: true,
),
),
onWebViewCreated: (InAppWebViewController c){
_controller = c;
if(staticEmail != null && staticPass != null) {
_controller.postUrl(url: "https://xxxxxxx.com/my-account", postData: utf8.encode(
"email=${staticEmail}&password=${staticPass}&wooc_user_phone=${staticShop}&wooc_user_name=${staticShop}&woocommerce-register-nonce=5d1b626841&_wp_http_referer=/my-account/&register=Register") )
.whenComplete(() => {print("done")}).catchError((err){print("err : ${err}");
isloading = false;
});
}
},
);
and it login fine.
But when I go to another link or when I close app and login again it ask me to login again i just want to save cookie or session id that doesn't make me login every time
You can make use of the CookieManager of this flutter_inappwebview package to get and set cookies. This is a singleton that the plugin uses, you can access it via:
CookieManager.instance()

How to change **Touch the fingerprint sensor** test local_auth Flutter

I'm using the local_auth package in my flutter app. I want to make the pop-up multi-lingual, so I changed the text using AndroidAuthMessages. but I'm not able to change Touch the fingerprint sensor and Not recognized text.
Code:
AndroidAuthMessages androidAuthStrings = AndroidAuthMessages(
cancelButton: I18n.of(context).cancel,
signInTitle: I18n.of(context).signInTitle,
fingerprintRequiredTitle: I18n.of(context).fingerprintRequiredTitle,
fingerprintHint: '',
fingerprintNotRecognized:I18n.of(context).fingerprintNotRecognized,
fingerprintSuccess: I18n.of(context).fingerprintSuccess,
goToSettingsButton: I18n.of(context).goToSettingsButton,
goToSettingsDescription: I18n.of(context).goToSettingsDescription,
);
bool didAuthenticate = await localAuth.authenticateWithBiometrics(
localizedReason: I18n.of(context).localizedReason,
useErrorDialogs: true,
stickyAuth: true,
sensitiveTransaction: true,
androidAuthStrings: androidAuthStrings,
);
Image:
https://i.stack.imgur.com/Xdko6.png
Set localizedReason: '' value when you call local_auth authenticate method.
await localAuthentication.authenticate(
androidAuthStrings: androidAuthStrings,
localizedReason: "Your text", // Set value here
useErrorDialogs: true,
stickyAuth: false,
biometricOnly: true
);
Set the value of fingerprintHint: '', to whatever you want.
Example fingerprintHint: 'Touch to Login',

flutter webview disallowed user agent

I am trying to openning sign-in google with webview in flutter application. I installed flutter_inappwebview: ^3.1.0 and this is my code:
child: InAppWebView(
initialUrl: url.toString(),
initialHeaders: {},
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
userAgent:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
debuggingEnabled: true,
)),
but when i open google sin in page i got this error:
Using webview_flutter package you can fix the problem by adding userAgent: 'random', in the web view constructor. So, it will look like this:
WebView(
initialUrl: 'https://abdulrazakzakieh.com/',
userAgent: 'random',
)
change userAgent to random like -> userAgent: "random". works perfectly! but then it will most likely low end mobile interface for google page. that's the only drawback. else works perfectly fine !
For my case, It worked for this-
InAppWebView(
initialUrlRequest: URLRequest(url: Uri.parse("www.myurl.com")),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(userAgent: "random"),)
...)