Trigger methods to logout user when user deletes app - iPad app

可紊 提交于 2019-12-02 01:03:52
mr.VVoo

Unfortunately there are no methods called when app is removed.

I'd prefer a solution where you log out the user when he quits the app and do a quiet login when he opens the app again without noticing that he was logged out. Therefore you need to store the credentials.

So you can ensure that the user is always logged out when he doesn't use the app.

But in my opinion you should change your backend so that it doesn't matter if the user has installed the app or not. But this may depend on your use case.

Richard Brown

There is no way to know when a user has deleted their app. You can use NSUserDefaults to store their login name once they're logged in and check for it's existence when you attempt to use services they have to be logged in to use. If the app has been deleted and reinstalled (or a new install) the NSUserDefaults value will be nil, if they're an established user it will be equal to their username.

[[NSUserDefaults standardUserDefaults] setObject:@"the_user_name" forKey:@"kUsername"];
[[NSUserDefaults standardUserDefaults] synchronize];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!