This question already has answers here:
Detect when app killed by user in background state iOS
(2 answers)
Closed 2 years ago.
Is there a way to execute an action when a React Native app terminates? I know about app states, but I'm looking for a way to call an action when the user swipes to kill the app, not when it's just in the background.
From my understanding, there is no way in doing this within React Native. Is there a way I could do it natively? I only need this functionality for iOS. Thanks a lot!
Hi you've got to go native code. In the AppDelegate you need to implement the method
- (void)applicationWillTerminate:(UIApplication *)application;
more info about applicationWillTerminate
inside of it you can resolve a Promise that you defined in our module
Related
This question already has answers here:
Proper way to exit iPhone application?
(24 answers)
Closed 3 years ago.
I'm allowing language change feature inside my application. As user select new language feature inside the application I need to quit the application and user will have to start it again. For quitting I'll show an alert to user that you have to restart the application for language change to complete.
Now how can I use manual termination of iOS app and make it approve from Apple.
PS: Facebook do the same for language change. They tell the user that app needs to restart for language change to take place. Some other apps also kills the application on some alert tap.
exit(0)
you can solve your problem by this, but this is forbidden by Apple. You should set your app to your Home page when you change your language.
let viewController = HomeViewController()
UIApplication.shared.keyWindow.rootViewController = viewController
Ankur gave you the correct answer: You can use exit to terminate your app but Apple does not allow apps to terminate themselves. Your app will be rejected from the app store if you do that.
Instead, you should refactor your app so you have the ability to tear down your entire UI and rebuild it. Delete all your view controllers and replace the root view controller as Ankur says.
This question already has answers here:
Save the current status when quit, auto-reload when re-open the app
(2 answers)
Closed 6 years ago.
I want, using Swift in iOS, to capture a variable before the app closes from a subview and place it in storage, and prior to the app gets too far along on re-open restore this variable.
I know how to get and set, I just am hoping to stumble across the events that trigger before the app closes and shortly after it launchers.
You should do this in the AppDelegate.swift file.
This question already has answers here:
Will iOS region monitoring call didEnterRegion on my app if my app is in a terminated state?
(2 answers)
Closed 8 years ago.
I'm creating a location aware application. I was able to create geofences already,
when I test it in my iPhone, I noticed that the calllback methods -didEnterRegion and -didExitRegion are being called when the application is running in foreground and background. But when I killed the application (meaning the application state is "not running") the said method call backs are not being called.
So, what am I missing here? Is there any configuration that I need to do? Any thought guys? Thank you!
This is correct behaviour depending on how you 'killed' the app. If you stopped the app by swiping up from the multi-tasking view (double tap home) then iOS 7 interprets this as meaning you do not want the app to operate at all - either in the foreground or background. If the app is 'killed' as a result of being in the background when the device needs more memory then it will continue to operate in background mode.
Refer to this answer - Region monitoring in ios 7
In order to test you can stop your application using Xcode, simulate a low-memory situation while your app is suspended or call exit() for testing purposes.
This question already has answers here:
Proper way to exit iPhone application?
(24 answers)
Closed 9 years ago.
In my app I am having a continuous communication with TCP server , now if
server sends a command to close the app, i want to close the app completely
and when user taps the app again, it should start with Application launch method itself.
I have tried using exit(0) in the code, using this application goes into background.But it doesn't kill the app. How can i do that?
There isn't a way. Apple doesn't allow it. The solution is: Just accept the fact that you are unable to do this and work around that fact.
This question already has an answer here:
Programmatically answer an incoming phone call on iPhone
(1 answer)
Closed 9 years ago.
Is it possible to programmatically answer a call in iPhone? I have already googled about this and found that iOS SDK does not support such feature. But I found an answering machine app in Appstore.
https://itunes.apple.com/in/app/prank-answering-machine-free/id508457142?mt=8
Please help me out.
No this is not possible, the iOS SDK does not allow any interaction with the phone.app.
Also the app you have found is a prank app, one that you start if you receive a call and the play back one the messages from the app.
No, that is not possible. The CoreTelephony framework lets your application receive notifications if there is any change in the call state, but there is no way to answer it.
The app that you mentioned does not say anything about answering a call, from what I can see.
I would say it depends. If you want to make a app and publish it in app store, its not possible. However if you want don't want to publish on app store and willing to use private api, then its possible. Refer this answer.