Search code examples
facebookfacebook-graph-apiunity-game-enginefacebook-unity-sdkfacebook-permissions

How to Request publish permission after logged in Unity


I know there is a function in iOS/Android SDK known as reauthorizeWithPublishPermissions.

But I couldn't find this function in Unity FB SDK. How can I achieve this?

I know permissions can be stated during Login. What if the user doesn't allow publish permissions and later on the user click on Share/Post to wall. At least I have to prompt the user and ask for permissions again.

Anyone has any workaround to handle this issue?


Solution

  • Simply call the FB.login with the publish_action/public_stream permission wherever you want to ask for the publishing permission-

    FB.Login("publish_action", AuthCallback);
    

    To find out which permissions user have at any given time, you can read the /user/permissions Graph API endpoint, by writing something like-

    FB.API("/me/permissions", HttpMethod.GET, delegate (FBResult response) {
      // inspect the response and adapt your UI as appropriate
      // check response.Text and response.Error
    });