问题
I am using the iOS Parse SDK in my iPhone app. When the app first loads the user is able to log in. If the user then logs out and logs back in, my app crashes with the following error:
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'User cannot be saved unless they have been authenticated via logIn or signUp'
I use the same code that the Parse documentation says to use to login and logout. (code here: https://parse.com/docs/ios_guide#fbusers/iOS) The app seems to be crashing after this AppDelegate.m method is called:
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];
}
After the app crashes, the user can reopen the app and re-login successfully.
Help please?
回答1:
Try this:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[FBAppEvents activateApp];
[FBAppCall handleDidBecomeActiveWithSession: [PFFacebookUtils session] ];
}
You should use FBSession.activeSession just to ensure that the FBAppCall gets the same instance of FBSession, for which it has got the result.
来源:https://stackoverflow.com/questions/25707282/parse-sdk-on-ios-nsinternalinconsistencyexception-reason-user-cannot-be-sa