private void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log(message.rawMessage); if (string.Equals(message.path, "setting")) { if (message.args["hideToday"] == "1") { ServerRequestManager.instance.SetNeedHideGameNoticeStuatus(1); OptionPanel component = base.GetComponent<OptionPanel>(); if (component != null) { component.ClickCancel(); } } else if (message.args["hideToday"] == "0") { ServerRequestManager.instance.SetNeedHideGameNoticeStuatus(0); OptionPanel panel2 = base.GetComponent<OptionPanel>(); if (panel2 != null) { panel2.ClickCancel(); } } } else if (string.Equals(message.path, "close")) { OptionPanel panel3 = base.GetComponent<OptionPanel>(); if (panel3 != null) { panel3.ClickCancel(); } } }
private void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log(message.rawMessage); if (string.Equals(message.path, "move")) { Vector3 zero = Vector3.zero; if (string.Equals(message.args["direction"], "up")) { zero = new Vector3(0f, 0f, 1f); } else if (string.Equals(message.args["direction"], "down")) { zero = new Vector3(0f, 0f, -1f); } else if (string.Equals(message.args["direction"], "left")) { zero = new Vector3(-1f, 0f, 0f); } else if (string.Equals(message.args["direction"], "right")) { zero = new Vector3(1f, 0f, 0f); } int result = 0; if (int.TryParse(message.args["distance"], out result)) { zero *= result; } this._moveVector = zero; } else if (string.Equals(message.path, "add")) { if (this._cube != null) { UnityEngine.Object.Destroy(this._cube); } this._cube = UnityEngine.Object.Instantiate(this.cubePrefab) as GameObject; this._cube.GetComponent<UniWebViewCube>().webViewDemo = this; this._moveVector = Vector3.zero; } else if (string.Equals(message.path, "close")) { webView.Hide(); UnityEngine.Object.Destroy(webView); webView.OnReceivedMessage -= new UniWebView.ReceivedMessageDelegate(this.OnReceivedMessage); webView.OnLoadComplete -= new UniWebView.LoadCompleteDelegate(this.OnLoadComplete); webView.OnWebViewShouldClose -= new UniWebView.WebViewShouldCloseDelegate(this.OnWebViewShouldClose); webView.OnEvalJavaScriptFinished -= new UniWebView.EvalJavaScriptFinishedDelegate(this.OnEvalJavaScriptFinished); webView.InsetsForScreenOreitation -= new UniWebView.InsetsForScreenOreitationDelegate(this.InsetsForScreenOreitation); this._webView = null; } }
private void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log(message.rawMessage); //this._webView.Hide(); //MessageHint.Show("ddddd:"+message.args["url"]); if (string.Equals(message.path, "dreamshare")) { // It is time to move! // In this example: // message.args["direction"] ="up" // message.args["distance"] ="1" var tmpUrl = message.args["url"]; var tmpdata = message.rawMessage.Split(new string[] { "url=" }, System.StringSplitOptions.None); tmpUrl = tmpdata[1]; ShareContentInfor.Instance.SetShareDreamUrl(tmpUrl); //MBGame.Instance.ShareWeiChat(ShareContentInfor.Instance.dreamShareContent); HideWebView(); var shareController = UIControllerManager.Instance.GetController <UIShareBoardWindowController>(); shareController.ShareWindow = 1; shareController.CallBack = ShowWebView; shareController.setVisible(true); } }
private void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { throw new System.NotImplementedException(); }
//6. The webview can talk to Unity by a url with scheme of "uniwebview". See the webpage for more // Every time a url with this scheme clicked, OnReceivedMessage of webview event get raised. void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log(message.rawMessage); //7. You can get the information out from the url path and query in the UniWebViewMessage //For example, a url of "uniwebview://move?direction=up&distance=1" in the web page will //be parsed to a UniWebViewMessage object with: // message.scheme => "uniwebview" // message.path => "move" // message.args["direction"] => "up" // message.args["distance"] => "1" // "uniwebview" scheme is sending message to Unity by default. // If you want to use your customized url schemes and make them sending message to UniWebView, // use webView.AddUrlScheme("your_scheme") and webView.RemoveUrlScheme("your_scheme") if (string.Equals(message.path, "move")) { Vector3 direction = Vector3.zero; if (string.Equals(message.args["direction"], "up")) { direction = new Vector3(0, 0, 1); } else if (string.Equals(message.args["direction"], "down")) { direction = new Vector3(0, 0, -1); } else if (string.Equals(message.args["direction"], "left")) { direction = new Vector3(-1, 0, 0); } else if (string.Equals(message.args["direction"], "right")) { direction = new Vector3(1, 0, 0); } int distance = 0; if (int.TryParse(message.args["distance"], out distance)) { direction *= distance; } _moveVector = direction; } else if (string.Equals(message.path, "add")) { if (_cube != null) { Destroy(_cube); } _cube = GameObject.Instantiate(cubePrefab) as GameObject; _cube.GetComponent <UniWebViewCube>().webViewDemo = this; _moveVector = Vector3.zero; } else if (string.Equals(message.path, "close")) { //8. When you done your work with the webview, //you can hide it, destory it and do some clean work. webView.Hide(); Destroy(webView); webView.OnReceivedMessage -= OnReceivedMessage; webView.OnLoadComplete -= OnLoadComplete; webView.OnWebViewShouldClose -= OnWebViewShouldClose; webView.OnEvalJavaScriptFinished -= OnEvalJavaScriptFinished; _webView = null; } }
private void processAdgemUrlSchemeMessage(UniWebViewMessage message) { if (AdGem.verboseLogging) { Debug.Log("Adgem: adgem url scheme message received"); Debug.Log("Adgem: " + message.RawMessage); } if (message.Path.Equals("close", System.StringComparison.InvariantCultureIgnoreCase)) { closeWebView(); } else if (message.Path.Equals("close-not-rewarded", System.StringComparison.InvariantCultureIgnoreCase)) { closeNotRewarded(); } else if (message.Path.Equals("play-success", System.StringComparison.InvariantCultureIgnoreCase)) { waitingForPlaySuccessConfirmation = false; if (AdGem.videoAdStarted != null) { AdGem.videoAdStarted(); } } else //otherwise, the path should be a url ecoded base64 encoded json string { try { string base64payload = message.Path; //Uniwebview automatically url-decodes string jsonString = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(base64payload)); //Debug.Log("Adgem--- offer wall message json string ---***--- " + jsonString); JSONNode baseJson = JSON.Parse(jsonString); if (baseJson == null) { return; } string actionType = baseJson["action"].Value; string url = baseJson["url"].Value; if (url == null) { url = ""; } //Debug.Log("url: " + url); string storeID = baseJson["store_id"].Value; if (storeID == null) { storeID = ""; } string app_id = baseJson["app_id"].Value; if (app_id == null) { app_id = ""; } int amount = baseJson["amount"].AsInt; if (actionType.Equals("browser", System.StringComparison.InvariantCultureIgnoreCase)) { //Debug.Log("browser"); Application.OpenURL(url); //Start polling for an offer completion AdGemManager.staticRef.startPollingProcess(); } if (actionType.Equals("appstore", System.StringComparison.InvariantCultureIgnoreCase) && AdGemPrefabController.staticRef != null) //appstore //store_id { //Start polling for an offer completion AdGemManager.staticRef.startPollingProcess(); //Debug.Log("appstore"); AdGemPrefabController.staticRef.userClicked(url, app_id); } //if (actionType.Equals("reward", System.StringComparison.InvariantCultureIgnoreCase) && AdGemPlugin.offerWallRewardReceived != null) //{ // Debug.Log("Adgem--- **** Reward action fired"); // AdGemPlugin.processOfferWallReward(baseJson, amount); //} } catch (System.Exception ex) { Debug.Log("Adgem--- " + ex.ToString()); } } }
private void ReceivedMessage(string rawMessage) { UniWebViewMessage message = new UniWebViewMessage(rawMessage); if (OnReceivedMessage != null) { OnReceivedMessage(this,message); } }
private void FunctionCallBack(UniWebView webView, UniWebViewMessage message) { switch (message.Path) { case "Back": { SceneTools.instance.BackScene(); break; }; case "GameOver": { SceneTools.instance.LoadScene("ScoreOrder"); break; }; //管理员获取管理的数据 case "GetRoomList": { ReqestData(message, "GetRoomUserTreeData", (result) => { CallWebPageFunction("ShowRoomList",result); }); break; } //玩家之间共享信息 case "ShowPlayInfo": { ReqestData(message, "GetRoomLifeInfoByUser", (result) => { CallWebPageFunction("GetRoomLifeInfoByUser",result); }); break; } //管理员查看用户详细信息 case "ShowPlayerDetailInfoList": { ReqestData(message, "GetPlayerLifeInfoByUser", (result) => { CallWebPageFunction("ShowPlayerDetailInfo",result); }); break; } //管理员查看用户详细信息 case "AddPlayerLife": { string userId = message.Args["userId"].ToString(); string addLifeValue = message.Args["addLifeValue"].ToString(); string currentUser = message.Args["currentUser"].ToString(); string url = "http://" + Config.parse("ServerIP") + ":8899/AddPlayerLife/" + userId + "/"+ addLifeValue + "/"+ currentUser; ResourceUtility.Instance.GetHttpText(url, (result) => { CallWebPageFunction("AddPlayerLifeMessageShow", result); }); break; } } }
private void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { // }
// public void addCheckedLocation() // { // /*Debug.Log("Adding Checked Location"); // _webView.EvaluatingJavaScript(JS_CHECKIN_LOCATION + '(' + // currentMarker.lat + ',' + // currentMarker.lon + ")"); */ // _webView.EvaluatingJavaScript( // JS_CHECKIN_LOCATION + '(' + SpatialClient2.single.getStreakPathAsJsonString() + ')'); // } void onReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log("hi"); Debug.Log(message.rawMessage); switch (message.path) { /* case "back": * StopCoroutine (_locationUpdateCoroutine); * _mainMenuCanvas.enabled = true; * _webView.Stop (); * mapLoaded = false; * _webView.Hide(); * break; */ case "eggs": /* StopCoroutine(_locationUpdateCoroutine); * _friendsEggsCanvas.enabled = false; * _eggsCanvas.enabled = false; * _checkedInText.text = * "Checked in " + "egg" + " at " + Input.location.lastData.latitude.ToString() + ", " + Input.location.lastData.longitude.ToString(); + _checkedInCanvas.enabled = true; + _webView.Stop(); + mapLoaded = false; + _webView.Hide(); */ _disableWebview(); _eggsCanvas.enabled = true; StartCoroutine(updateCheckinnables()); // TODO update to actually check in break; case "destroy": /* * StopCoroutine(_locationUpdateCoroutine); * _webView.Stop(); * mapLoaded = false; * _webView.Hide(); */ _disableWebview(); Debug.Log("Marker ID: " + message.args["id"]); MainController.single.goToDestroyCity(message.args["id"]); break; case "resetscore": StartCoroutine(SpatialClient2.single.resetStreak()); break; case "addfriend": _disableWebview(); _friendSearchCanvas.enabled = true; break; case "kaiju": _disableWebview(); _kaijuCanvas.enabled = true; break; case "print": Debug.Log(message.args ["msg"]); break; default: break; } }
//< 웹뷰에서 입력받았을시 받는 메시지콜백 void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log(message.rawMessage); }
//6. The webview can talk to Unity by a url with scheme of "uniwebview". See the webpage for more // Every time a url with this scheme clicked, OnReceivedMessage of webview event get raised. void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log("Received a message from native"); Debug.Log(message.rawMessage); //7. You can get the information out from the url path and query in the UniWebViewMessage //For example, a url of "uniwebview://move?direction=up&distance=1" in the web page will //be parsed to a UniWebViewMessage object with: // message.scheme => "uniwebview" // message.path => "move" // message.args["direction"] => "up" // message.args["distance"] => "1" // "uniwebview" scheme is sending message to Unity by default. // If you want to use your customized url schemes and make them sending message to UniWebView, // use webView.AddUrlScheme("your_scheme") and webView.RemoveUrlScheme("your_scheme") if (string.Equals(message.path,"move")) { Vector3 direction = Vector3.zero; if (string.Equals(message.args["direction"],"up")) { direction = new Vector3(0,0,1); } else if (string.Equals(message.args["direction"],"down")) { direction = new Vector3(0,0,-1); } else if (string.Equals(message.args["direction"],"left")) { direction = new Vector3(-1,0,0); } else if (string.Equals(message.args["direction"],"right")) { direction = new Vector3(1,0,0); } int distance = 0; if (int.TryParse(message.args["distance"], out distance)) { direction *= distance; } _moveVector = direction; } else if (string.Equals(message.path, "add")) { if (_cube != null) { Destroy(_cube); } _cube = GameObject.Instantiate(cubePrefab) as GameObject; _cube.GetComponent<UniWebViewCube>().webViewDemo = this; _moveVector = Vector3.zero; } else if (string.Equals(message.path, "close")) { //8. When you done your work with the webview, //you can hide it, destory it and do some clean work. webView.Hide(); Destroy(webView); webView.OnReceivedMessage -= OnReceivedMessage; webView.OnLoadComplete -= OnLoadComplete; webView.OnWebViewShouldClose -= OnWebViewShouldClose; webView.OnEvalJavaScriptFinished -= OnEvalJavaScriptFinished; webView.InsetsForScreenOreitation -= InsetsForScreenOreitation; _webView = null; } }
private void ReceivedMessage(string rawMessage) { UniWebViewMessage message = new UniWebViewMessage(rawMessage); if (OnReceivedMessage != null) { OnReceivedMessage(this,message); } if (message.path.ToLower() == "exit") { Application.Quit(); } else if (message.path.ToLower() == "show_ar") { Application.LoadLevel("ARScene"); } }
private static void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { if (message.path == "close") { UnityEngine.Object.Destroy(webView.gameObject); } else if (message.path == "register") { UnityEngine.Object.Destroy(webView.gameObject); if (message.rawMessage != null) { Regex regex = new Regex("username=(.*)&password=(.*)"); string str = regex.Match(message.rawMessage).Groups[1].Value; string str2 = regex.Match(message.rawMessage).Groups[2].Value; Singleton <NotifyManager> .Instance.FireNotify(new Notify(NotifyTypes.MihoyoAccountRegisterSuccess, new Tuple <string, string>(str, str2))); } } else if (message.path == "login") { UnityEngine.Object.Destroy(webView.gameObject); if (message.rawMessage != null) { Regex regex2 = new Regex("username=(.*)&password=(.*)"); string str3 = regex2.Match(message.rawMessage).Groups[1].Value; string str4 = regex2.Match(message.rawMessage).Groups[2].Value; Singleton <AccountManager> .Instance.manager.LoginUIFinishedCallBack(str3, str4); } } else if (message.path == "bind_email") { UnityEngine.Object.Destroy(webView.gameObject); if (message.rawMessage != null) { Regex regex3 = new Regex("email=(.*)"); string str5 = regex3.Match(message.rawMessage).Groups[1].Value; Singleton <MiHoYoGameData> .Instance.GeneralLocalData.Account.email = str5; Singleton <MiHoYoGameData> .Instance.SaveGeneralData(); Singleton <NotifyManager> .Instance.FireNotify(new Notify(NotifyTypes.MihoyoAccountInfoChanged, null)); } } else if (message.path == "bind_mobile") { UnityEngine.Object.Destroy(webView.gameObject); if (message.rawMessage != null) { Regex regex4 = new Regex("mobile=(.*)"); string str6 = regex4.Match(message.rawMessage).Groups[1].Value; Singleton <MiHoYoGameData> .Instance.GeneralLocalData.Account.mobile = str6; Singleton <MiHoYoGameData> .Instance.SaveGeneralData(); Singleton <NotifyManager> .Instance.FireNotify(new Notify(NotifyTypes.MihoyoAccountInfoChanged, null)); } } else if (message.path == "bind_identity") { UnityEngine.Object.Destroy(webView.gameObject); if (message.rawMessage != null) { Singleton <MiHoYoGameData> .Instance.GeneralLocalData.Account.isRealNameVerify = true; Singleton <MiHoYoGameData> .Instance.SaveGeneralData(); Singleton <NotifyManager> .Instance.FireNotify(new Notify(NotifyTypes.MihoyoAccountInfoChanged, null)); } } }
/// <summary> /// “uniwebview://”模式在列表中是默认的,因此单击链接以“uniwebview://”开始。 /// </summary> private void OnMessageReceived(UniWebView webView, UniWebViewMessage message) { }
/// <summary> /// UniWebView Call Unity /// </summary> /// <param name="webView"></param> /// <param name="message"></param> private void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { //Debug.Log(message.rawMessage); m_Text.text = message.rawMessage; }
private void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { UnityEngine.Debug.Log("OnReceivedMessage"); UnityEngine.Debug.Log(message.rawMessage); if (string.Equals(message.path, "webview")) { Vector3 zero = Vector3.zero; if (message.args.ContainsKey("funcname")) { if (string.Equals(message.args["funcname"], "dnqueryuserinfo")) { if (message.args.ContainsKey("callback")) { UnityEngine.Debug.Log("Will callback"); string arg = message.args["callback"]; Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["appid"] = this.mAppId; dictionary["openid"] = this.mOpenid; dictionary["access_token"] = this.mToken; dictionary["partition"] = this.mServerid; dictionary["roleid"] = this.mRoleid; dictionary["entertime"] = this.mOpenTime; dictionary["nickname"] = this.mNickName; string arg2 = Json.Serialize(dictionary); string text = string.Format("{0}({1})", arg, arg2); UnityEngine.Debug.Log(text); webView.EvaluatingJavaScript(text); } } else if (string.Equals(message.args["funcname"], "dnclosewebview")) { this.CloseWebView(webView); } else if (string.Equals(message.args["funcname"], "dniswifi")) { if (message.args.ContainsKey("callback")) { UnityEngine.Debug.Log("Will dniswifi callback"); string arg3 = message.args["callback"]; bool flag = Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork; int num = (!flag) ? 0 : 1; string text2 = string.Format("{0}({1})", arg3, num); UnityEngine.Debug.Log(text2); webView.EvaluatingJavaScript(text2); } } else if (string.Equals(message.args["funcname"], "dnisbgopen")) { if (message.args.ContainsKey("callback")) { UnityEngine.Debug.Log("Will dnisbgopen callback"); string arg4 = message.args["callback"]; int num2 = (!this._is_bgopen) ? 0 : 1; string text3 = string.Format("{0}({1})", arg4, num2); UnityEngine.Debug.Log(text3); webView.EvaluatingJavaScript(text3); } } else if (string.Equals(message.args["funcname"], "dnopenbg")) { this._is_bgopen = true; UniWeb.m_uiUtility.OnSetBg(true); } else if (string.Equals(message.args["funcname"], "dnclosebg")) { this._is_bgopen = false; UniWeb.m_uiUtility.OnSetBg(false); } else if (string.Equals(message.args["funcname"], "dnchangemenu")) { if (message.args.ContainsKey("menutype")) { int menutype = int.Parse(message.args["menutype"]); UniWeb.m_uiUtility.OnSetWebViewMenu(menutype); } } else if (string.Equals(message.args["funcname"], "dnbackgame")) { if (message.args.ContainsKey("backtype")) { int menutype2 = int.Parse(message.args["backtype"]); UniWeb.m_uiUtility.OnSetWebViewMenu(menutype2); } if (message.args.ContainsKey("callback")) { UnityEngine.Debug.Log("Will dnbackgame callback"); string arg5 = message.args["callback"]; string text4 = string.Format("{0}()", arg5); UnityEngine.Debug.Log(text4); webView.EvaluatingJavaScript(text4); } } else if (string.Equals(message.args["funcname"], "dnrefreshredpoint")) { if (message.args.ContainsKey("args")) { string text5 = WWW.UnEscapeURL(message.args["args"]); UnityEngine.Debug.Log("dnrefreshredpoint" + text5); UniWeb.m_uiUtility.OnWebViewRefershRefPoint(text5); } } else if (string.Equals(message.args["funcname"], "dnsetheaderinfo")) { if (message.args.ContainsKey("args")) { string text6 = WWW.UnEscapeURL(message.args["args"]); UnityEngine.Debug.Log("dnsetheaderinfo" + text6); UniWeb.m_uiUtility.OnWebViewSetheaderInfo(text6); } } else if (string.Equals(message.args["funcname"], "dnshownav")) { if (message.args.ContainsKey("type")) { int num3 = int.Parse(message.args["type"]); if (num3 == 1) { this._gap = this.GetGap(); } else { this._gap = 0; } this._webView.ForceResize(); } } else if (string.Equals(message.args["funcname"], "dncloseloading")) { if (message.args.ContainsKey("show")) { int num4 = int.Parse(message.args["show"]); UnityEngine.Debug.Log("dncloseloading: " + message.args["show"]); UniWeb.m_uiUtility.OnWebViewCloseLoading(num4); if (num4 == 1) { this._webView.Hide(); } else { this._webView.Show(); } } } else if (string.Equals(message.args["funcname"], "dnshowreconnect")) { if (message.args.ContainsKey("show")) { int num5 = int.Parse(message.args["show"]); UnityEngine.Debug.Log("dnshowreconnect: " + message.args["show"]); UniWeb.m_uiUtility.OnWebViewShowReconnect(num5); if (num5 == 1) { this._webView.Hide(); } else { this._webView.Show(); } } } else if (string.Equals(message.args["funcname"], "dnsetlivetab")) { UniWeb.m_uiUtility.OnWebViewLiveTab(); } else if (string.Equals(message.args["funcname"], "dnbackhistory")) { this._webView.GoBack(); } else if (string.Equals(message.args["funcname"], "dnsetshareinfo")) { string json = WWW.UnEscapeURL(message.args["args"]); Dictionary <string, object> dictionary2 = Json.Deserialize(json) as Dictionary <string, object>; XPlatform platf = base.gameObject.GetComponent <XPlatform>(); object title; dictionary2.TryGetValue("title", out title); object obj; dictionary2.TryGetValue("imgurl", out obj); object desc; dictionary2.TryGetValue("desc", out desc); object url; dictionary2.TryGetValue("url", out url); object type; dictionary2.TryGetValue("type", out type); if (type.Equals("qq") || type.Equals("qzone")) { Dictionary <string, string> dictionary3 = new Dictionary <string, string>(); dictionary3["scene"] = ((!type.Equals("qq")) ? "QZone" : "Session"); if (url != null) { dictionary3["targetUrl"] = "https:" + url.ToString(); } if (obj != null) { dictionary3["imageUrl"] = obj.ToString(); } if (title != null) { dictionary3["title"] = title.ToString(); } if (desc != null) { dictionary3["description"] = desc.ToString(); } dictionary3["summary"] = string.Empty; string json2 = Json.Serialize(dictionary3); platf.SendGameExData("share_send_to_struct_qq", json2); } else if (type.Equals("weixin") || type.Equals("timeline")) { if (!base.gameObject.activeSelf) { return; } base.StartCoroutine(this.DownloadPic(obj.ToString(), delegate(string filepath) { if (!string.IsNullOrEmpty(filepath)) { Dictionary <string, string> dictionary4 = new Dictionary <string, string>(); dictionary4["scene"] = ((!type.Equals("weixin")) ? "Timeline" : "Session"); if (title != null) { dictionary4["title"] = title.ToString(); } if (desc != null) { dictionary4["desc"] = desc.ToString(); } if (url != null) { dictionary4["url"] = url.ToString(); } dictionary4["mediaTagName"] = "MSG_INVITE"; dictionary4["filePath"] = filepath; dictionary4["messageExt"] = "ShareUrlWithWeixin"; string json3 = Json.Serialize(dictionary4); platf.SendGameExData("share_send_to_with_url_wx", json3); } })); } else { UnityEngine.Debug.LogError("err type: " + type); } } } } }
static int QPYX_get_table_YXQP(IntPtr L_YXQP) { object QPYX_o_YXQP = null; try { QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1); UniWebViewMessage QPYX_obj_YXQP = (UniWebViewMessage)QPYX_o_YXQP; LuaInterface.LuaTable QPYX_ret_YXQP = QPYX_obj_YXQP.table; ToLua.Push(L_YXQP, QPYX_ret_YXQP); return(1); } catch (Exception QPYX_e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index table on a nil value")); } }
private void MPMainUIOnReceivedMessage(UniWebView webView, UniWebViewMessage message) { try { string loadingUrl = string.Empty; if (message.rawMessage != null && message.rawMessage != string.Empty) { loadingUrl = message.rawMessage.Replace(uniwebview, ""); } if (loadingUrl != string.Empty && loadingUrl.StartsWith(mpopenmolpaywindow)) { mpMainUI.Stop(); string base64String = loadingUrl.Replace(mpopenmolpaywindow, ""); #if UNITY_IOS base64String = base64String.Replace("-", "+"); base64String = base64String.Replace("_", "="); #endif byte[] data = Convert.FromBase64String(base64String); string decodedString = Encoding.UTF8.GetString(data); if (decodedString.Length > 0) { mpMOLPayUI = CreateWebView(); LoadFromText(mpMOLPayUI, decodedString); mpMOLPayUI.OnLoadBegin += MPMOLPayUIOnLoadBegin; mpMOLPayUI.OnLoadComplete += MPMOLPayUIOnLoadComplete; } } else if (loadingUrl != string.Empty && loadingUrl.StartsWith(mpcloseallwindows)) { if (mpBankUI != null) { mpBankUI.url = "about:blank"; mpBankUI.Load(); mpBankUI.Hide(); mpBankUI.CleanCache(); mpBankUI.CleanCookie(); mpBankUI = null; } mpMOLPayUI.url = "about:blank"; mpMOLPayUI.Load(); mpMOLPayUI.Hide(); mpMOLPayUI.CleanCache(); mpMOLPayUI.CleanCookie(); mpMOLPayUI = null; } else if (loadingUrl != string.Empty && loadingUrl.StartsWith(mptransactionresults)) { string base64String = loadingUrl.Replace(mptransactionresults, ""); #if UNITY_IOS base64String = base64String.Replace("-", "+"); base64String = base64String.Replace("_", "="); #endif byte[] data = Convert.FromBase64String(base64String); string decodedString = Encoding.UTF8.GetString(data); if (decodedString.Length > 0) { transactionResult = decodedString; try { Dictionary <string, object> jsonResult = Json.Deserialize(transactionResult) as Dictionary <string, object>; object requestType; jsonResult.TryGetValue("mp_request_type", out requestType); if (!jsonResult.ContainsKey("mp_request_type") || (string)requestType != "Receipt" || jsonResult.ContainsKey("error_code")) { Finish(); } else { isClosingReceipt = true; } } catch (Exception) { Finish(); } } } else if (loadingUrl != string.Empty && loadingUrl.StartsWith(mprunscriptonpopup)) { string base64String = loadingUrl.Replace(mprunscriptonpopup, ""); #if UNITY_IOS base64String = base64String.Replace("-", "+"); base64String = base64String.Replace("_", "="); #endif byte[] data = Convert.FromBase64String(base64String); string decodedString = Encoding.UTF8.GetString(data); if (decodedString.Length > 0) { mpMOLPayUI.EvaluatingJavaScript(decodedString); } } else if (loadingUrl != string.Empty && loadingUrl.StartsWith(mppinstructioncapture)) { string base64String = loadingUrl.Replace(mppinstructioncapture, ""); #if UNITY_IOS base64String = base64String.Replace("-", "+"); base64String = base64String.Replace("_", "="); #endif byte[] data = Convert.FromBase64String(base64String); string decodedString = Encoding.UTF8.GetString(data); Dictionary <string, object> jsonResult = Json.Deserialize(decodedString) as Dictionary <string, object>; object base64ImageUrlData; jsonResult.TryGetValue("base64ImageUrlData", out base64ImageUrlData); object filename; jsonResult.TryGetValue("filename", out filename); byte[] imageData = Convert.FromBase64String(base64ImageUrlData.ToString()); string[] temp = (Application.persistentDataPath.Replace("Android", "")).Split(new string[] { "//" }, System.StringSplitOptions.None); string imageLocation = temp[0] + "/Download/" + filename.ToString(); File.WriteAllBytes(imageLocation, imageData); #if UNITY_IOS _SavePhoto(imageLocation); #elif UNITY_ANDROID using (AndroidJavaClass jcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) using (AndroidJavaObject joActivity = jcUnityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) using (AndroidJavaObject joContext = joActivity.Call <AndroidJavaObject>("getApplicationContext")) using (AndroidJavaClass jcMediaScannerConnection = new AndroidJavaClass("android.media.MediaScannerConnection")) using (AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment")) using (AndroidJavaObject joExDir = jcEnvironment.CallStatic <AndroidJavaObject>("getExternalStorageDirectory")) { jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { imageLocation }, null, null); } #endif Debug.Log("imageLocation: " + imageLocation); if (System.IO.File.Exists(imageLocation)) { NPBinding.UI.ShowAlertDialogWithSingleButton("Info", "Image saved", "OK", OnButtonPressed); } else { NPBinding.UI.ShowAlertDialogWithSingleButton("Info", "Image not saved", "OK", OnButtonPressed); } } } catch (Exception) { } }
static int QPYX_get_path_YXQP(IntPtr L_YXQP) { object QPYX_o_YXQP = null; try { QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1); UniWebViewMessage QPYX_obj_YXQP = (UniWebViewMessage)QPYX_o_YXQP; string QPYX_ret_YXQP = QPYX_obj_YXQP.path; LuaDLL.lua_pushstring(L_YXQP, QPYX_ret_YXQP); return(1); } catch (Exception QPYX_e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index path on a nil value")); } }
void OnReceivedMessage(UniWebView webView, UniWebViewMessage message) { Debug.Log("Received a message from native"); Debug.Log(message.rawMessage); }
static int QPYX_get_args_YXQP(IntPtr L_YXQP) { object QPYX_o_YXQP = null; try { QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1); UniWebViewMessage QPYX_obj_YXQP = (UniWebViewMessage)QPYX_o_YXQP; System.Collections.Generic.Dictionary <string, string> QPYX_ret_YXQP = QPYX_obj_YXQP.args; ToLua.PushSealed(L_YXQP, QPYX_ret_YXQP); return(1); } catch (Exception QPYX_e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index args on a nil value")); } }