iOS - Start a function if app is closed [duplicate] - ios

This question already has answers here:
Perform background tasks when app is terminated
(3 answers)
Detect iOS app entering background
(7 answers)
Closed 5 years ago.
I wonder if it's possible with swift, start a function at a certain time, especially if the app is closed.
I tried a bit around but did not find anything useful.
I hope you can help me.
Thanks

You can try to override functions like
applicationDidEnterBackground
applicationWillTerminate
applicationDidBecomeActive

Related

How can i crash app with some log in swift? [duplicate]

This question already has answers here:
Easiest way to force a crash in Swift
(6 answers)
Closed 3 years ago.
I want to crash my app forcefully but also want that app first print crash log on debuging window and than terminate app.
It's for testing purpose to test app to fetch crash log.
Thank you.
Simple :
var arr = [Int]()
arr.remove(at: 1)

Is there a method that gets called on app uninstallation? [duplicate]

This question already has answers here:
Detect iOS application about to delete?
(3 answers)
Closed 4 years ago.
I have a very specific need to handle some cases if my iOS app gets uninstalled. But I cannot find any method so far that gets called in case the app gets uninstalled. I have searched around with similar questions but cannot find anything usefull. Can anyone suggest something please.
No, its not possible.
But you can check if the application has re-installed by storing a key in iCloud using keychain.

How To Detect When App Is Force Closed in Background Swift [duplicate]

This question already has answers here:
iOS how to detect when app was removed from process
(4 answers)
Closed 6 years ago.
If my app is running in the background, and I force close it, how can I get the app to detect it was force closed in the background? Is there a specific function I can call to detect this?
You can use
func applicationWillTerminate(_ application: UIApplication) {
}
within AppDelegate class to observe when the app will be terminated. Documentation.
Edit: Please, note that as it written in docs
Suspended apps are not notified of termination

Swift iOS 9+ before app closes/before app opens [duplicate]

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.

Custom Vibrations in iOS7 [duplicate]

This question already has answers here:
Are there APIs for custom vibrations in iOS?
(2 answers)
Closed 8 years ago.
I've been looking around the web trying to see if anyone has been able to do custom vibration timing. I found information on iOS5 but it was only doable with non app store approved methods.
Is there any API's in iOS7 that will let me do this?
There are no new iOS 7 APIs for this. The private APIs you mentioned remain the only option.

Resources