Ejemplo n.º 1
0
    protected void messageCallBack(WebView webview, WebViewMessage message)
    {
        switch (message.Host)
        {
        case (WEBVIEW_LOGIN):
            saveUserInfo(message.Arguments ["userId"], message.Arguments ["tokenId"], message.Arguments["displayName"]);
            loginToShopika(ShopikaManager.GetCastedInstance <ShopikaManager> ().currentUserId,
                           ShopikaManager.GetCastedInstance <ShopikaManager> ().currentUser.accesToken);

            if (OnLoggedIn != null)
            {
                OnLoggedIn();
            }

            break;

        case (WEBVIEW_GEMS):
            if (!((DataManagerKubera)DataManagerKubera.GetInstance()).alreadyPurchaseGems())
            {
                KuberaAnalytics.GetInstance().registerGemsFirstPurchase(PersistentData.GetInstance().lastLevelReachedName);
                ((DataManagerKubera)DataManagerKubera.GetInstance()).markGemsAsPurchased();
            }

            ShopikaManager.GetCastedInstance <ShopikaManager>().OnGemsRemotleyChanged();
            break;

        case (WEBVIEW_FINISH):
            closeWebView();
            ShopikaManager.GetCastedInstance <ShopikaManager>().OnGemsRemotleyChanged();
            break;
        }
    }
 protected void WebViewDidReceiveMessage(WebView _webview, WebViewMessage _message)
 {
     // Send event
     if (_webview != null)
     {
         _webview.InvokeMethod(kOnDidReceiveMessageEvent, _message);
     }
 }
Ejemplo n.º 3
0
 private void DidReceiveMessageEvent(WebView _webview, WebViewMessage _message)
 {
     AddNewResult("Received a new message from web view.");
     AppendResult(string.Format("Host: {0}.", _message.Host));
     AppendResult(string.Format("Scheme: {0}.", _message.Scheme));
     AppendResult(string.Format("URL: {0}.", _message.URL));
     AppendResult(string.Format("Arguments: {0}.", _message.Arguments.ToJSON()));
 }
Ejemplo n.º 4
0
        protected void WebViewDidReceiveMessage(WebView _webview, WebViewMessage _message)
        {
            Console.Log(Constants.kDebugTag, "[WebView] Received DidReceiveMessage event, Webview=" + _webview + " " + "Message=" + _message);

            if (_webview != null)
            {
                _webview.InvokeMethod(kOnDidReceiveMessageEvent, _message);
            }
        }
Ejemplo n.º 5
0
    protected void receiveMessageEvent(WebView webview, WebViewMessage message)
    {
        //Debug.Log("Received a new message from web view.");
        //Debug.Log(string.Format("Host: {0}.",         message.Host));
        //Debug.Log(string.Format("Scheme: {0}.",       message.Scheme));
        //Debug.Log(string.Format("URL: {0}.",      message.URL));
        //Debug.Log(string.Format("Arguments: {0}.",    message.Arguments.ToJSON()));

        if (webViewMessagesSubscriptors.ContainsKey(message.Scheme))
        {
            webViewMessagesSubscriptors [message.Scheme].action(webview, message);
        }
    }
Ejemplo n.º 6
0
        private void DoAction()
        {
#if USES_WEBVIEW
            try
            {
                WebViewMessage _message = WebViewUtils.message;

                if (_message == null || _message.Arguments == null)
                {
                    OnActionDidFail();
                    return;
                }

                // Fetch the value
                int _iter = 0;

                foreach (KeyValuePair <string, string> _pair in _message.Arguments)
                {
                    if (_iter == atIndex.Value)
                    {
                        // Update the properties
                        argumentKey.Value   = _pair.Key;
                        argumentValue.Value = _pair.Value;

                        // Invoke handler
                        OnActionDidFinish();

                        return;
                    }

                    // Increment index
                    _iter++;
                }

                // Item is not found at given index
                OnActionDidFail();

                return;
            }
            catch (System.Exception _exception)
            {
                Debug.Log(_exception.Message);

                OnActionDidFail();

                return;
            }
#endif
        }
        private void OnDidReceiveMessage(WebView _webview, WebViewMessage _message)
        {
            // Cache information
            WebViewUtils.message = _message;

            if (_webview == m_targetWebView)
            {
                // Update properties
                scheme.Value = _message.Scheme;
                host.Value   = _message.Host;

                // Send event
                Fsm.Event(receivedEvent);
            }
        }
Ejemplo n.º 8
0
    public void messageCallBack(WebView webview, WebViewMessage message)
    {
        /*Debug.Log ("Soy el registrado");
         * Debug.Log (message.Host);
         * Debug.Log (message.Scheme);
         * Debug.Log (message.URL);
         * Debug.Log (message.Arguments.ToJSON().ToString());*/

        Debug.Log(message.Arguments ["tokenId"]);
        Debug.Log(message.Arguments ["userId"]);

        string tempHtml = "<script type=\"text/javascript\">\n\tvar tokenId = \"{{TokenID}}\";\n\tvar userId = \"{{UserID}}\";\n</script>\n<form method=\"post\" action=\"http://45.55.222.58:3003/token-login\" id=\"tokenLoginForm\">\n\t<input type=\"hidden\" name=\"action\" value=\"token-login\">\n\t<input type=\"hidden\" name=\"tokenId\">\n\t<input type=\"hidden\" name=\"userId\">\n</form>\n<script type=\"text/javascript\">\n\tvar form = document.getElementById(\"tokenLoginForm\");\n\tform.tokenId.value = tokenId;\n\tform.userId.value = userId;\n\tform.submit();\n</script> ";

        tempHtml = tempHtml.Replace("{{TokenID}}", message.Arguments ["tokenId"]);
        tempHtml = tempHtml.Replace("{{UserID}}", message.Arguments ["userId"]);

        Debug.Log(tempHtml);

        WebViewManager.GetInstance().createWebView(tempHtml, true);
    }
		protected override void ParseMessageData (IDictionary _dataDict, out string _tag, out WebViewMessage _message)
		{
			_tag		= _dataDict[kTag] as string;
			_message	= new AndroidWebViewMessage(_dataDict[kMessageData] as IDictionary);
		}
 protected override void ParseMessageData(IDictionary _dataDict, out string _tag, out WebViewMessage _message)
 {
     _tag     = _dataDict[kTagKey] as string;
     _message = new iOSWebViewMessage(_dataDict[kMessageKey] as IDictionary);
 }
Ejemplo n.º 11
0
//		{
//			"tag": "tag",
//			"message-data": {
//				"host": "move",
//				"arguments": {
//					"cmd": "showAlert",
//					"var": "myVar"
//				},
//				"url-scheme": "unity"
//			}
//		}

        protected override void ParseMessageData(IDictionary _dataDict, out string _tag, out WebViewMessage _message)
        {
            _tag     = _dataDict.GetIfAvailable <string>("tag");
            _message = new iOSWebViewMessage(_dataDict["message-data"] as IDictionary);
        }
		protected virtual void ParseMessageData (IDictionary _dataDict, out string _tag, out WebViewMessage _message)
		{
			_tag		= null;
			_message	= null;
		}
		protected void WebViewDidReceiveMessage (WebView _webview, WebViewMessage	_message)
		{
			Console.Log(Constants.kDebugTag, "[WebView] Received DidReceiveMessage event, Webview=" + _webview + " " + "Message=" + _message);

			if (_webview != null)
				_webview.InvokeMethod(kOnDidReceiveMessageEvent, _message);
		}
Ejemplo n.º 14
0
 protected virtual void ParseMessageData(IDictionary _dataDict, out string _tag, out WebViewMessage _message)
 {
     _tag     = null;
     _message = null;
 }
Ejemplo n.º 15
0
 public void ParseMessageReceivedEventData(IDictionary _JSONDict, out string _tag, out WebViewMessage _message)
 {
     _tag     = _JSONDict[kTagKey] as string;
     _message = new iOSWebViewMessage(_JSONDict[kMessageKey] as IDictionary);
 }
Ejemplo n.º 16
0
 private void DidReceiveMessageEvent(WebView _webview, WebViewMessage _message)
 {
     AddNewResult("Received Did Receive Message Event");
     AppendResult("Message= " + _message);
 }
Ejemplo n.º 17
0
 private void DidReceiveMessageEvent(WebView _webview, WebViewMessage _message)
 {
     AddNewResult(string.Format("Webview with name {0} received message from URL scheme {1}.", _webview.name, _message.SchemeName));
     AppendResult("Received message is " + _message + ".");
 }
 public void ParseMessageReceivedEventData(IDictionary _JSONDict, out string _tag, out WebViewMessage _message)
 {
     // Set default values
     _tag     = null;
     _message = null;
 }
//		{
//			"tag": "tag",
//			"message-data": {
//				"host": "move",
//				"arguments": {
//					"cmd": "showAlert",
//					"var": "myVar"
//				},
//				"url-scheme": "unity"
//			}
//		}
		
		protected override void ParseMessageData (IDictionary _dataDict, out string _tag, out WebViewMessage _message)
		{
			_tag		= _dataDict.GetIfAvailable<string>("tag");
			_message	= new iOSWebViewMessage(_dataDict["message-data"] as IDictionary);
		}