Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Content of FB.Mobile.AppInvite callback

Discussion in 'Editor & General Support' started by Sreeraj, Jan 15, 2016.

  1. Sreeraj

    Sreeraj

    Joined:
    Apr 27, 2015
    Posts:
    14
    Is that possible to get the Ids as callback in which i have sent app request?? Like we are getting in FB.AppRequest
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    Did you check the raw response you're getting for the request ?
     
  3. Sreeraj

    Sreeraj

    Joined:
    Apr 27, 2015
    Posts:
    14
    ya i did , In that we are getting whether we are sent the request properly or not and how many times we are sent request in that current session.
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    I dont think you are supposed to receive "how many times in a session... You'll have to count that yourself...
     
  5. Sreeraj

    Sreeraj

    Joined:
    Apr 27, 2015
    Posts:
    14
    Thats fine, is that possible to know to whom we sent the invite??
     
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    What kind of information are you getting in the response? Can you print the raw response of when sending an invite to:
    1. No one
    2. A few friends
    3. Cancelling

    Examine the results & check the docs for this API to see what is the expected results. Then you could know if this information is available or not.
     
  7. joyjeba28

    joyjeba28

    Joined:
    Nov 30, 2015
    Posts:
    3
    This is the code i am using .


    Code (CSharp):
    1.  
    2. if (!result.Cancelled)
    3.             {
    4.                 var objs = Json.Deserialize (result.RawResult) as Dictionary<string, object>;  
    5. //                Dictionary objs;
    6. //                objs = Json.Deserialize (result.ResultDictionary) ;  
    7.  
    8.                 Debug.Log ("**"+objs["didComplete"]);
    9.                 Debug.Log ("**"+objs["callback_id"]);
    10.                 foreach (var field  in objs)
    11.                 {
    12.                     Debug.Log ("**field received**" + field.Key + ":" + field.Value);
    13.                 }
    14.                 string status = "" + objs ["didComplete"].ToString ();
    15.  
    16.                 #if UNITY_ANDROID
    17.                 {
    18.                     if (status == "True")
    19.                     {
    20.                         int currentCoins = PlayerPrefs.GetInt(PlayerStats.playerPrefInstance.totalCoin);
    21.                         int targetCount = 500 + currentCoins;
    22.  
    23.                         PlayerPrefs.SetInt(PlayerStats.playerPrefInstance.totalCoin,targetCount);
    24.  
    25.                         if (sceneName.name == "MenuScene")
    26.                         {
    27.                             refForAddingFbCoins.FbRewardCoins (targetCount);
    28.                         }
    29.                         Debug.Log (result.RawResult);
    30.                         EnableBonusCoinsRewarded(500);
    31.                     }
    32.                 }
    33.                 #else
    34.                 {
    35.                     if (status == "1") //called in two cases
    36.                     {
    37.                        
    38.                      
    39.                         Debug.Log ("Invite successfully done");
    40.                        
    41.                     }
    42.                 }
    43.                 #endif
    i m getting result.cancelld while user press the close button .
    but i m getting the same callback for
    while user clicked 1)done button in safari view controller or 2)while user successfully inviting friend
    how can i differentiate this . is there any way to get the number of friends invited .
     
  8. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    This could be a bug in the Facebook SDK. which version are you using ? I recall a bug like this from a few months ago.
     
  9. goble

    goble

    Joined:
    Jun 30, 2016
    Posts:
    8
    FYI that I am having the same issue...if the user clicks "Done", I get the same result data as if they had clicked "Send"...making it so I can't tell if they really sent an invite to one or more friends.

    I'm using Facebook 7.4.0 with Unity 5.4.2f2
     
    Last edited: Feb 2, 2017
  10. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,559
    Did you try upgrading to the latest Facebook SDK?
     
  11. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    228
    The same issue with latest 7.9 SDK (((
     
  12. goble

    goble

    Joined:
    Jun 30, 2016
    Posts:
    8
    Everything I've searched seems to conclude that it's not currently possible to distinguish by zero users and one-or-more users being inviting when "Done" is tapped. I'm thinking of adding a "minimum elapsed time" check or trying another method of inviting.
     
  13. Salazar

    Salazar

    Joined:
    Sep 2, 2013
    Posts:
    235
    Same here.

    Code (CSharp):
    1. FB.AppRequest(message,null,new List<object> (){ "app_non_users" },null,null,null,title,delegate (IAppRequestResult result)
    2.             {
    3.                 // Error checking
    4.                 //Debug.Log(result.RawResult);
    5.                 bool requested = false;
    6.                 int requestCount = 0;
    7.                 if (result.Error != null)
    8.                 {
    9.                     //Debug.LogError(result.Error);
    10.                     requested = false;
    11.                     requestCount = 0;
    12.                     return;
    13.                 }
    14.  
    15.                 // Check response for success - show user a success popup if so
    16.                 object obj;
    17.                 if (result.ResultDictionary.TryGetValue ("cancelled", out obj))
    18.                 {
    19.                     //Debug.Log("Request cancelled");
    20.                     requested = false;
    21.                     requestCount = 0;
    22.  
    23.                 }
    24.                 else if (result.ResultDictionary.TryGetValue ("to", out obj))
    25.                 {
    26.  
    27.                     List<object> inviteList = (List<object>)obj;
    28.                     //Dictionary<string, object> rObject = result.ResultDictionary;
    29.                     //IEnumerable<object> inviteList =(IEnumerable<object>)rObject["to"];
    30.                     //Debug.Log (inviteList.Count);
    31.                     //Debug.Log (Json.Serialize(obj));
    32.  
    33.                     if(inviteList.Count>0)
    34.                     {
    35.                     requested = true;
    36.                         requestCount = inviteList.Count;
    37.                     }
    38.  
    39.  
    40.                 }
    41.                 if(callback!=null)
    42.                 {
    43.                     callback(requested,requestCount);
    44.                 }
    45.  
    46.            
    47.             });
    48.  
    It returns plain string of user IDs . Not a string array as documented here.
     
  14. Salazar

    Salazar

    Joined:
    Sep 2, 2013
    Posts:
    235
    Workaround for facebook sdk 7.9.4

    Code (CSharp):
    1. FB.AppRequest(message,null,new List<object> (){ "app_non_users" },null,null,null,title,delegate (IAppRequestResult result)
    2.             {
    3.                 // Error checking
    4.                 //Debug.Log(result.RawResult);
    5.                 bool requested = false;
    6.                 int requestCount = 0;
    7.                 if (result.Error != null)
    8.                 {
    9.                     //Debug.LogError(result.Error);
    10.                     requested = false;
    11.                     requestCount = 0;
    12.                     return;
    13.                 }
    14.  
    15.                 // Check response for success - show user a success popup if so
    16.                 object obj;
    17.                 if (result.ResultDictionary.TryGetValue ("cancelled", out obj))
    18.                 {
    19.                     //Debug.Log("Request cancelled");
    20.                     requested = false;
    21.                     requestCount = 0;
    22.  
    23.                 }
    24.                 else if (result.ResultDictionary.TryGetValue ("to", out obj))
    25.                 {
    26.                     Debug.Log(obj.GetType());
    27.                     char[] charSeparators = new char[] {','};
    28.                     string resultIds = (string)obj;
    29.                     string[] ids = resultIds.Split(charSeparators);
    30.                     Debug.Log(ids.Length);
    31.  
    32.                     if(ids.Length>0)
    33.                     {
    34.                     requested = true;
    35.                         requestCount = ids.Length;
    36.                     }
    37.  
    38.                 }
    39.                 if(callback!=null)
    40.                 {
    41.                     callback(requested,requestCount);
    42.                 }
    43.  
    44.            
    45.             });
    Best Regards,