I am using flutter_webview_plugin: ^0.3.11
This is my code
Widget build(BuildContext context){
return WebviewScaffold(
url: glbPhotoURL,
withJavascript: true,
scrollBar : true,
withZoom: true
)
url: glbPhotoURL => here glbPhotoURL is a URL that I am passing
When I am using any normal URL it is running fine (like http://www.google.com, http://youtube.com"
Even url like - https://youtu.be/o5UPfG1eIw4 is running fine
But when I am using any google photo url (short url) it is throwing an error net::ERR_UNKNOWN_URL_SCHEME for eg - https://photos.app.goo.gl/FkQenAD8kQQc4TSr6
If I am using the expanded URL it shows the pictures -https://photos.google.com/share/AF1QipNItZG3Cg_hn9__2QnuVh3nNMbRuGxQaQSWZ76qni7L7h0ORbauolcH3AKe0MOnEA?
key=emc1Mk1CenRJRjloMjV5V1AzcmczNUprcGFsbmR3
Please help me resolve the issue
As of now I am running it on Android physical device.
Google Photos uses Firebase Dynamic Links. I suggest launching the link externally. I encountered a similar error on Android before, when Firebase Dynamic Links are being forced to be loaded in a WebView. FDLs are expected to be handled by Google Play Services in Android. But since the WebView doesn't know what to do with the link it's forced to display, the WebView returns "net::ERR_UNKNOWN_URL_SCHEME" error.
Open the link externally by using url_launcher. Use RegEx to filter intent URLs and check if the URL can be launched and be handled externally (outside the app).
var yourURL = "URL goes here";
// Check if URL contains Google Photos URL
yourURL.contains(RegExp('^https://photos\.app\.goo\.gl/.*$')){
// Check if the URL can be launched
if (await canLaunch(yourURL)) {
await launch(yourURL);
} else {
print('Could not launch $yourURL');
}
}
Related
I just released my first app and It has a button in it that takes you to a website.
A user just sent me this:.
I tried googling Google's secure browsers policy but not much info is coming up.
how can I make my app comply with this policy? I think the button opens a browser in app (I use duckduckgo as my default browser and haven't had an issue)
is it just a case of opening a browser and then heading to the website when the button is pressed?
my code to open the website is:
_launchURL() async {
const url = 'https://www.thiswebsite.com';
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
throw 'Could not launch $url';
}
}
thanks so much and any help would be greatly appreciated
Google is trying to make sure, you open this window in an actual new browser window, not in a webview still under the control of your application.
Your code should open an external browser.
Maybe the user has no browser installed on their device? Maybe their default browser is some exotic thing not recognized by Google?
If you are using the latest version of url_launcher (currently 6.1.8) there is not a lot more you can do.
You could force the app to take the external browser, not the in-app webview:
await launchUrl(_url,mode: LaunchMode.externalApplication);
But that should be what happens anyway. If your version is up to date, ask your user, what browser they use. Be prepared to tell them that they need to use another one.
I want to open Google calendar app more specifically the create event page in the app from my another flutter app.
I am using the URL launcher package but it opens the app in chrome
What change should I make in the URL so that the add event page opens directly in the google calendar app.
Currently my URL looks like below
https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda
My code for that part is as below
if (await canLaunchUrl(Uri.parse('https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda'))) {
await launchUrl(
Uri.parse('https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda'),
mode: LaunchMode.externalApplication);
} else {
throw 'Could not launch URL';
}
rathe than using a HTTP request, you could use googleapis package from https://pub.dev which has inbuilt methods to create Google Calender events directly within the Calender app.
Check package and documentation here.
Happy coding!
I'm Loading the web URL inside the webview, all URL is working fine. But when I try to load the Paypal screen that time getting a problem. PayPal screen successfully loading when I try from the mobile device. But when I try to load the same screen from a web Browser it's shows Paypal refused to connect. I'm doing web development using flutter. Other web site loading fine. only got the issue in Paypal.
Below url i'm trying to laoding
https://www.paypal.com/connect//flowEntry=static&client_id=AYcri***********&redirect_uri=${_redirectUrl}&scope(0)=email&scope(1)=openid&response_type=code#
below is the sample that works on mobile but does not work in the web browser
WebView(
javascriptMode: web.JavascriptMode.unrestricted,
navigationDelegate: (web.NavigationRequest request) {
// This can intercept any navigation within the WebView.
if (request.url.startsWith(_redirectUrl)) {
// final startIndex = request.url.indexOf('code=');
String tokenPath = request.url.split("code=")[1];
if (tokenPath.contains("&scope=")) {
token = tokenPath.split("&scope=")[0];
}else{
token = tokenPath;
}
print(token);
Get.back(result: token);
return web.NavigationDecision.prevent;
}
return web.NavigationDecision.navigate;
},
onWebViewCreated: (web.WebViewController webViewController) {
webViewController = webViewController;
webViewController.loadUrl("https://www.paypal.com/connect//flowEntry=static&client_id=AYcri***********&redirect_uri=${_redirectUrl}&scope(0)=email&scope(1)=openid&response_type=code#",);
},
);
N.B I know the Web view library is not supported for Web, I used an extra plugin that helps to support the web.
How can I solve this issue? any suggestion?
PayPal does not support webviews; they should not be used for either mobile or web.
Instead, for mobile: "launch the PayPal web page within the system browser or an approved browser-view mechanism such as Safari View Controller on iOS or Chrome Custom Tabs on Android."
(Once you have code that opens a Safari View Controller / Chrome Custom Tab that works on mobile, it's possible there exists some plugin that will emulate and open a new browser tab when the same flutter code is run from web but I can't speak to that)
await launchUrl(
Uri.parse(
'https://www.facebook.com/$fbid',
),
mode: LaunchMode.externalApplication);
I have this launch url mode. The address works when I use it on my browser however, it does not when I use it inside the Flutter app. It says The link you followed may be broken, or ....
Twitter works fine but Instagram and FB are the ones that cause the error. I feel like something must be done for meta apps that I am missing right now. How can I fix this?
if (Platform.isAndroid) { var fbUrl = "fb://facewebmodal/f?href=" + "https://www.facebook.com/$fbid "; //for android launchFacebook(fbUrl, "https://www.facebook.com/$fbid"); }
I have a site that contains a Facebook Messenger API that works on browsers, but it does not work in Flutter WebView !
i tried to use url_launcher using this Code :
await launch(
request.url,
forceWebView: true,
enableJavaScript: true,
);
also i tried to play around settings in launch by updating some option like chenging forceWebView: true but it is not working !
output error :
PlatformException (PlatformException(ACTIVITY_NOT_FOUND, No Activity found to handle intent { intent://user/100272608460963/?intent_trigger=mme&ref=__chat_plugin_automation_ref_&nav=discover&source=customer_chat_plugin&source_id=1507329&metadata=%7B%22referer_uri%22%3A%22https%3A%5C%2F%5C%2Ffarmasi-iq.net%5C%2Fdemo%5C%2F%22%7D#Intent;scheme=fb-messenger;package=com.facebook.orca;end }, null, null))
the URL that contain the Messenger Plug-In so you can try it , it is working in any browser apps but not in WebView !
The error Happen when Pressing this black button , The user must be transferred to the Messenger application