Since there is no accepted answer I try to reply what I found. After my comment above I read the documentation about renewCredentialsForAccount which says "If the user has deauthorized your app, this renewal request will return ACAccountCredentialRenewResultRejected."
What is missleading that it is not the user who rejects but Facebook.
I think I understand the concept now and I try to reply to those who failed with this issue like me. In fact what I did not realise is that my FB token will be completely reset when I receive ACAccountCredentialRenewResultRejected result. And that is the key element in the puzzle.
So what you need to do for different results:
- ACAccountCredentialRenewResultRenewed you are good to go and you have a new token. Go and perform your SLRequest with this renewed token.
- ACAccountCredentialRenewResultRejected: your token is reset, if you try to obtain one it will be a nil. You have to request permissions from the users from scratch and "install" the App for Facebook. That means you ask first for the usual "email+other read permissions" and (if you need so) in a separate request you ask for write permissions. (Someone could explain why Facebook wants me to bother the user twice if I want to upload a photo for instance)
- ACAccountCredentialRenewResultFailed: I could not reproduce this ever. I beleive here you drop an error message to the user.
This is what I came up with. It is a very nasty API which has a poor documentation and missing samples. Also the examples around the Internet are about the "Success" and they do not care about the fact that the user can revoke permissions outside the app. I am in a constant try & fail development mode. Loosing gray hair but coming to the end. I hope my response helps others.
renewCredentialsForAccount
call that the next time i launch the app and try to log in i am prompted to give permissions to the app. Whereas if I do not make that call I am never prompted to do that. – Frymire