Since there is no answer, I am trying to answer what I found. After my comment above, I read the documentation for updateCredentialsForAccount, which says: "If the user has canceled the authorization of your application, this renewal request will return ACAccountCredentialRenewResultRejected."
Which means that this is not the user who rejects, but Facebook.
I think I understand the concept now, and I'm trying to answer those who have not dealt with this problem, like me. In fact, I did not understand that my FB token will be completely reset when I get the result ACAccountCredentialRenewResultRejected. And this is a 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 run SLRequest with this updated token.
- ACAccountCredentialRenewResultRejected : your token is reset , if you try to get it, it will be nil . You must request permission from users from scratch and “install” the application for Facebook. This means that you first request the usual "email permissions and other read permissions" and (if you need it) in a separate request requesting write permissions. (Someone can explain why Facebook wants me to bother the user twice if I want to upload a photo, for example)
- ACAccountCredentialRenewResultFailed : I could not reproduce this ever. I believe that you are sending an error message to the user.
Here is what I came up with. This is a very nasty API that has poor documentation and missing samples. In addition, examples on the Internet relate to “success,” and they don’t care that the user can revoke permissions outside the application. I constantly try and cannot develop a development mode. Weakening gray hair, but coming to an end. Hope my answer helps others.
Teddy
source share