简体   繁体   中英

ios - What is the correct way to check if the app has access to Facebook?

If I want to make sure that the ios app has access to user's facebook account, which method should I follow? I have seen checking for FBSession.accessToken in some places and FBSession.activeSession.isOpen being checked at some other places. What is the difference between these two?

Thanks.

FBSession.accessToken tells you that the app has access to the user's Facebook account, whereas FBSession.activeSession.isOpen tells you weather the current session is open or not. We prefer to use FBSession.accessToken to check if the app has access to the user's facebook or not.

If you want to communicate with Facebook via your app and considering that you have setup the project correctly ie the FacebookAppID etc, you call for an active session via

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI 

method. The access token stores the information that an app has been permitted with certain permissions your app asks and you check for a valid access token each time so that you don't have to validate the app each time. FBSession.activeSession.isOpen is used to check if there is an active session in open state and if so, you can move forward with whatever your app intends to do with Facebook.

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