Пример #1
0
        /// <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.");
            }
        }
        public IFacebookScheduler GetInstance()
        {
            FacebookScheduler scheduler = ComponentFactory.GetComponent <FacebookScheduler>();

            return(scheduler);
        }
Пример #3
0
 internal static void Request(Uri url, HttpMethod method, IDictionary <string, string> formData = null, FacebookDelegate <IGraphResult> callback = null)
 {
     ComponentFactory.AddComponent <AsyncRequestString>().SetUrl(url).SetMethod(method).SetFormData(formData).SetCallback(callback);
 }
Пример #4
0
 internal static void Request(Uri url, HttpMethod method, WWWForm query = null, FacebookDelegate <IGraphResult> callback = null)
 {
     ComponentFactory.AddComponent <AsyncRequestString>().SetUrl(url).SetMethod(method).SetQuery(query).SetCallback(callback);
 }
Пример #5
0
 internal static void Request(Uri url, HttpMethod method, [Optional, DefaultParameterValue(null)] WWWForm query, [Optional, DefaultParameterValue(null)] FacebookDelegate <IGraphResult> callback)
 {
     ComponentFactory.AddComponent <AsyncRequestString>().SetUrl(url).SetMethod(method).SetQuery(query).SetCallback(callback);
 }
Пример #6
0
 internal static void Request(Uri url, HttpMethod method, [Optional, DefaultParameterValue(null)] IDictionary <string, string> formData, [Optional, DefaultParameterValue(null)] FacebookDelegate <IGraphResult> callback)
 {
     ComponentFactory.AddComponent <AsyncRequestString>().SetUrl(url).SetMethod(method).SetFormData(formData).SetCallback(callback);
 }