简体   繁体   中英

iOS Facebook SDK “user cancelled login” when running app on device?

I'm using the latest iOS Facebook SDK and I can log in and out perfectly when I am running my app in the simulator (in which case it opens the non-native popup window because the facebook app is not installed), but when I run it on my device I get the native uialertview popup and when I click "ok", the terminal says "user cancelled login" and the popup dismisses but it doesn't log in. Do you have any idea what could be causing this? I have done some research and couldn't find anything. I have pretty much followed their example app "Scrumptious" to the letter and I can't figure out why it works for that app but not mine.

Apart from wrong bundle, not handling Facebook callback can be a reason too. Add below mentioned method in app delegate.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                      openURL:url
                                            sourceApplication:sourceApplication
                                                   annotation:annotation];
}

Try to add the bundle identifier of your app on developer.facebook.com where you have created your appID. And make sure that bundle identifier of your app and you have entered both are same.! Also in mobile settings check that you have access permissions to your app. Here you will have to add your bundle identifier and save the changes.

Hope it will work.

If you have the Facebook App installed on the iPhone, make sure your application is allowed to connect using it. Go to Settings > Facebook and make sure your app is enabled for Login.

Besides the common problems with bundle_id and permission from Facebook app in Settings , I encountered another strange issue , after doing all that I could do , noticed I was getting the same problem "User cancelled login" .

I went into Settings and checked under Facebook the account I was logged in with, then I deleted the account and left the one managed by the Facebook application , that worked, not sure why , but fixed my problem.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM