I am trying to remove data from a Firebase database that I have set up when a user closes an app. Is there a method that is called when the app is closed in order for me to call one last function to remove the data from the database?
Thanks
I am trying to remove data from a Firebase database that I have set up when a user closes an app. Is there a method that is called when the app is closed in order for me to call one last function to remove the data from the database?
Thanks
To Close application using double time press home button and swipe Up is different thing. It will call below method
- (void)applicationWillTerminate:(UIApplication *)application {
}
Press home button and application will work on background is different task. Maybe you are looking for
- (void)applicationDidEnterBackground:(UIApplication *)application{
}
Please refer TheAppLifeCycle
application:willFinishLaunchingWithOptions:—This method is your app’s first chance to execute code at launch time.
application:didFinishLaunchingWithOptions:—This method allows you to perform any final initialization before your app is displayed to the user.
applicationDidBecomeActive:—Lets your app know that it is about to become the foreground app. Use this method for any last minute preparation.
applicationWillResignActive:—Lets you know that your app is transitioning away from being the foreground app. Use this method to put your app into a quiescent state.
applicationDidEnterBackground:—Lets you know that your app is now running in the background and may be suspended at any time.
applicationWillEnterForeground:—Lets you know that your app is moving out of the background and back into the foreground, but that it is not yet active.
applicationWillTerminate:—Lets you know that your app is being terminated. This method is not called if your app is suspended.
Hope it will help you.
use this appdelegate
method
- (void)applicationWillTerminate:(UIApplication *)application {
}
Or
erase data in Every application launch, because applicationWillTerminate
only get called in restricted conditions.
Firebase supports some functions regarding presence.
If you want to remove a node on disconnect. ref.onDisconnectRemoveValue()
Or if you want to set a value on a node: ref.onDisconnectSetValue(someValue)