Need "Android WebViewClient shouldOverrideUrlLoading()" functionality inside WebViewObject.
Nobody has claimed this yet.
- Dominant language
- Objective-C++
- Stars
- 2.7k
- Forks
- 734
- Avg merge
- 11h 39m
- Merged PRs (30d)
- 1
Description
Hi Koji Nakamaru,
I am using the Gree plugin for my unity game(Android and iOS). I have imported the "dist/unity-webview.unitypackage" as a unity package in my unity project. I want to have a functionality equivalent to the "Android WebViewClient shouldOverrideUrlLoading() method" inside of WebViewObject. i am getting the Html from a third party source. So i can't do modification in the HTML. The HTML is loaded in the WebViewObject properly. When I tap on it, it loads the next url in the WebView itself. I don't want to load the next url in the webview. Instead, i want the WebViewObject to notify me(via a callback with the next url) whenever a user taps on it. I will handle the next url by myself. Is this functionality already present in the WebViewObject? I appreciate your help. Thanks.
My Code:
WebViewObject webViewObject = new GameObject("VmaxWebViewObject").AddComponent();
webViewObject.Init(
cb: (message) => {},
err: (error) => {},
httpErr: null,
ld: (url) => {},
started: (url) => {},
cookies: null,
transparent: false,
zoom: true,
ua: "",
radius: 0
);
webViewObject.SetMargins(leftMargin, topMargin, screenWidth - (leftMargin + webViewWidthPx), 10);
webViewObject.SetVisibility(true);
webViewObject.LoadHTML(htmlMarkupString, "");
Below is one of sample html mark-up which i am getting from a third party server in string format(You can use it).
"<html lang="en"><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>body,html{margin:0;padding:0;display:inline-block;position:relative}a{display:block;outline:0;text-decoration:none}img[id^=ad-image-]{cursor:pointer;display:block}.ad-badge{position:absolute;top:2px;left:2px;background:#ffc52f 0 0 no-repeat padding-box;width:15px;height:12px;border-radius:3px;display:flex;align-items:center;justify-content:center;color:rgba(0,0,0,.67);font-family:roboto,arial,sans-serif;font-style:normal;font-weight:600;font-size:9px;z-index:1;box-sizing:border-box}.ad-badge.size-2{width:18px;height:16px;font-size:11px}.ad-badge.size-3{width:24px;height:20px;font-size:12px}.ad-badge.topRight{top:2px;right:2px;left:auto}.ad-badge.hide{display:none}</style><span class="ad-badge">Ad<img id="ad-image-419737784" src="" alt="Advertisement" /><script>(function(,n){var i=document.getElementById("ad-image-419737784"),t=document.querySelector(".ad-badge"),d={id:"419737784",image:"https://uat-assets.vmax.com/vmaxtester/i/320x50/gif/38/S_1739447399_100.gif\",trackers:{impression:[],click:[\"https://ts-uat.vmax.com/vmaxtester/c?p=eyJhbGciOiJBMjU2S1ciLCJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIn0.aFpbLWxAmcli4-uvgcE9c05DKHuh0snqx_giyJEIf9yJth-iad25NA.q9wQSkITVffN8V4W.XlnurEZp2bmqVX62Edw02jZSqSOO1ixIERPbKVlQcc1iL3ceKnb4W-E3cbfDGPt6kcuNUmK7XM7dcCplsnSXMkZoSzvjQiDia6uMze-9b9wvEHBJtp7WrvTJreywyiv2y--bhsmba4hmbW9d20MkIRbkc-DKJpP1BZ_H5svCr1jIQQM7UPZzmNi-qabuOMiBKUAW6oUxPmRP1blKtIfTXMAPPm_hIAW7AFOj-b8FTnwSXiCg5KzL5ymYgSKc8QngGLt9mEF3dmPiKeqWt7L1eW3utrf1chaFYWtBlMXGtTTPX_n7XYxHXi6W7VFTFsgWr125-lUF-X0OFDytx_B3X48PpzW5eS20dvqwry594AW3yN__LfQtsB8N4Q79aq4BURfKg4wxcsWeQDFuqEZBVwU1KgkDQ70VxiGgmkOHtbbJWY6oFXGlWhj5ETh39Gbis0ggBzWZiM-L-OEDxsv_sfwsfcVlrG8llyaRbp_Ie1Kzx3Ij7h5v0ylFRGv-MeuSBOS6YpWfIb7l-wtzhKRSsQlPLusY_oQRrtcl5oX8kPWn1R9diJevj7VxuMOsJ8LCxQjeu3efXcDgrJ6Q5IDgCqkxddtnI8BOTyeCScQUgVbm6qZPmX9qUFcw-fCog4YaNbKm66H54fq49j6mpWv-fUUJVInMgKFmEjRN8Tn2b7PVrleNJ8gwP2zfwBV6_eWF1iLArLHa-8u-6SHGRYUH9J5XvFmB68-kKqrcEWwV27QzwkHJiDZZoJpZ_7yBcehIY-N_9akBX5udYO80-sf60lHqa2C-vB3mvxA8IOUc3Wt0ecz7DE5OUU5lFIl5t5bmexXc5fyQbu-sNIg.GxOwA80MzfGD6XRT7YnrXg\"]},landingUri:\"https://www.vmax.com\",adBadgePosition:\"\"};function e(){var n=d||{},e=n.deepLinkIntent,e=void 0===e?"":e,n=n.landingUri,i="string"==typeof(n=void 0===n?"":n),e="string"==typeof e&&e.trim()||"",n=i&&n.trim()||"",i=navigator.userAgent,t=-1<i.indexOf("Android"),i=-1<i.indexOf("Chrome"),t=t&&i&&!!e&&e,i=!!n&&n;(t||i)&&(.open(t||i,"_blank"),a(d.trackers.click))}function a(n){n.forEach(function(n){fetch(n,{method:"GET",mode:"no-cors",headers:{Connection:"keep-alive"},credentials:"include"}).catch(function(n){})})}t.classList.add((null==d?void 0:d.adBadgePosition)||"topLeft"),i.onload=function(){var n=i.naturalWidth,e=i.naturalHeight,n="".concat(n,"x").concat(e),e=["250x250","300x250","336x280","120x600","160x600","728x90","970x90"].includes(n),n=["970x250","300x600","3000x1050"].includes(n);e&&t.classList.add("size-2"),n&&t.classList.add("size-3")},i.src=d.image,a(null==d||null==(n=d.trackers)?void 0:n.impression),i.addEventListener("click",e)})(window);</script>"Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the WebViewObject.Init callbacks and the LoadHTML flow described in the issue, then trace how navigation is handled on Android and iOS. Confirm whether existing callbacks expose tapped destination URLs; done means a tap notifies the Unity caller with the URL without navigating the WebView.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, csharp, ios, unity
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100