public static void Init(string appId, bool cookie = true, bool logging = true, bool status = true, bool xfbml = false, bool frictionlessRequests = true, string authResponse = null, string javascriptSDKLocale = "en_US", HideUnityDelegate onHideUnity = null, InitDelegate onInitComplete = null) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentException("appId cannot be null or empty!"); } FB.AppId = appId; if (!FB.isInitCalled) { FB.isInitCalled = true; if (Constants.IsEditor) { FB.OnDLLLoadedDelegate = delegate { ((EditorFacebook)FB.facebook).Init(onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <EditorFacebookLoader>(ComponentFactory.IfNotExist.AddNew); } else { switch (Constants.CurrentPlatform) { case FacebookUnityPlatform.Android: FB.OnDLLLoadedDelegate = delegate { ((AndroidFacebook)FB.facebook).Init(appId, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <AndroidFacebookLoader>(ComponentFactory.IfNotExist.AddNew); break; case FacebookUnityPlatform.IOS: FB.OnDLLLoadedDelegate = delegate { ((IOSFacebook)FB.facebook).Init(appId, frictionlessRequests, FacebookSettings.IosURLSuffix, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <IOSFacebookLoader>(ComponentFactory.IfNotExist.AddNew); break; case FacebookUnityPlatform.WebGL: case FacebookUnityPlatform.WebPlayer: FB.OnDLLLoadedDelegate = delegate { ((CanvasFacebook)FB.facebook).Init(appId, cookie, logging, status, xfbml, FacebookSettings.ChannelUrl, authResponse, frictionlessRequests, javascriptSDKLocale, Constants.DebugMode, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <CanvasFacebookLoader>(ComponentFactory.IfNotExist.AddNew); break; default: throw new NotImplementedException("Facebook API does not yet support this platform"); } } } else { FacebookLogger.Warn("FB.Init() has already been called. You only need to call this once and only once."); } }
public static T GetValueOrDefault <T>(IDictionary <string, object> dictionary, string key, [Optional, DefaultParameterValue(true)] bool logWarning) { T local; if (!TryGetValue <T>(dictionary, key, out local)) { string[] args = new string[] { key }; FacebookLogger.Warn("Did not find expected value '{0}' in dictionary", args); } return(local); }
/// <summary> /// If you need a more programmatic way to set the facebook app id and other setting call this function. /// Useful for a build pipeline that requires no human input. /// </summary> /// <param name="appId">App identifier.</param> /// <param name="cookie">If set to <c>true</c> cookie.</param> /// <param name="logging">If set to <c>true</c> logging.</param> /// <param name="status">If set to <c>true</c> status.</param> /// <param name="xfbml">If set to <c>true</c> xfbml.</param> /// <param name="frictionlessRequests">If set to <c>true</c> frictionless requests.</param> /// <param name="authResponse">Auth response.</param> /// <param name="onHideUnity"> /// A delegate to invoke when unity is hidden. /// </param> /// <param name="onInitComplete"> /// Delegate is called when FB.Init() finished initializing everything. By passing in a delegate you can find /// out when you can safely call the other methods. /// </param> public static void Init( string appId, bool cookie = true, bool logging = true, bool status = true, bool xfbml = false, bool frictionlessRequests = true, string authResponse = null, HideUnityDelegate onHideUnity = null, InitDelegate onInitComplete = null) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentException("appId cannot be null or empty!"); } FB.appId = appId; FB.cookie = cookie; FB.logging = logging; FB.status = status; FB.xfbml = xfbml; FB.frictionlessRequests = frictionlessRequests; FB.authResponse = authResponse; FB.onInitComplete = onInitComplete; FB.onHideUnity = onHideUnity; if (!isInitCalled) { FB.LogVersion(); #if UNITY_EDITOR ComponentFactory.GetComponent <EditorFacebookLoader>(); #elif UNITY_WEBPLAYER || UNITY_WEBGL ComponentFactory.GetComponent <CanvasFacebookLoader>(); #elif UNITY_IOS ComponentFactory.GetComponent <IOSFacebookLoader>(); #elif UNITY_ANDROID ComponentFactory.GetComponent <AndroidFacebookLoader>(); #else throw new NotImplementedException("Facebook API does not yet support this platform"); #endif isInitCalled = true; return; } FacebookLogger.Warn("FB.Init() has already been called. You only need to call this once and only once."); // Init again if possible just in case something bad actually happened. if (FacebookImpl != null) { OnDllLoaded(); } }
public static T GetValueOrDefault <T>(this IDictionary <string, object> dictionary, string key, bool logWarning = true) { T result; if (!dictionary.TryGetValue(key, out result) && logWarning) { FacebookLogger.Warn("Did not find expected value '{0}' in dictionary", new string[] { key }); } return(result); }
public static T GetValueOrDefault <T>( this IDictionary <string, object> dictionary, string key, bool logWarning = true) { T result; if (!dictionary.TryGetValue <T>(key, out result) && logWarning) { FacebookLogger.Warn(WarningMissingParameter, key); } return(result); }
private static ICollection <string> ParsePermissionFromResult(IDictionary <string, object> resultDictionary) { string str; IEnumerable <object> enumerable; if (TryGetValue <string>(resultDictionary, LoginResult.PermissionsKey, out str)) { char[] separator = new char[] { ',' }; enumerable = str.Split(separator); } else if (!TryGetValue <IEnumerable <object> >(resultDictionary, LoginResult.PermissionsKey, out enumerable)) { enumerable = new string[0]; string[] args = new string[] { LoginResult.PermissionsKey }; FacebookLogger.Warn("Failed to find parameter '{0}' in login result", args); } if (< > f__am$cache0 == null) {
private static ICollection <string> ParsePermissionFromResult(IDictionary <string, object> resultDictionary) { string permissions; IEnumerable <object> permissionList; // For permissions we can get the result back in either a comma separated string or // a list depending on the platform. if (resultDictionary.TryGetValue(LoginResult.PermissionsKey, out permissions)) { permissionList = permissions.Split(','); } else if (!resultDictionary.TryGetValue(LoginResult.PermissionsKey, out permissionList)) { permissionList = new string[0]; FacebookLogger.Warn("Failed to find parameter '{0}' in login result", LoginResult.PermissionsKey); } return(permissionList.Select(permission => permission.ToString()).ToList()); }
private static ICollection <string> ParsePermissionFromResult(IDictionary <string, object> resultDictionary) { string text; IEnumerable <object> source; if (resultDictionary.TryGetValue(LoginResult.PermissionsKey, out text)) { source = text.Split(new char[] { ',' }); } else if (!resultDictionary.TryGetValue(LoginResult.PermissionsKey, out source)) { source = new string[0]; FacebookLogger.Warn("Failed to find parameter '{0}' in login result", new string[] { LoginResult.PermissionsKey }); } return((from permission in source select permission.ToString()).ToList <string>()); }
public static void Warn(string format, params string[] args) { FacebookLogger.Warn(string.Format(format, args)); }