private FacebookSession GetSessionToken(AccessToken accessToken) { var session = new FacebookSession() { Token = accessToken.TokenString, UserId = accessToken.UserID, }; var permissions = accessToken.Permissions.ToArray <NSString>(); foreach (var m in permissions) { session.Permissions.Add(m.ToString()); } return(session); }
private void GetUserInfo(List <string> fields, FacebookSession facebookSession, TaskCompletionSource <OperationResult <FacebookSession> > taskCompletionSource) { var builder = new StringBuilder(); fields.ForEach(m => { builder.Append($"{m},"); }); var s = builder.ToString(); if (!String.IsNullOrWhiteSpace(s)) { s = s.Substring(0, s.Length - 1); } var graphRequest = new GraphRequest($"/me?fields={s}", null, facebookSession.Token, null, "GET"); var requestConnection = new GraphRequestConnection(); requestConnection.AddRequest(graphRequest, (connection, result, error) => { if (error != null) { taskCompletionSource.SetResult( OperationResult <FacebookSession> .AsFailure(new ApplicationException(error.LocalizedDescription))); return; } var r = result as NSDictionary; var jsonData = r.ToDictionary(); facebookSession.Data = JObject.FromObject(jsonData); taskCompletionSource.SetResult(OperationResult <FacebookSession> .AsSuccess(facebookSession)); }); requestConnection.Start(); }