My app performs some checks inside main() function, before runApp( MyApp());, most important is load app configuration from Firebase. If failed, there's no any way to run not configured app. So I want to show message box saying "app configuration load failed", then after user press OK, exit app.
What is preferred way to exit app in that case? I need it working on iOS and Android.
If you need UI, I would suggest still calling runApp but on a different widget:
if(success){
runApp(MyApp());
} else {
runApp(ErrorApp());
}
For closing a flutter app programmatically, the best way is using SystemNavigator.pop() but if that didn't work, you can try exit(0).
Related
I was developing a video call application, and I want to show incoming calls.
When The phone is in the foreground I was able to show a full screen in both android and ios.
and when the app is minimized, in android I achieved it by bringing the app to foreground and navigate to the invitation screen.
but in ios, I couldn't do that. I tried URL scheme but, URL scheme opens the app from other app. when I try to call in the app it throws the following exception.
Runner[4647:51243] [default] Failed to open URL exampleapp://: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.exampleapp" failed." UserInfo={BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000acabe0 {Error Domain=FBSOpenApplicationErrorDomain Code=3 "Application com.exampleapp is neither visible nor entitled, so may not perform un-trusted user actions." UserInfo={BSErrorCodeDescription=Security, NSLocalizedFailureReason=Application com.exampleapp is neither visible nor entitled, so may not perform un-trusted user actions.}}, NSLocalizedDescription=The request to open "com.exampleapp" failed., FBSOpenApplicationRequestID=0x46fb, NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Application com.exampleapp is neither visible nor entitled, so may not perform un-trusted user actions"
I searched online but couldn't find anything helpful.
How to show a full-screen incoming call when the app is in background in ios, like WhatsUp?
I guess that is only possible using IOS Call-Kit, Try to explore IOS Call-Kit
Else there is no solution for that
I am developing an app which uses an embedded system connected to through Bluetooth to an embedded device and I want the app to run a function when the device sends a signal.
The issue is that I cannot keep the app open all the time and thus need the app to keep running in the background and keep listening for the signal send by the embedded device so that it can run the function I want.
I have seen the following questions :
How to run flutter app in background continually?
How can I make my flutter app run in background without stopping?
How to create a service in Flutter to make an app to run always in background?
and many more and so far nothing seems to work.
I have written this code for now :
Future<void> _run_app_in_background() async {
final config = FlutterBackgroundAndroidConfig(
notificationTitle: 'MEDICA',
notificationText:
'MEDICA is running in the background',
notificationIcon: AndroidResource(name: 'background_icon'),
notificationImportance: AndroidNotificationImportance.Default,
);
var hasPermissions = await FlutterBackground.hasPermissions;
hasPermissions = await FlutterBackground.initialize(androidConfig: config);
final backgroundExecution =
await FlutterBackground.enableBackgroundExecution();
}
but it seems to be doing nothing and the same with other packages.
So how can I make my app run in background to keep listening for the Bluetooth data sent by device.
Edit:I want this to run on both Android and iOS and if possible maybe someone can suggest me another framework apart from Flutter (in comments maybe) and I can search the internet for the same.
#HrishabhNayal Hello bro Try this way!
https://medium.com/dlt-labs-publication/flutter-run-code-in-the-background-461b4d6c635b
I am trying to pass a parameter to another application.
I am using cordova-plugin-app-launcher to launch the other application.
Both applications are wrapped by Cordova and only are available on Android.
In this moment I don't have access to the code of the second application which is launched, so I can't test a solution right now.
I saw the GitHub documentation talks about extras, and for the launch part would be something like this:
window.plugins.launcher.launch({uri:'fb://profile', extras: [{"name":"param1", "value":"VALUE1", "dataType":"String"}]}, successCallback, errorCallback);
I would like to know how to retrieve this extra on the launched app (maybe on the App.controller.js?).
EDIT
I think this can be handled by this other plugin
document.addEventListener('deviceReady', function(){
window.plugins.intent.getCordovaIntent(function (Intent) {
console.log(Intent);
}, function () {
console.log('Error');
});
}
Can someone please confirm is this is the way to do this or this is a good/bad practice? I would like to know if you have any suggestion to perform this logic I would really appreciate it. Thanks.
Cordova apps cannot capture startup parameters out of the box.
Someone has tried and has a fix for iOS I believe but I haven't seen anything for Android.
See this issue
You might also want to look into https://www.npmjs.com/package/cordova-plugin-intent
I am developing an ionic app. I am wondering if there is any event handler for this condition when the app is being stop/close in follow ways:
1) Settings -> Application -> Application Name -> Force stop
2) Swipe to close app.
I would expect something like this. But the best i could found is to cater for app exiting via $ionicPlatform.registerBackButtonAction which does not include the above two scenario.
Also, I am not sure whether this can be done in native platform as well. Please advise on this.
angular.module('app').run(function($ionicPlatform) {
$ionicPlatform.onAppStopOrForceClose(function() {
// Any function here
});
});
ionic.Platform.exitApp(); // stops the app
window.close();
see: http://ionicframework.com/docs/api/utility/ionic.Platform/
if you try in ios: you can't exit an IOS App, Apple do not allow apps to exit programmatically
I like to know how to exit an app in a good way in Android and Ios?
In the helloworld app of cocos2d-js this code is unfortunately omitted:
var closeItem = cc.MenuItemImage.create(
res.CloseNormal_png,
res.CloseSelected_png,
function () {
cc.log("Menu is clicked!");
}, this);
What can be there instead of
cc.log("Menu is clicked!");
?
For Android, you should call CCDirector::sharedDirector()->end(); to end the app. For Apple though, you could call exit(0) but its not really recommended to exit apps and will appear sort of like a crash. Do you need a close button? Most apps don't tend to have them and just keep running until the system or the user kills them.