예제 #1
0
        public void Init(string appId, bool cookie, bool logging, bool status, bool xfbml, string channelUrl, string authResponse, bool frictionlessRequests, string javascriptSDKLocale, bool loadDebugJSSDK, HideUnityDelegate hideUnityDelegate, InitDelegate onInitComplete)
        {
            if (this.canvasJSWrapper.IntegrationMethodJs == null)
            {
                throw new Exception("Cannot initialize facebook javascript");
            }
            base.Init(hideUnityDelegate, onInitComplete);
            this.canvasJSWrapper.ExternalEval(this.canvasJSWrapper.IntegrationMethodJs);
            this.appId = appId;
            bool            flag            = true;
            MethodArguments methodArguments = new MethodArguments();

            methodArguments.AddString("appId", appId);
            methodArguments.AddPrimative <bool>("cookie", cookie);
            methodArguments.AddPrimative <bool>("logging", logging);
            methodArguments.AddPrimative <bool>("status", status);
            methodArguments.AddPrimative <bool>("xfbml", xfbml);
            methodArguments.AddString("channelUrl", channelUrl);
            methodArguments.AddString("authResponse", authResponse);
            methodArguments.AddPrimative <bool>("frictionlessRequests", frictionlessRequests);
            methodArguments.AddString("version", FB.GraphApiVersion);
            this.canvasJSWrapper.ExternalCall("FBUnity.init", new object[]
            {
                (!flag) ? 0 : 1,
                "https://connect.facebook.net",
                javascriptSDKLocale,
                (!loadDebugJSSDK) ? 0 : 1,
                methodArguments.ToJsonString(),
                (!status) ? 0 : 1
            });
        }
예제 #2
0
        public override void Init(
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            HideUnityDelegate hideUnityDelegate,
            InitDelegate onInitComplete)
        {
            if (CanvasFacebook.IntegrationMethodJs == null)
            {
                throw new Exception("Cannot initialize facebook javascript");
            }

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

            Application.ExternalEval(CanvasFacebook.IntegrationMethodJs);
            this.appId = appId;

            bool isPlayer = true;

            #if UNITY_WEBGL
            isPlayer = false;
            #endif

            MethodArguments parameters = new MethodArguments();
            parameters.AddString("appId", appId);
            parameters.AddPrimative("cookie", cookie);
            parameters.AddPrimative("logging", logging);
            parameters.AddPrimative("status", status);
            parameters.AddPrimative("xfbml", xfbml);
            parameters.AddString("channelUrl", channelUrl);
            parameters.AddString("authResponse", authResponse);
            parameters.AddPrimative("frictionlessRequests", frictionlessRequests);
            parameters.AddString("version", SDKVersion);

            // use 1/0 for booleans, otherwise you'll get strings "True"/"False"
            Application.ExternalCall(
                "FBUnity.init",
                isPlayer ? 1 : 0,
                FacebookConnectURL,
                SDKLocale,
                this.sdkDebug ? 1 : 0,
                parameters.ToJsonString(),
                status ? 1 : 0);
        }
예제 #3
0
        public override void SetDataProcessingOptions(IEnumerable <string> options, int country, int state)
        {
            var args = new MethodArguments();

            args.AddList <string>("options", options);
            args.AddPrimative <int>("country", country);
            args.AddPrimative <int>("state", state);
            this.CallFB("SetDataProcessingOptions", args.ToJsonString());
        }
예제 #4
0
        private void PayImpl(
            string product,
            string productId,
            string action,
            int quantity,
            int?quantityMin,
            int?quantityMax,
            string requestId,
            string pricepointId,
            string testCurrency,
            FacebookDelegate <IPayResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.AddString("product", product);
            args.AddString("product_id", productId);
            args.AddString("action", action);
            args.AddPrimative("quantity", quantity);
            args.AddNullablePrimitive("quantity_min", quantityMin);
            args.AddNullablePrimitive("quantity_max", quantityMax);
            args.AddString("request_id", requestId);
            args.AddString("pricepoint_id", pricepointId);
            args.AddString("test_currency", testCurrency);
            var call = new CanvasUIMethodCall <IPayResult>(this, MethodPay, Constants.OnPayCompleteMethodName);

            call.Callback = callback;
            call.Call(args);
        }
        public override void SharePhoto(
            Texture2D texture2D,
            Uri photoURL,
            bool userGenerated,
            string caption,
            FacebookDelegate <IShareResult> callback)
        {
            MethodArguments args = new MethodArguments();

            if (texture2D != null)
            {
                var tempPhotoPath = Utilities.SaveTexture2DtoPNG(texture2D, "tempSharePhoto");
                args.AddUri("photo_url", new Uri(tempPhotoPath));
            }
            else if (photoURL != null)
            {
                args.AddUri("photo_url", photoURL);
            }
            args.AddPrimative("user_generated", userGenerated);
            args.AddString("caption", caption);
            var sharePhotoCall = new JavaMethodCall <IShareResult>(this, "SharePhoto");

            sharePhotoCall.Callback = callback;
            sharePhotoCall.Call(args);
        }
예제 #6
0
        public override void Init(
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            HideUnityDelegate hideUnityDelegate,
            InitDelegate onInitComplete)
        {
            // Set the user agent suffix for graph requests
            // This should be set before a call to init to ensure that
            // requests made during init include this suffix.
            this.CallFB(
                "SetUserAgentSuffix",
                string.Format("Unity.{0}", Constants.UnitySDKUserAgentSuffixLegacy));

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

            var args = new MethodArguments();

            args.AddString("appId", appId);
            args.AddPrimative("cookie", cookie);
            args.AddPrimative("logging", logging);
            args.AddPrimative("status", status);
            args.AddPrimative("xfbml", xfbml);
            args.AddString("channelUrl", channelUrl);
            args.AddString("authResponse", authResponse);
            args.AddPrimative("frictionlessRequests", frictionlessRequests);
            var initCall = new JavaMethodCall <IResult>(this, "Init");

            initCall.Call(args);
        }
예제 #7
0
        public override void CallKeepScreenOn(bool isKeepScreenOn)
        {
            MethodArguments args = new MethodArguments();

            args.AddPrimative("isKeepScreenOn", true);
            var keepScreenOnCall = new JavaMethodCall <IResult> (this, "KeepScreenOn");

            keepScreenOnCall.Call(args);
        }
예제 #8
0
        public override void AppEventsLogPurchase(float logPurchase, string currency, Dictionary <string, object> parameters)
        {
            MethodArguments methodArguments = new MethodArguments();

            methodArguments.AddPrimative <float>("logPurchase", logPurchase);
            methodArguments.AddString("currency", currency);
            methodArguments.AddDictionary("parameters", parameters);
            AndroidFacebook.JavaMethodCall <IResult> javaMethodCall = new AndroidFacebook.JavaMethodCall <IResult>(this, "LogAppEvent");
            javaMethodCall.Call(methodArguments);
        }
예제 #9
0
        public void Init(
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            string javascriptSDKLocale,
            bool loadDebugJSSDK,
            HideUnityDelegate hideUnityDelegate,
            InitDelegate onInitComplete)
        {
            base.Init(onInitComplete);

            this.canvasJSWrapper.ExternalEval(CanvasConstants.JSSDKBindings);
            this.appId = appId;
            this.onHideUnityDelegate = hideUnityDelegate;

            MethodArguments parameters = new MethodArguments();

            parameters.AddString("appId", appId);
            parameters.AddPrimative("cookie", cookie);
            parameters.AddPrimative("logging", logging);
            parameters.AddPrimative("status", status);
            parameters.AddPrimative("xfbml", xfbml);
            parameters.AddString("channelUrl", channelUrl);
            parameters.AddString("authResponse", authResponse);
            parameters.AddPrimative("frictionlessRequests", frictionlessRequests);
            parameters.AddString("version", FB.GraphApiVersion);

            // use 1/0 for booleans, otherwise you'll get strings "True"/"False"
            this.canvasJSWrapper.ExternalCall(
                "FBUnity.init",
                FacebookConnectURL,
                javascriptSDKLocale,
                loadDebugJSSDK ? 1 : 0,
                parameters.ToJsonString(),
                status ? 1 : 0);
        }
예제 #10
0
        public override void Init(
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            HideUnityDelegate hideUnityDelegate,
            InitDelegate onInitComplete)
        {
            base.Init(
                appId,
                cookie,
                logging,
                status,
                xfbml,
                channelUrl,
                authResponse,
                frictionlessRequests,
                hideUnityDelegate,
                onInitComplete);

            var args = new MethodArguments();

            args.AddString("appId", appId);
            args.AddPrimative("cookie", cookie);
            args.AddPrimative("logging", logging);
            args.AddPrimative("status", status);
            args.AddPrimative("xfbml", xfbml);
            args.AddString("channelUrl", channelUrl);
            args.AddString("authResponse", authResponse);
            args.AddPrimative("frictionlessRequests", frictionlessRequests);
            var initCall = new JavaMethodCall <IResult>(this, "Init");

            initCall.Call(args);
            this.CallFB(
                "SetUserAgentSuffix",
                string.Format("Unity.{0}", Facebook.Unity.FacebookSdkVersion.Build));
        }
예제 #11
0
        public override void AppEventsLogPurchase(
            float logPurchase,
            string currency,
            Dictionary <string, object> parameters)
        {
            MethodArguments args = new MethodArguments();

            args.AddPrimative("logPurchase", logPurchase);
            args.AddString("currency", currency);
            args.AddDictionary("parameters", parameters);
            var logPurchaseCall = new JavaMethodCall <IResult>(this, "LogAppEvent");

            logPurchaseCall.Call(args);
        }
예제 #12
0
        private void PayImpl(string product, string action, int quantity, int?quantityMin, int?quantityMax, string requestId, string pricepointId, string testCurrency, FacebookDelegate <IPayResult> callback)
        {
            MethodArguments methodArguments = new MethodArguments();

            methodArguments.AddString("product", product);
            methodArguments.AddString("action", action);
            methodArguments.AddPrimative <int>("quantity", quantity);
            methodArguments.AddNullablePrimitive <int>("quantity_min", quantityMin);
            methodArguments.AddNullablePrimitive <int>("quantity_max", quantityMax);
            methodArguments.AddString("request_id", requestId);
            methodArguments.AddString("pricepoint_id", pricepointId);
            methodArguments.AddString("test_currency", testCurrency);
            new CanvasFacebook.CanvasUIMethodCall <IPayResult>(this, "pay", "OnPayComplete")
            {
                Callback = callback
            }.Call(methodArguments);
        }
예제 #13
0
        public override void ScheduleAppToUserNotification(
            string title,
            string body,
            Uri media,
            int timeInterval,
            string payload,
            FacebookDelegate <IScheduleAppToUserNotificationResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.AddString("title", title);
            args.AddString("body", body);
            args.AddUri("media", media);
            args.AddPrimative("timeInterval", timeInterval);
            args.AddString("payload", payload);
            var scheduleAppToUserNotification = new JavaMethodCall <IScheduleAppToUserNotificationResult>(
                this,
                "ScheduleAppToUserNotification")
            {
                Callback = callback
            };

            scheduleAppToUserNotification.Call(args);
        }