Exemplo n.º 1
0
        public override void Init(
            InitDelegate onInitComplete,
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            HideUnityDelegate hideUnityDelegate)
        {
            if (string.IsNullOrEmpty(appId))
            {
                throw new ArgumentException("appId cannot be null or empty!");
            }

            var args = new MethodArguments();

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

            initCall.call(args);
            this.CallFB("SetUserAgentSuffix",
                        String.Format("Unity.{0}", Facebook.Unity.FacebookSdkVersion.Build));
        }
Exemplo n.º 2
0
        public override void Init(
            InitDelegate onInitComplete,
            string appId,
            bool cookie,
            bool logging,
            bool status,
            bool xfbml,
            string channelUrl,
            string authResponse,
            bool frictionlessRequests,
            HideUnityDelegate hideUnityDelegate)
        {
            if (string.IsNullOrEmpty(appId))
            {
                throw new ArgumentException("appId cannot be null or empty!");
            }

            if (CanvasFacebook.IntegrationMethodJs == null)
            {
                throw new Exception("Cannot initialize facebook javascript");
            }

            this.onInitComplete      = onInitComplete;
            this.OnHideUnityDelegate = hideUnityDelegate;
            Application.ExternalEval(CanvasFacebook.IntegrationMethodJs);
            this.appId = appId;

            bool isPlayer = true;

            #if UNITY_WEBGL
            isPlayer = false;
            #endif

            MethodArguments parameters = new MethodArguments();
            parameters.addNonNullOrEmptyParameter("appId", appId);
            parameters.addNonNullParameter("cookie", cookie);
            parameters.addNonNullParameter("logging", logging);
            parameters.addNonNullParameter("status", status);
            parameters.addNonNullParameter("xfbml", xfbml);
            parameters.addNonNullOrEmptyParameter("channelUrl", channelUrl);
            parameters.addNonNullOrEmptyParameter("authResponse", authResponse);
            parameters.addNonNullParameter("frictionlessRequests", frictionlessRequests);
            parameters.addNonNullOrEmptyParameter("version", SDKVersion);
            // use 1/0 for booleans, otherwise you'll get strings "True"/"False"
            Application.ExternalCall(
                "FBUnity.init",
                isPlayer ? 1 : 0,
                FacebookConnectURL,
                sdkLocale,
                sdkDebug ? 1 : 0,
                parameters.ToJsonString(),
                status ? 1 : 0);
        }
Exemplo n.º 3
0
        public override void GameGroupJoin(
            string id,
            FacebookDelegate <IGroupJoinResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("id", id);
            args.addNonNullOrEmptyParameter("display", "async");
            var call = new CanvasUIMethodCall <IGroupJoinResult>(this, MethodGameGroupJoin, Constants.OnJoinGroupCompleteMethodName);

            call.Callback = callback;
            call.call(args);
        }
Exemplo n.º 4
0
        public void Pay(
            string product,
            string action,
            int quantity,
            int?quantityMin,
            int?quantityMax,
            string requestId,
            string pricepointId,
            string testCurrency,
            FacebookDelegate <IPayResult> callback)
        {
            MethodArguments args = new MethodArguments();

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

            call.Callback = callback;
            call.call(args);
        }
Exemplo n.º 5
0
        public override void GameGroupCreate(
            string name,
            string description,
            string privacy,
            FacebookDelegate <IGroupCreateResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("name", name);
            args.addNonNullOrEmptyParameter("description", description);
            args.addNonNullOrEmptyParameter("privacy", privacy);
            var gameGroupCreate = new JavaMethodCall <IGroupCreateResult>(this, "GameGroupCreate");

            gameGroupCreate.Callback = callback;
            gameGroupCreate.call(args);
        }
Exemplo n.º 6
0
        public override void GameGroupCreate(
            string name,
            string description,
            string privacy,
            FacebookDelegate <IGroupCreateResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("name", name);
            args.addNonNullOrEmptyParameter("description", description);
            args.addNonNullOrEmptyParameter("privacy", privacy);
            args.addNonNullOrEmptyParameter("display", "async");
            var call = new CanvasUIMethodCall <IGroupCreateResult>(this, MethodGameGroupCreate, Constants.OnGroupCreateCompleteMethodName);

            call.Callback = callback;
            call.call(args);
        }
Exemplo n.º 7
0
            private void UI(
                string method,
                MethodArguments args,
                FacebookDelegate <T> callback = null)
            {
                if (Screen.fullScreen)
                {
                    Screen.fullScreen = false;
                }

                var clonedArgs = new MethodArguments(args);

                clonedArgs.addNonNullOrEmptyParameter("app_id", this.canvasImpl.appId);
                clonedArgs.addNonNullOrEmptyParameter("method", method);
                var uniqueId = this.canvasImpl.CallbackManager.AddFacebookDelegate(callback);

                Application.ExternalCall("FBUnity.ui", clonedArgs.ToJsonString(), uniqueId, this.callbackMethod);
            }
Exemplo n.º 8
0
        public override void ShareLink(
            string contentURL,
            string contentTitle,
            string contentDescription,
            string photoURL,
            FacebookDelegate <IShareResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("link", contentURL);
            args.addNonNullOrEmptyParameter("name", contentTitle);
            args.addNonNullOrEmptyParameter("description", contentDescription);
            args.addNonNullOrEmptyParameter("picture", photoURL);
            var call = new CanvasUIMethodCall <IShareResult>(this, MethodFeed, Constants.OnShareCompleteMethodName);

            call.Callback = callback;
            call.call(args);
        }
Exemplo n.º 9
0
        public override void ShareLink(
            string contentURL,
            string contentTitle,
            string contentDescription,
            string photoURL,
            FacebookDelegate <IShareResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("content_url", contentURL);
            args.addNonNullOrEmptyParameter("content_title", contentTitle);
            args.addNonNullOrEmptyParameter("content_description", contentDescription);
            args.addNonNullOrEmptyParameter("photo_url", photoURL);
            var shareLinkCall = new JavaMethodCall <IShareResult>(this, "ShareLink");

            shareLinkCall.Callback = callback;
            shareLinkCall.call(args);
        }
Exemplo n.º 10
0
        public override void LogInWithReadPermissions(
            string scope,
            FacebookDelegate <ILoginResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("scope", scope);
            AddAuthDelegate(callback);
            var loginCall = new JavaMethodCall <IResult>(this, "LoginWithReadPermissions");

            loginCall.call(args);
        }
Exemplo n.º 11
0
        public override void AppRequest(
            string message,
            OGActionType actionType,
            string objectId,
            string[] to,
            List <object> filters,
            string[] excludeIds,
            int?maxRecipients,
            string data,
            string title,
            FacebookDelegate <IAppRequestResult> callback)
        {
            ValidateAppRequestArgs(
                message,
                actionType,
                objectId,
                to,
                filters,
                excludeIds,
                maxRecipients,
                data,
                title,
                callback
                );

            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("message", message);
            args.addNonNullOrEmptyParameter("action_type", actionType != null ? actionType.ToString() : null);
            args.addNonNullOrEmptyParameter("object_id", objectId);
            args.addCommaSeperateListNonNull("to", to);
            if (filters != null && filters.Count > 0)
            {
                string mobileFilter = filters[0] as string;
                if (mobileFilter != null)
                {
                    args.addNonNullOrEmptyParameter("filters", mobileFilter);
                }
            }
            args.addNonNullOrEmptyParameter("max_recipients", maxRecipients);
            args.addNonNullOrEmptyParameter("data", data);
            args.addNonNullOrEmptyParameter("title", title);
            var appRequestCall = new JavaMethodCall <IAppRequestResult>(this, "AppRequest");

            appRequestCall.Callback = callback;
            appRequestCall.call(args);
        }
Exemplo n.º 12
0
        public override void FeedShare(
            string toId,
            Uri link,
            string linkName,
            string linkCaption,
            string linkDescription,
            Uri picture,
            string mediaSource,
            FacebookDelegate <IShareResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("to", toId);
            args.addNonNullOrEmptyParameter("link", link);
            args.addNonNullOrEmptyParameter("name", linkName);
            args.addNonNullOrEmptyParameter("caption", linkCaption);
            args.addNonNullOrEmptyParameter("description", linkDescription);
            args.addNonNullOrEmptyParameter("picture", picture);
            args.addNonNullOrEmptyParameter("source", mediaSource);
            var call = new CanvasUIMethodCall <IShareResult>(this, MethodFeed, Constants.OnShareCompleteMethodName);

            call.Callback = callback;
            call.call(args);
        }
Exemplo n.º 13
0
        public override void FeedShare(
            string toId,
            Uri link,
            string linkName,
            string linkCaption,
            string linkDescription,
            Uri picture,
            string mediaSource,
            FacebookDelegate <IShareResult> callback)
        {
            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("toId", toId);
            args.addNonNullOrEmptyParameter("link", link);
            args.addNonNullOrEmptyParameter("linkName", linkName);
            args.addNonNullOrEmptyParameter("linkCaption", linkCaption);
            args.addNonNullOrEmptyParameter("linkDescription", linkDescription);
            args.addNonNullOrEmptyParameter("picture", picture);
            args.addNonNullOrEmptyParameter("mediaSource", mediaSource);
            var call = new JavaMethodCall <IShareResult>(this, "FeedShare");

            call.Callback = callback;
            call.call(args);
        }
Exemplo n.º 14
0
        public override void AppRequest(
            string message,
            OGActionType actionType,
            string objectId,
            string[] to,
            List <object> filters,
            string[] excludeIds,
            int?maxRecipients,
            string data,
            string title,
            FacebookDelegate <IAppRequestResult> callback)
        {
            ValidateAppRequestArgs(
                message,
                actionType,
                objectId,
                to,
                filters,
                excludeIds,
                maxRecipients,
                data,
                title,
                callback
                );

            MethodArguments args = new MethodArguments();

            args.addNonNullOrEmptyParameter("message", message);
            args.addCommaSeperateListNonNull("to", to);
            args.addNonNullOrEmptyParameter("action_type", actionType != null ? actionType.ToString() : null);
            args.addNonNullOrEmptyParameter("object_id", objectId);
            args.addNonNullParameter("filters", filters);
            args.addNonNullParameter("exclude_ids", excludeIds);
            args.addNonNullOrEmptyParameter("max_recipients", maxRecipients);
            args.addNonNullOrEmptyParameter("data", data);
            args.addNonNullOrEmptyParameter("title", title);
            var call = new CanvasUIMethodCall <IResult>(this, MethodAppRequests, Constants.OnAppRequestsCompleteMethodName);

            call.call(args);
        }