Felipe Marinho
Felipe Marinho

Reputation: 58

How to create a temporary User in QuickBlox?

I was wandering the best way to create a user and delete it after session ends. I'm tring to make a Annonymous chat. The app create and random login and password, sign up the user and log it in. When the user closes the app (double press home and swipe up) it should delete the user.

Where should i put the [QBUsers deleteUserWithID:userID delegate:self]; code ?

I've tried in applicationWillTerminate:

- (void)applicationWillTerminate:(UIApplication *)application {
    [QBUsers deleteUserWithID:appDelegate.appUser.userID delegate:self];
    NSLog(@"%u",appDelegate.appUser.userID);  
}

The NSLog return the right ID, but the user don't get deleted, if i put a IBAction with the same code it works.

Any Ideas ?

Upvotes: 2

Views: 118

Answers (2)

Rubycon
Rubycon

Reputation: 18346

The issue with your code is that you can perform only sync code in applicationWillTerminate, but not async.

Upvotes: 0

Rafał Sroka
Rafał Sroka

Reputation: 40030

Here is what the docs say:

(...) you must be prepared for your app to be killed without any notification. The user can kill apps explicitly using the multitasking UI.

And some more info on applicationWillTerminate:

If your app is running at termination time, the system calls your app delegate’s applicationWillTerminate: method so that you can perform any required cleanup. Your method has approximately 5 seconds to perform any tasks and return. If it does not return in time, the app is killed and removed from memory.

Important: The applicationWillTerminate: method is not called if your app is currently suspended.

Source: App States and Multitasking

Upvotes: 2

Related Questions