I’m using the Facebook SDK to login and progress through my app. When a user removes the app permissions from their Facebook page and then reopens the app, I want it to go to the very first view controller, which asks the user to log into Facebook. However, I’m running into the problem where the user is still able to access the app even after removing the permissions.
So, how it should work:
i) User goes to Facebook profile and removes app permissions from settings
ii) User completely closes down my app from iPhone.
iii) User reopens my app and the “Log into Facebook” view controller should appear.
Instead, what happens:
i) User goes to Facebook profile and removes app permissions from settings
ii) User completely closes down my app from iPhone.
iii) User reopens my app, and my app opens up in a different view controller that should only come up after user has logged in.
AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("MY_API_KEY")
GMSPlacesClient.provideAPIKey("MY_API_KEY")
// FACEBOOK API STUFF
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
print(FBSDKAccessToken.current())
let storyboard = UIStoryboard(name: "Main", bundle: nil)
self.window = UIWindow(frame: UIScreen.main.bounds)
if(FBSDKAccessToken.current() != nil){
print(FBSDKAccessToken.current())
let initialViewController = storyboard.instantiateViewController(withIdentifier: "main")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
}
else{
print(FBSDKAccessToken.current())
let initialViewController = storyboard.instantiateViewController(withIdentifier: "facebookLogin")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
}
return true
}
2
Answers
You need to logout your session manually
OR
A solution is to refresh token every time your user start using the app when you delete your app from “Logged in with Facebook” you will receive error
“The operation couldn’t be completed. (com.facebook.sdk.core error 10.)”
so you can then sign out and make your user sign in once again