Search Unity

Facebook login permissions for IOS in Unity

Discussion in 'Editor & General Support' started by Bertlapp, Jul 26, 2016.

  1. Bertlapp

    Bertlapp

    Joined:
    Sep 7, 2015
    Posts:
    44
    Hello,

    I am developing a game for android and IOS with a Facebook extension in Unity.

    My app is using Facebook to keep user scores with the score.API. Facebook changed their login policy from login to LogInWithReadPermissions and LogInWithPublishPermissions.

    So far so good. I ask for the standard permissions (email, public profile and user_friends) using the LogInWithReadPermissions and ask for the publish_actions using the LogInWithPublishPermissions.
    (I applied to use the publish_actions for my app in the FB developers settings which FB has approved)

    Android
    When i test the game everything works like a charm on android. When I log in to Facebook, the first popup is asking for the read permissions to approve and afterwords a second popup asks for the publish permission approval.

    iPhone
    When I do the same on iPhone, it's only asking for the read permissions and ignores the publish permissions?
    Which makes my app unable to save the scores on iPhone since the publish_actions is not approved.

    Now i need to know why this popup doesn't show on an iPhone device?


    Some technical data:
    Unity version 5.3.5f1
    Facebook SDK 7.4.0

    Build to Android API 16 and up (working fine)
    Build for IOS 9 and up


    Here is a part of my Facebook manager code where I handle the login.

    Not entirely sure I should ask for multiple permissions using this way, but I'am unable to find a good documented example on this issue.

    Code (CSharp):
    1.         public void FBlogin(){
    2.                 try{
    3.                     List<string> perms = new List<string>(){"user_friends","public_profile","email"};
    4.                     FB.LogInWithReadPermissions (perms,LoginReadCallback);
    5.                 }
    6.                 catch(System.Exception e){
    7.                         print (e.ToString());
    8.                 }
    9.  
    10.         }
    11.  
    12.         void LoginReadCallback(ILoginResult result)
    13.         {
    14.                
    15.                 if (FB.IsLoggedIn) {
    16.                         //You granted the standard read permissions
    17.  
    18.                         FacebookManager.Instance.IsLoggedIn = true;
    19.  
    20.                         List<string> perms = new List<string> (){ "publish_actions" };
    21.                         FB.LogInWithPublishPermissions (perms, LoginPublishCallback);
    22.  
    23.                 }
    24.                 else {
    25.                         FacebookManager.Instance.IsLoggedIn = false;
    26.                 }
    27.         }
    28.  
    29.  
    30.         void LoginPublishCallback(ILoginResult result)
    31.         {
    32.               //You also granted the asked publish_actions permission.
    33.  
    34.         }

    Any help is greatly appreciated.
    Thanks

    Bert
     
    Last edited: Aug 2, 2016
  2. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
    Did you manage to find a solution to the problem? I'm facing the exact same one.
     
  3. Bertlapp

    Bertlapp

    Joined:
    Sep 7, 2015
    Posts:
    44
    No, I didn't :(

    Which iPhone are you using?
    Apparently the iPhone 6 has some issues with the login, according to some posts I found.
     
  4. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
    Happened on Iphone 5, 6 and 6s
     
  5. Bertlapp

    Bertlapp

    Joined:
    Sep 7, 2015
    Posts:
    44
    Maybe I should update to Facebook SDK 7.8 since I'm still using 7.4 ;)
    I'll test it and keep you posted.
     
  6. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
    As a workaround we delayed the second permission request by 1 second, that works but I'm sure thats not how it's meant to be used ... :p
     
  7. Bertlapp

    Bertlapp

    Joined:
    Sep 7, 2015
    Posts:
    44
    With SDK 7.8 the same result.
    The 1sec workaround is at least a result that works :rolleyes:

    Thanks
     
  8. rajan4uto

    rajan4uto

    Joined:
    Nov 27, 2014
    Posts:
    2
    I did the same thing but first i login with publish action then on success, asked about the other permissions. It's working fine but I have other problem, I am not able to see user's friend list but in test mode i can see the list. publish_action is also approved. Please help me for this issue.
     
  9. Bertlapp

    Bertlapp

    Joined:
    Sep 7, 2015
    Posts:
    44
    I think your app is working fine when it's live.

    The only thing is you must be sure some of your Facebook friends have the app installed with the permissions approved.
    Only then you will be able to see them in your friends list. I recommend you making a test Facebook account and add yourself as a friend. Then login to the app with the test account and see if you can see your own Facebook listed. If this is the case, everything works fine. The test Facebook is always handy when you are doing Facebook related programming.

    In Facebook under games, you can see your own app listed. This is where the approved permissions are kept. If you delete this you can approve the permissions again in your app. Be careful not to delete your Facebook developers app!


    In test mode with test users, the users are probably friends of each other already and have the app installed. That's why you can see them in test mode.


    Hopes this solve your problem,

    Regards
    Bert
     
    Last edited: Aug 24, 2016