How to get notified about app being completely closed - flutter

I need to take an action when my app gets destroyed. I tried to use WidgetsBindingObserver and WillPopScope so far but none of them is invoked in case user removes the app from launcher's recent apps. Is there a way to execute some code before app is completely gone?

As far is I know for now, there is no way in Flutter. But I know a native way in Android (see this link)
You can implement this in your MainActivity or so, see this how to call Android/iOS code from Flutter
I don't know how to do in iOS, but that could be a bit more difficult due to iOS's different app resource handling etc.
Also, it could be a nice idea for a plugin/package. So developers, go ahead ;)

Related

Flutter application restart instead of resuming after some time when switch to other applications

Hi i am developing a flutter application and i am using getx statemanagment. The problem is when i put application in background and use some other applications like whatsapp,youtube,play a game or listen music, after some time when i resume my application from recents it restarts and all progress is lost.
I have already tried different solutions like moveTaskToback(true) with native android function call
Please help, I have almost finished my important application.
I'm not sure on why this happens, but some manufacturers have their own restrictions on apps running in the background. Nothing you can really do from a flutter perspective, the app lifecycle is the same on all devices.
Here is a link where they share some tips how to deal with this on Xiaomi from the users perspective.
https://dontkillmyapp.com/xiaomi
From the developers perspective, as you can read on the bottom of the article, the are no common workarounds known yet.

Flutter, Detecting that other apps are launched

I'm trying to develop an app that prevents a user from starting other application when my app is running. The scenario:
my app starts the timer
app detects launch of another app (could be anything other than my app)
if it detects, it cancels some achievements
Can anyone help? I saw some solutions on this topic, but could not find anything in Flutter.
Any ideas would help.
Thank you.
There is a few ways to do that but easy one to observe your app situation, you can use WidgetsBindingObserver to detect your app is background or not.
But if the case is not being background it is just depending to launch an app so there is a few ways which suggest in this answer you can try them.

Running an ionic app inside ionic app

Is there any way to develop the main app with logins using ionic and develop subparts of that app as individual apps and use the main app to access the sub-apps and pass the login info to sub apps.
Draw.io Flow Diagram For Better idea 1
One ionic app can launch another through the InAppBrowser, for instance. Or socialsharing plugin, etc. And then you need to pass on variables through the launch code. And then going back again.
But the UI experience will be awefull this way if functionally the apps actually are quite similar/related/dependent. So from a UI perspective not a very nice thing to do.
So basically, if you manage the code for all these apps, you may be better off integrating as modules/components in one code base. If you don't own the other apps, make sure the UI is smooth.
Regards
Tom

iOS - app containing another app

I would like to hand my application to another developer to assymilate in his iOS app.
The goal is to have, in his app, a shortcut that opens my app directly - not just a link to the appstore.
The problem is my app has to remain compiled, since I don't want to hand over my source-code.
Is this situation, of one compiled iOS app, encapsulated insind another iOS app, even possible?
Thanks in advance.
Your application can register a custom URL handler that will launch it whenever any application will follow that URL. It can be triggered from Safari but it can also be triggered from any other application.
Here's how you enable that feature in your app and handle incomming passed parameters etc.
All code in an app bundle has to be staticly linked, so you would have to rewrite and compile your app as a linkable shared library.
What you're looking to do really isn't possible. Each app has it's own code structure and can't be embedded into another app (MainWindow.xib for example). Each app is also signed by the developers private key, so that's an obstacle there. You can't just hand him a binary of your app.
What you could do is potentially take your .XIBs and view controllers and give them to him to implement. This is easiest if there's no model that also has to be migrated over. Then he can present your views to take advantage of the logic built into your view controllers.
It's not a trivial amount of work and of questionable value. If you're not willing to share source code then none of the above is really going to work for you.
My advice would be as people above have mentioned and use a URL scheme in his app that refers to yours. Yes, your app would need to be installed, but then there's a clear and unambiguous separation between his work and yours...

Can an iPhone app hide/launch other apps?

I am asking this question mainly to know if what I want to do is possible. I don't think there is an app that does it and I've been meaning to learn objective C, but it may not be possible.
I want an app that serves as the ONLY way (at least, the only easy way) to launch another app. So in an ideal world, you have MyApp, which lists app A, B, and C. A B and C are not visible on the normal browser, but can be launched from within my app.
Possible? Not?
Not possible. And its most likely that such a functionality will never make it into the official SDK.
What you're trying to do isn't really possible. It isn't possible (with the official development kit) to create iOS applications that don't appear on the home screen.
It is possible to launch other applications, though -- one common approach is to set them as URL handlers for private URL schemes. This can be used to pass information between applications. (However, trying to use this as access control won't work, because Apple will likely reject an application which can only be opened "correctly" by another app.)
Depends on your definition of App.
You can just have a master app which creates the illusion of being an app launcher by "opening" subroutines. Imagine like the old facebook iphone app for example
NO
Well... This has been done for years on the Cydia store with some custom menus but we wont get into that here...
Using the official SDK I think there are protocols to allow you to open an another application but pressing the home button for example will always go back to the default screen. I think ever if you were able to get it working, there is no chance it would be accepted into the App Store on grounds of it not doing anything the phone already does.
By all means look up jailbreaking and using the custom tool chain but you won't be able to sell this through Apple unfortunatley.