I am using url launcher package to run another app using my flutter desktop app with the following code:
launchAutoCadApp() async {
SharedPreferencesManager prefs = SharedPreferencesManager();
final String filePath = (await prefs.getCUrl()).toString();
final Uri uri = Uri.file(filePath);
if (!File(uri.toFilePath()).existsSync()) {
throw Exception('$uri does not exist!');
}
if (!await launchUrl(uri)) { //This is where my another desktop app is being initiated
throw Exception('Could not launch $uri');
}
}
I want to initiate my another desktop app with admin privilages from my flutter desktop app i.e a popup should display like this before launching my app.
I have gone through this answer on stackoverflow, but this doesn't fullfil what I want.
Related
I created a flutter web app that creates an image and generates the base64 data. so I used AnchorElement in the HTML package to download the image to the client, it works on mac and windows but when I want to be downloaded on mobile nothing happen at all.
any clue?
code:
Future<void> downloadImage(Uint8List data8) async {
try {
final base64data = base64Encode(data8);
final a = html.AnchorElement(href: 'data:image/jpeg;base64,$base64data');
a.download = 'image.jpg';
a.click();
a.remove();
} catch (e) {
print(e);
}
}
In general mobile apps need rights to access certain resource, e.g. access the network.
Search for entitlement on iOS like this and manifest on Android.
You need to set these rights in the iOS or Android project. Without this rights, access gets simply denied.
I would like to create an app in Flutter. The web version contains a button that should open version of android or IOS app according user platform if mobile version of app was installed (like an app install or open banner).
How should I detect is app installed in web flutter?
update:
I tried below code using import 'package:universal_html/html.dart' pakage:
window.location.href = (defaultTargetPlatform ==
TargetPlatform.android)
? 'https://play.google.com/store/apps/details?id=com.amazon.mShop.android.shopping'
: 'https://apps.apple.com/us/app/amazon-shopping/id297606951';
But this just open the store. I'm looking for a solution to open app directly if it was installed.
If this is fine for you, you can use an URL launcher. This way it opens the App store or play store and the user can either download the App or open it.
For Example flutter has a package that does most of this work:
https://github.com/Purus/launch_review
LaunchReview.launch(androidAppId: "yourpackagename", iOSAppId: "appid");
You just need to pass your package name and on ios your app ID
You could also use an URL Launcher:
https://pub.dev/packages/url_launcher
The code would be similar to this:
_launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
}
else {
throw 'Could not launch $url';
}
}
URL Example
try {
launch("market://details?id=" + appPackageName);
} on PlatformException catch(e) {
launch("https://play.google.com/store/apps/details?id=" + appPackageName);
} finally {
launch("https://play.google.com/store/apps/details?id=" + appPackageName);
}
Note this code needs to be adapted
Also see this tutorial for help: https://flutteragency.com/open-appstore-playstore-url-in-flutter/
Edit:
If you want to directly open another app you can use something like this:
https://pub.dev/packages/external_app_launcher/
flutter pub add external_app_launcher
The Code would look like this then:
await LaunchApp.openApp(
androidPackageName: 'net.pulsesecure.pulsesecure',
iosUrlScheme: 'pulsesecure://',
appStoreLink: 'itms-apps://itunes.apple.com/us/app/pulse secure/id945832041',// openStore: false
);
// Enter the package name of the App you want to open and for iOS add the URLscheme to the Info.plist file.
// The `openStore` argument decides whether the app redirects to PlayStore or AppStore.
// For testing purpose you can enter com.instagram.android
More infos regarding implementation and additional setup infos you can find here: https://pub.dev/packages/external_app_launcher in the Readme
I have created a flutter app which adds calendar events to user's google calendar using the google Calendar API. The app is doing the job but I have the following problem.
The app has initializeCalendarApi(); function(code attached below) in the initState() function which authenticates the user using Google Oauth. This is done by redirecting the user to user's browser where they select their Google account and click Allow to allow app to access their calendar. The problem is, once the authentication is done, the browser window is not closed automatically and the user has to close the browser app and shift to the flutter app manually which is bad for a production app.
How do I resolve this to make sure the user automatically gets back to the flutter app after clicking Allow.
Future<void> initializeCalendarApi() async {
var _clientID = new ClientId(Secret.getId(), "");
const _scopes = const [calendar.CalendarApi.calendarScope];
await clientViaUserConsent(_clientID, _scopes, prompt)
.then((AuthClient client) async {
CalendarClient.calendar = calendar.CalendarApi(client);
});
}
Image shows the final Page Obtained in browser after Oauth has been completed. I want to return my flutter app after successful authentication rather than this window opened in browser.
I'm trying to create a Login through Facebook button in my Flutter project using Firebase. I added all the things Facebook asked and I have also set my app in Live mode. But when I try to Login, it says
App not setup: This app is still in development mode.
Here's the code I've used in my flutter project:
Future<UserCredential> _signInWithFacebook() async {
final AccessToken result = await FacebookAuth.instance.login();
final FacebookAuthCredential facebookAuthCredential =
FacebookAuthProvider.credential(result.token);
return await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
}
How do I solve this?
I have this code:
import 'package:url_launcher/url_launcher.dart';
...
await launch("https://example.org/bigprizes");
It launches a web view within the app on iOS. Instead, I want it to launch in Safari or some other external browser of the user's choice. Is there a way to do that in Flutter?
Look at Step 4 in https://www.digitalocean.com/community/tutorials/flutter-url-launcher
await launch("https://example.org/bigprizes", forceSafariVC: false);
url_launcher plugin (https://pub.dev/packages/url_launcher) has methods launchUrl() and launchUrlString() which both has a property mode where you can specify how the app will open the URL. More details on the Launch mode documentation
Basically you can call it like this:
static Future<void> launchURL(String url) async {
if (await canLaunchUrlString(url)) {
// Passes the URL to the OS to be handled by another application.
await launchUrlString(url, mode: LaunchMode.externalApplication);
} else {
throw 'Could not launch $url';
}
}
check this package https://pub.dev/packages/flutter_linkify it's may be useful for your project