Search Unity

Question WINSDKFB for UWP Error When Trying to Open Login Dialog

Discussion in 'Windows' started by rekatha, Jan 2, 2023.

  1. rekatha

    rekatha

    Joined:
    Dec 18, 2017
    Posts:
    22
    Hello...
    Has anyone integrated Unity Facebook in UWP ? There is Facebook SDK for Unity but it doesn't support UWP. I have tried using winsdkfb to show login dialog, but I got an error at LoginAsync. (error attached) I use InvokeOnUIThread from unity so the LoginAsync runs on UI thread.
    (Build setting and player setting are attached)

    Note: I make empty C# UWP app from visual studio (not from unity) and using same winsdkfb. And the app can successfully show login dialog.

    my unity C# code:

    Code (CSharp):
    1. private void OnLoginButtonClick()
    2.     {
    3. #if UNITY_WSA && ENABLE_WINMD_SUPPORT
    4.         SessionLoginBehavior loginBehavior = SessionLoginBehavior.WebView;
    5.         FBSession sess = FBSession.ActiveSession;
    6.         sess.FBAppId = "xxxxxxxx";
    7.         sess.WinAppId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    8.         List<String> permissionList = new List<String>();
    9.         permissionList.Add("user_friends");
    10.         permissionList.Add("user_photos");
    11.         FBPermissions permissions = new FBPermissions( permissionList );
    12.  
    13.         UnityEngine.WSA.Application.InvokeOnUIThread(async () =>
    14.         {
    15.             FBResult result = await sess.LoginAsync(permissions, loginBehavior);
    16.             if (result.Succeeded)
    17.             {
    18.                 FBUser user = sess.User;
    19.                 UnityEngine.Debug.Log(sess.User.Id);
    20.                 UnityEngine.Debug.Log(sess.User.Name);
    21.             }
    22.             else
    23.             {
    24.                 UnityEngine.Debug.Log("login failed");
    25.             }  
    26.         }, waitUntilDone: true);
    27.  
    28. #endif
    29.     }
    ... or maybe there is another sdk for UWP to login facebook ???
     

    Attached Files:

    Last edited: Jan 2, 2023
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Perhaps facebook SDK requires XAML app type instead of D3D? Did you try switching to that in the build window?
     
  3. rekatha

    rekatha

    Joined:
    Dec 18, 2017
    Posts:
    22
    Yes, my build setting is xaml. My screen shoot is error from solution generated by unity uwp XAML type.
    (I edit my question with Build setting and player setting are attached)
     
  4. bart_zempot

    bart_zempot

    Joined:
    Apr 11, 2022
    Posts:
    1
    I'm stuck here, too. Is it resolved?