Flutter lost focus on phone if Android Auto runs Waze - flutter

I launch Waze from App with this code with button click:`enter code here
void launchWaze(String lat, String lng) async {
Uri url = Uri.parse(
'https://waze.com/ul?ll=$lat,$lng&navigate=yes');
Uri fallbackUrl =
Uri.parse('https://waze.com/ul?ll=$lat,$lng&navigate=yes');
try {
bool launched = await launchUrl(
url,
mode: LaunchMode.externalApplication, // or externalNonBrowserApplication,
);
} catch (e) {
await launchUrl(fallbackUrl);
}
}
Waze launched from app, on Android Auto starts and route is fine, but the focus not in my app anymore so I can not use the app to start other location, only a text you use Waze on Android Auto. Back button not working...
Is there any solution to navigate on Android Auto and use the app on phone the same time?

Related

how to change app icon and name dynamically in flutter(ios/andorid) both

i want to change app icon and name dynamically in flutter for ios and android both i already know about flutter_dynamic_icon but its work only for ios but i want to change for android also
is possible to change app icon from local storage or from server
for ex. user select image from gallery/local or click via camera and set to app icon?
try {
if (await FlutterDynamicIcon.supportsAlternateIcons) {
await FlutterDynamicIcon.setAlternateIconName("photos");
print("App icon change successful");
return;
}
} on PlatformException {} catch (e) {}
print("Failed to change app icon");
...
// set batch number
try {
await FlutterDynamicIcon.setApplicationIconBadgeNumber(9399);
} on PlatformException {} catch (e) {}
// gets currently set batch number
int batchNumber = FlutterDynamicIcon.getApplicationIconBadgeNumber();

Flutter - Connectycube_flutter_callkit not working in the background or terminated

i'm using connectycube for receiving calls but when i accept call while is in the background like the image below
it navigates me the home page but not the call here is the code
void videocaller( var friendName){
Uuid uuid = Uuid();
CallEvent callEvent = CallEvent(sessionId: uuid.v4() + "1", callType: 1, callerId: 0,
callerName: friendName, opponentsIds:{1234});
Future<void> _onCallAccepted(CallEvent callEvent) async {
_joinMeetingVideo(friendName);
}
Future<void> _onCallRejected(CallEvent callEvent) async {
}
Future onCallRejectedWhenTerminated(CallEvent? callEvent) async {
}
Future onCallAcceptedWhenTerminated(CallEvent? callEvent) async {
_joinMeetingVideo(friendName);
}
ConnectycubeFlutterCallKit.onCallRejectedWhenTerminated = onCallRejectedWhenTerminated;
ConnectycubeFlutterCallKit.onCallAcceptedWhenTerminated = onCallAcceptedWhenTerminated;
ConnectycubeFlutterCallKit.instance.init(
onCallAccepted: _onCallAccepted,
onCallRejected: _onCallRejected,
);
ConnectycubeFlutterCallKit.showCallNotification(callEvent);
ConnectycubeFlutterCallKit.setOnLockScreenVisibility(isVisible: true);
}
i tried it with getx to navigate to jitsi call but it does not work
actually the problem is that jitsi function [_joinMeetingVideo(friendName);] is not a page where i can navigate to it's a function so it can't be executed enless the app is open this why it opens the home page of the app but not the video call itself but unfortunately i could't find a solution for this issue. any ideas ??

Login with facebook works on real phones but not emulators, it started happening with the new emulator update

This code works on real phones but not on emulators
I use flutter_facebook_auth. This exact code worked fine before emulator update and it's still works on real devices, but on emulator it just do nothing after coming back from fb login page.
static Future<User?> signInWithFacebook() async {
try {
//Trigger the sign-in flow
final LoginResult loginResult =
await FacebookAuth.instance.login(permissions: [
'public_profile',
'email',
'user_friends',
]);
if (loginResult.status == LoginStatus.success) {
print('success');
facebookAuthCredential =
FacebookAuthProvider.credential(loginResult.accessToken!.token);
print(loginResult.accessToken?.token);
Credential = await FirebaseAuth.instance
.signInWithCredential(facebookAuthCredential);
print('here 1');
UserData = await FacebookAuth.instance.getUserData(
fields:
"name,email,picture.width(400),birthday,friends,gender,link");
print(UserData);
} else {
print(loginResult.message);
error = loginResult.message!;
}
user = Credential.user;
await user
?.updatePhotoURL(UserData['picture']['data']['url'])
.then((value) {
print('success' + UserData['picture']['data']['url']);
});
return Credential.user;
} on FirebaseException catch (e) {
error = e.code;
print(e.code);
}
}
}
In the above code the app flow stops or freezes on
Credential = await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
What I have tried is:
Tried other emulators, different api's and models.
I tried adding new release and debug keyhashes to both facebook and firebase
I tried increasing emulator ram and cpu cores etc
I tried refreshing fb sdk and json and other dev dependencies
I tried flutter clean
I tried Invalidate Caches
I uninstalled android studio and all of it's components and install again
Is this happening with just me or it's a bug in the new emulator update?
It's been 12 hours, can somebody please help and check if their updated emulator is working with fb login
I solved it by downgrading emulator version to 31.2.9,
Here is emulator_archive how you can do it:

Flutter-web:url_launcher_web not launching email in browser

I've added a feature of sending feedback through email for my flutter web app. This is my code :
static void launchEmail(String subjectLine) async {
const emailId = Constants.ARUDITO_EMAIL;
print('opening email app for uploading content');
String url = "mailto:$emailId?subject=$subjectLine";
if (kIsWeb) {
if (await webLauncher.UrlLauncherPlugin().canLaunch(url)) {
await webLauncher.UrlLauncherPlugin().launch(
url,
useWebView: true,
enableDomStorage: true,
enableJavaScript: true,
useSafariVC: true,
webOnlyWindowName: 'Arudito',
headers: null,
universalLinksOnly: false,
);
} else {
throw 'Could not open an email app';
}
} else {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not open an email app';
}
}
}
pubspec.yaml includes :
dependencies:
flutter:
sdk: flutter
url_launcher: ^5.4.2
url_launcher_web: ^0.1.3+1
This code is not launching email in a web browser. It only opens a new tab. However, it is launching on selecting mail app in Windows. Can someone please tell what is the issue here?
I had exactly the same problem. I found a useful answer in another StackOverflow post.
There it is mentioned that if you just omit the canLaunch check and instead wrap the launch in a try-catch block it works on Flutter Web. I just tried, and it works nicely.
Btw, there is also a quite new Link widget in the url_launcher package, which makes it possible to create proper web links (including right-click support).
I had the exact issue. Click on any email link will just opens a new blank tab. That's it.
Took me hours to figure out.
Open Mail app on mac, settings, general, and there's an option for default email reader. It was selecting chrome. Change it to a real email client and it works as expected now.

I can't receiving notifications when the app is closed or swiped away on huawei device?

I'm using onsignal notifications with my flutter app,I've tested my app on three Samsunge devices and notifcations working perfectly in all these devices when the app on foreground, background, and also when I swiped it away.
after that I tested the app on huawei device which using EMUI 9.0.1 Os
the notifications only works if the app is active or on background
if I swiped it away I can't receiving any notifications.
Any help would be greatly appreciated, I've been struggling with this for a long time. I'll post my code for setting onesignal below
Future<void> initPlatformState() async {
if (!mounted) return;
OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.none);
OneSignal.shared.setRequiresUserPrivacyConsent(true);
OneSignal.shared.consentGranted(true);
var settings = {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.promptBeforeOpeningPushUrl: true
};
OneSignal.shared.setNotificationReceivedHandler((notification) {
this.setState(() {
print('Notifiaction received');
});
});
OneSignal.shared
.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
this.setState(() {
newUrl = result.notification.payload.additionalData['url'].toString();
});
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => WebNotification(newUrl)));
});
// NOTE: Replace with your own app ID from https://www.onesignal.com
await OneSignal.shared
.init("xxxx-xxxx-xxxx-xxxx-xxxx", iOSSettings: settings);
OneSignal.shared
.setInFocusDisplayType(OSNotificationDisplayType.notification);
OneSignal.shared.inFocusDisplayType();
}
You need to set up a service extension. Take a look at our docs on Background Notifications. Also, consider Notification Behavior when designing your implementation
make sure you sue latest version of onesignal
for huwaii use HMS if possible ( onesignal support HMS )
In your root build.gradle, under buildscript, add the following 2 new lines to your existing repositories and dependencies sections
buildscript {
repositories {
// ...
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
// ...
// OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.8, 0.99.99]'
}
}
Add the following to the top of your app/build.gradle
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
you need to make user add your app to ignore battry optmztion in huwaii it is (protacted app )
in flutter you can make button and attach it to the app setting ( use these plugin https://pub.dev/packages/app_settings)