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

北战南征 提交于 2019-12-24 01:24:34

问题


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.


回答1:


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];
}



回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/20876208/ios-facebook-sdk-user-cancelled-login-when-running-app-on-device

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