/// <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="clientToken">App client token.</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="javascriptSDKLocale"> /// The locale of the js sdk used see /// https://developers.facebook.com/docs/internationalization#plugins. /// </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, string clientToken = null, bool cookie = true, bool logging = true, bool status = true, bool xfbml = false, bool frictionlessRequests = true, string authResponse = null, string javascriptSDKLocale = FB.DefaultJSSDKLocale, HideUnityDelegate onHideUnity = null, InitDelegate onInitComplete = null) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentException("appId cannot be null or empty!"); } FB.AppId = appId; FB.ClientToken = clientToken; if (!isInitCalled) { isInitCalled = true; if (Constants.IsEditor) { FB.OnDLLLoadedDelegate = delegate { ((EditorFacebook)FB.facebook).Init(onInitComplete); }; ComponentFactory.GetComponent<EditorFacebookLoader>(); } else { switch (Constants.CurrentPlatform) { case FacebookUnityPlatform.WebGL: FB.OnDLLLoadedDelegate = delegate { ((CanvasFacebook)FB.facebook).Init( appId, cookie, logging, status, xfbml, FacebookSettings.ChannelUrl, authResponse, frictionlessRequests, javascriptSDKLocale, Constants.DebugMode, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<CanvasFacebookLoader>(); break; case FacebookUnityPlatform.IOS: FB.OnDLLLoadedDelegate = delegate { ((IOSFacebook)FB.facebook).Init( appId, frictionlessRequests, FacebookSettings.IosURLSuffix, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<IOSFacebookLoader>(); break; case FacebookUnityPlatform.Android: FB.OnDLLLoadedDelegate = delegate { ((AndroidFacebook)FB.facebook).Init( appId, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<AndroidFacebookLoader>(); break; case FacebookUnityPlatform.Arcade: FB.OnDLLLoadedDelegate = delegate { ((ArcadeFacebook)FB.facebook).Init(appId, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent<ArcadeFacebookLoader>(); break; default: throw new NotSupportedException("The facebook sdk does not support this platform"); } } } else { FacebookLogger.Warn("FB.Init() has already been called. You only need to call this once and only once."); } }
/// <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="clientToken">App client token.</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="javascriptSDKLocale"> /// The locale of the js sdk used see /// https://developers.facebook.com/docs/internationalization#plugins. /// </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, string clientToken = null, bool cookie = true, bool logging = true, bool status = true, bool xfbml = false, bool frictionlessRequests = true, string authResponse = null, string javascriptSDKLocale = FB.DefaultJSSDKLocale, HideUnityDelegate onHideUnity = null, InitDelegate onInitComplete = null) { if (string.IsNullOrEmpty(appId)) { throw new ArgumentException("appId cannot be null or empty!"); } FB.AppId = appId; FB.ClientToken = clientToken; if (!isInitCalled) { isInitCalled = true; if (Constants.IsEditor) { FB.OnDLLLoadedDelegate = delegate { ((EditorFacebook)FB.facebook).Init(onInitComplete); }; ComponentFactory.GetComponent <EditorFacebookLoader>(); } else { switch (Constants.CurrentPlatform) { case FacebookUnityPlatform.WebGL: FB.OnDLLLoadedDelegate = delegate { ((CanvasFacebook)FB.facebook).Init( appId, cookie, logging, status, xfbml, FacebookSettings.ChannelUrl, authResponse, frictionlessRequests, javascriptSDKLocale, Constants.DebugMode, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <CanvasFacebookLoader>(); break; case FacebookUnityPlatform.IOS: FB.OnDLLLoadedDelegate = delegate { ((IOSFacebook)FB.facebook).Init( appId, frictionlessRequests, FacebookSettings.IosURLSuffix, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <IOSFacebookLoader>(); break; case FacebookUnityPlatform.Android: FB.OnDLLLoadedDelegate = delegate { ((AndroidFacebook)FB.facebook).Init( appId, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <AndroidFacebookLoader>(); break; case FacebookUnityPlatform.Gameroom: FB.OnDLLLoadedDelegate = delegate { ((GameroomFacebook)FB.facebook).Init(appId, onHideUnity, onInitComplete); }; ComponentFactory.GetComponent <GameroomFacebookLoader>(); break; default: throw new NotSupportedException("The facebook sdk does not support this platform"); } } } else { FacebookLogger.Warn("FB.Init() has already been called. You only need to call this once and only once."); } }