public override void Init(
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            HideUnityDelegate hideUnityDelegate,
            InitDelegate onInitComplete)
        {
            // Warn that editor behavior will not match supported platforms
            FacebookLogger.Warn(WarningMessage);

            base.Init(
                appId,
                cookie,
                logging,
                status,
                xfbml,
                channelUrl,
                authResponse,
                frictionlessRequests,
                hideUnityDelegate,
                onInitComplete);

            this.EditorGameObject.OnInitComplete(string.Empty);
        }
        public override void Init(InitDelegate onInitComplete)
        {
            // Warn that editor behavior will not match supported platforms
            FacebookLogger.Warn(WarningMessage);

            base.Init(onInitComplete);
            this.editorWrapper.Init();
        }
Esempio n. 3
0
        public override void Init(
            HideUnityDelegate hideUnityDelegate,
            InitDelegate onInitComplete)
        {
            // Warn that editor behavior will not match supported platforms
            FacebookLogger.Warn(WarningMessage);

            base.Init(
                hideUnityDelegate,
                onInitComplete);

            this.EditorGameObject.OnInitComplete(string.Empty);
        }
Esempio n. 4
0
        private static void FormatAuthResponse(ResultContainer result, Utilities.Callback <ResultContainer> callback)
        {
            if (result.ResultDictionary == null)
            {
                callback(result);
                return;
            }

            IDictionary <string, object> authResponse;

            if (result.ResultDictionary.TryGetValue(CanvasFacebook.AuthResponseKey, out authResponse))
            {
                result.ResultDictionary.Remove(CanvasFacebook.AuthResponseKey);
                foreach (var item in authResponse)
                {
                    result.ResultDictionary[item.Key] = item.Value;
                }
            }

            // The JS SDK doesn't always store the permissions so request them before returning the results
            if (result.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey) &&
                !result.ResultDictionary.ContainsKey(LoginResult.PermissionsKey))
            {
                var parameters = new Dictionary <string, string>()
                {
                    { "fields", "permissions" },
                    { Constants.AccessTokenKey, (string)result.ResultDictionary[LoginResult.AccessTokenKey] },
                };
                FacebookDelegate <IGraphResult> apiCallback = (IGraphResult r) =>
                {
                    IDictionary <string, object> permissionsJson;
                    if (r.ResultDictionary != null && r.ResultDictionary.TryGetValue("permissions", out permissionsJson))
                    {
                        IList <string> permissions = new List <string>();
                        IList <object> data;
                        if (permissionsJson.TryGetValue("data", out data))
                        {
                            foreach (var permission in data)
                            {
                                var permissionDictionary = permission as IDictionary <string, object>;
                                if (permissionDictionary != null)
                                {
                                    string status;
                                    if (permissionDictionary.TryGetValue("status", out status) &&
                                        status.Equals("granted", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        string permissionName;
                                        if (permissionDictionary.TryGetValue("permission", out permissionName))
                                        {
                                            permissions.Add(permissionName);
                                        }
                                        else
                                        {
                                            FacebookLogger.Warn("Didn't find permission name");
                                        }
                                    }
                                    else
                                    {
                                        FacebookLogger.Warn("Didn't find status in permissions result");
                                    }
                                }
                                else
                                {
                                    FacebookLogger.Warn("Failed to case permission dictionary");
                                }
                            }
                        }
                        else
                        {
                            FacebookLogger.Warn("Failed to extract data from permissions");
                        }

                        result.ResultDictionary[LoginResult.PermissionsKey] = permissions.ToCommaSeparateList();
                    }
                    else
                    {
                        FacebookLogger.Warn("Failed to load permissions for access token");
                    }

                    callback(result);
                };
                FB.API(
                    "me",
                    HttpMethod.GET,
                    apiCallback,
                    parameters);
            }
            else
            {
                callback(result);
            }
        }
Esempio n. 5
0
 public override void Init(HideUnityDelegate hideUnityDelegate, InitDelegate onInitComplete)
 {
     FacebookLogger.Warn("You are using the facebook SDK in the Unity Editor. Behavior may not be the same as when used on iOS, Android, or Web.");
     base.Init(hideUnityDelegate, onInitComplete);
     this.editorWrapper.Init();
 }
Esempio n. 6
0
        private static void FormatAuthResponse(ResultContainer result, Utilities.Callback <ResultContainer> callback)
        {
            if (result.ResultDictionary == null)
            {
                callback(result);
                return;
            }
            IDictionary <string, object> dictionary;

            if (result.ResultDictionary.TryGetValue("authResponse", out dictionary))
            {
                result.ResultDictionary.Remove("authResponse");
                foreach (KeyValuePair <string, object> current in dictionary)
                {
                    result.ResultDictionary[current.Key] = current.Value;
                }
            }
            if (result.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey) && !result.ResultDictionary.ContainsKey(LoginResult.PermissionsKey))
            {
                Dictionary <string, string> formData = new Dictionary <string, string>
                {
                    {
                        "fields",
                        "permissions"
                    },
                    {
                        "access_token",
                        (string)result.ResultDictionary[LoginResult.AccessTokenKey]
                    }
                };
                FacebookDelegate <IGraphResult> callback2 = delegate(IGraphResult r)
                {
                    IDictionary <string, object> dictionary2;
                    if (r.ResultDictionary != null && r.ResultDictionary.TryGetValue("permissions", out dictionary2))
                    {
                        IList <string> list = new List <string>();
                        IList <object> list2;
                        if (dictionary2.TryGetValue("data", out list2))
                        {
                            foreach (object current2 in list2)
                            {
                                IDictionary <string, object> dictionary3 = current2 as IDictionary <string, object>;
                                if (dictionary3 != null)
                                {
                                    string text;
                                    if (dictionary3.TryGetValue("status", out text) && text.Equals("granted", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        string item;
                                        if (dictionary3.TryGetValue("permission", out item))
                                        {
                                            list.Add(item);
                                        }
                                        else
                                        {
                                            FacebookLogger.Warn("Didn't find permission name");
                                        }
                                    }
                                    else
                                    {
                                        FacebookLogger.Warn("Didn't find status in permissions result");
                                    }
                                }
                                else
                                {
                                    FacebookLogger.Warn("Failed to case permission dictionary");
                                }
                            }
                        }
                        else
                        {
                            FacebookLogger.Warn("Failed to extract data from permissions");
                        }
                        result.ResultDictionary[LoginResult.PermissionsKey] = list.ToCommaSeparateList();
                    }
                    else
                    {
                        FacebookLogger.Warn("Failed to load permissions for access token");
                    }
                    callback(result);
                };
                FB.API("me", HttpMethod.GET, callback2, formData);
            }
            else
            {
                callback(result);
            }
        }