आप Android और iOS पर WebView रिडायरेक्ट त्रुटियों का निवारण कैसे करते हैं? पहले यह पहचानें कि क्या विफलता में मानक HTTPS नेविगेशन, कस्टम URL स्कीम, Android intent:// URI, या नई-विंडो अनुरोध शामिल है, फिर Chrome DevTools या Safari Web Inspector के माध्यम से नेविगेशन का निरीक्षण करें और संबंधित नेटिव डेलिगेट (shouldOverrideUrlLoading, onCreateWindow, decidePolicyForNavigationAction, या createWebViewWith) को ट्रैक करें। कंटेनर-स्तरीय त्रुटियों को ऑपरेटिंग-सिस्टम प्रेषण विफलताओं से अलग करने के लिए टारगेट-ऐप रिज़ॉल्यूशन, URI अनुमति सूचियों, फ्रेम और उपयोगकर्ता-इंटरैक्शन नीतियों और फ़ॉलबैक रूटिंग को सत्यापित करें।
WebView रिडायरेक्शन त्रुटि तब होती है जब एक एम्बेडेड Android Chromium WebView या iOS WebKit WKWebView नेविगेशन अनुरोध को उसके इच्छित गंतव्य पर रूट करने में विफल रहता है। विशिष्ट कारणों में असमर्थित कस्टम URL स्कीम, अनहैंडल्ड
target="_blank"अनुरोध, गायब पैकेज विज़िबिलिटी घोषणाएं, और अस्वीकृत या लूपिंग फ़ॉलबैक रिडायरेक्ट शामिल हैं।
एम्बेडेड Android WebView और iOS WKWebView कंटेनर रिडायरेक्ट क्यों छोड़ते हैं

रिडायरेक्शन विफलताओं को डीबग करते समय, इंजीनियरिंग टीमों को WebView इंजन व्यवहार (Chromium या WebKit URL, फ्रेम टारगेट और पॉपअप इवेंट को कैसे पार्स करता है) को होस्ट एप्लिकेशन नीति (एप्लिकेशन-आपूर्ति किए गए WebViewClient, WebChromeClient, WKNavigationDelegate, या WKUIDelegate उपयोगकर्ता इंटरैक्शन प्रकारों, अनुमति सूचियों और बाहरी ऐप हैंडऑफ़ का मूल्यांकन कैसे करते हैं) से अलग करना होगा। स्टैंडअलोन ब्राउज़र में अंतर्निहित URI डिस्पैचर और लिंक-हैंडऑफ़ हैंडल होते हैं, जबकि android.webkit.WebView और Apple का WKWebView एम्बेडेड रेंडरिंग घटक हैं जो डिफ़ॉल्ट रूप से मानक http:// या https:// नेटवर्क प्रतिक्रियाओं की अपेक्षा करते हैं।
जब कोई वेब पेज सक्रिय डेलिगेट ओवरराइड के बिना कस्टम स्कीम (जैसे myapp://product/42) या Android intent:// लिंक को ट्रिगर करता है, तो डिफ़ॉल्ट कंटेनर व्यवहार प्लेटफ़ॉर्म के बीच भिन्न होता है:
- Android Chromium WebView: Android
WebViewClientविनिर्देश के अनुसार, यदि कोई कस्टमWebViewClientअसाइन नहीं किया गया है, तो WebView उपलब्ध सिस्टम हैंडलर के माध्यम से URL को हल करने के लिए गतिविधि प्रबंधक से कह सकता है। जब एक कस्टमWebViewClientअसाइन किया गया है औरshouldOverrideUrlLoadingएक असमर्थित कस्टम स्कीम के लिएfalseलौटाता है, तो WebView इसे Chromium के अंदर लोड करना जारी रखता है औरnet::ERR_UNKNOWN_URL_SCHEMEरेंडर करता है। - iOS WebKit WKWebView: WebKit आंतरिक रूप से गैर-HTTP स्कीम को अस्वीकार कर देता है और नेविगेशन को तब तक रोकता है जब तक कि होस्ट का
WKNavigationDelegateअनुरोध को इंटरसेप्ट करके इसेUIApplicationको अग्रेषित नहीं करता है, जो अक्सर चुपचाप विफल हो जाता है याNSURLErrorUnsupportedURLको ट्रिगर करता है।
यह भी ध्यान दें कि Apple की स्मार्ट ऐप बैनर के साथ ऐप्स को बढ़ावा देना सुविधा एम्बेडेड WKWebView नेविगेशन API के बजाय स्टैंडअलोन Safari ब्राउज़िंग के लिए डिज़ाइन की गई एक Safari समर्थन सुविधा है, और इसे इन-ऐप कस्टम URL स्कीम रिडायरेक्शन से अलग से मूल्यांकन किया जाना चाहिए।
एक नजर में
- इंजन व्यवहार को होस्ट नीति से अलग करें: अलग करें कि नेविगेशन वेब इंजन (Chromium/WebKit) के भीतर, नेटिव डेलिगेट ओवरराइड के भीतर, या OS पैकेज-रिज़ॉल्यूशन सीमा पर विफल हुआ या नहीं।
- कोडिंग से पहले लाइव रिडायरेक्ट का निरीक्षण करें: 3xx रिडायरेक्ट श्रृंखला,
targetFrameस्थितियों और जेस्चर फ़्लैग को कैप्चर करने के लिए Chrome DevTools (chrome://inspect) और Safari Web Inspector (isInspectable = true) का उपयोग करें। - प्लेटफ़ॉर्म-उपयुक्त URI और Intent सत्यापन लागू करें: Android पर, वेबपेज-आपूर्ति किए गए टास्क फ़्लैग के बिना
IntentSanitizerके माध्यम से सत्यापित पैकेजों के लिए कस्टम स्कीम औरintent://टारगेट को 1-से-1 बाइंड करें; iOS पर, संपूर्ण कस्टम URI संरचनाओं को सत्यापित करें (जहां सत्यापित ऐप-से-डोमेन पहचान आवश्यक है वहां यूनिवर्सल लिंक पर भरोसा करें), और दोनों प्लेटफ़ॉर्म पर डुप्लिकेट क्वेरी कुंजियों को अस्वीकार करें। - पॉपअप और रेस स्थितियों के लिए डिफेंस-इन-दप्थ लागू करें:
shouldInterceptRequestऔरshouldOverrideUrlLoadingमें कॉलबैक सीमाओं को समझते हुए Android पॉपअप सत्र स्थिति को कड़ाई से UI धागे तक सीमित करें, और एक्शन-स्तरीय डिडुप्लीकेशन और नेविगेशन जेनरेशन टोकन का उपयोग करके iOSWKWebViewमें शुद्ध नीति जांच को बाहरी प्रेषण साइड इफेक्ट्स से अलग करें।
WebView रिडायरेक्शन त्रुटियों के सामान्य कारण और सत्यापन चरण
निरीक्षित क्लाइंट त्रुटियों को अंतर्निहित कंटेनर विफलता तंत्र से मैपिंग करना
निरीक्षित WebView लक्षणों को सामान्य प्लेटफ़ॉर्म मूल कारणों, सत्यापन चरणों और लक्षित उपचारों से मैप करने के लिए नीचे दिए गए नैदानिक मैट्रिक्स का उपयोग करें:
| निरीक्षित लक्षण या त्रुटि | लक्ष्य प्लेटफ़ॉर्म | सामान्य मूल कारण | नैदानिक सत्यापन चरण | लक्षित उपचार |
|---|---|---|---|---|
WebView net::ERR_UNKNOWN_URL_SCHEME प्रदर्शित करता है |
Android WebView | कस्टम WebViewClient false लौटाता है या स्कीम अनुमति सूची का अभाव है |
shouldOverrideUrlLoading में request.url का निरीक्षण करें |
अनुमति प्राप्त URI को इंटरसेप्ट करें और 1-से-1 पैकेज-बाउंड Intent.ACTION_VIEW प्रेषित करें |
| कस्टम स्कीम लिंक पर टैप करने पर साइलेंट हैंग | iOS WKWebView | जब WKNavigationDelegate .allow लौटाता है तो WebKit गैर-HTTP URI को रद्द कर देता है |
decidePolicyForNavigationAction में navigationAction.request.url को लॉग करें |
UIApplication.shared.open के माध्यम से सत्यापित स्कीम को रूट करें और .cancel पास करें |
target="_blank" WebView में वर्तमान पेज को बदल देता है |
Android WebView | setSupportMultipleWindows(false) नई विंडो को शीर्ष-स्तरीय लोड के रूप में मानता है |
webView.settings.supportMultipleWindows() की जाँच करें |
केवल तभी setSupportMultipleWindows(true) सक्षम करें जब अलग पॉपअप कंटेनरों की आवश्यकता हो |
target="_blank" कुछ नहीं करता है या OAuth 302 रिडायरेक्ट छोड़ देता है |
Android WebView | onCreateWindow गायब है, या चाइल्ड क्लाइंट hasGesture() के बिना isRedirect हॉप्स को ब्लॉक करता है |
onCreateWindow, request.isRedirect, और shouldInterceptRequest लॉग की जाँच करें |
UI-थ्रेड सत्र स्थिति और परिबद्ध isRedirect हॉप्स के साथ एक व्यू-होस्टेड पॉपअप WebView संलग्न करें |
target="_blank" या window.open() वाला लिंक कुछ नहीं करता है |
iOS WKWebView | नई-विंडो नेविगेशन targetFrame == nil सेट करता है और इसके लिए WKUIDelegate की आवश्यकता होती है |
navigationAction.targetFrame == nil की जाँच करें |
decidePolicyForNavigationAction में targetFrame == nil का पता लगाएं और WKUIDelegate के माध्यम से संभालें |
| लक्ष्य ऐप इंस्टॉल है, फिर भी फ़ॉलबैक पेज खुलता है | Android 11+ (targetSdk >= 30) |
गायब <queries> घोषणाएं अदृश्य पैकेजों के लिए अधूरे परिणाम लौटने का कारण बनती हैं |
resolveActivity() के आसपास एप्लिकेशन-स्तरीय लॉगिंग जोड़ें और adb logcat के माध्यम से आउटपुट का निरीक्षण करें |
पूर्व-जांच करते समय <queries> intents घोषित करें, या ActivityNotFoundException कैच के साथ सीधे startActivity को कॉल करें |
| JavaScript 타이머 रिडायरेक्ट बाहरी ऐप को खोलने में विफल रहता है | iOS / Android | स्वचालित स्क्रिप्ट रिडायरेक्शन में उपयोगकर्ता इंटरैक्शन सिग्नल का अभाव है | request.hasGesture() (Android) या navigationType (iOS) की जाँच करें |
रिडायरेक्शन को सीधे उपयोगकर्ता टैप से बाइंड करें और एक स्पष्ट होस्ट जेस्चर नीति परिभाषित करें |
यूनिवर्सल लिंक लक्ष्य ऐप के बजाय WKWebView के अंदर लोड होता है |
iOS WKWebView | ब्राउज़िंग संदर्भ, डोमेन संबंध, या JS नेविगेशन लोड को WebKit में रखता है | decidePolicyForNavigationAction में navigationType और होस्ट की जाँच करें |
अनुमत बाहरी होस्ट के लिए .universalLinksOnly: true के साथ UIApplication.shared.open को कॉल करें |
पांच मिनट की WebView रिडायरेक्ट त्वरित-त्रुटि जांच सूची
- चरण 1: DevTools में प्रोटोकॉल स्कीम की जाँच करें: सत्यापित करें कि पेज ने
https://, कस्टम स्कीम, याintent://URI उत्सर्जित किया था या नहीं और पुष्टि करें कि यह सामग्री सुरक्षा नीति (CSP) द्वारा अवरुद्ध नहीं किया गया था। - चरण 2: फ्रेम पदानुक्रम का निरीक्षण करें: जाँच करें कि क्या ट्रिगर किसी तृतीय-पक्ष
<iframe>(!isMainFrame) के भीतर उत्पन्न हुआ है। होस्ट एप्लिकेशन जानबूझकर तृतीय-पक्ष iframe से शुरू किए गए बाहरी-ऐप लॉन्च को ब्लॉक कर सकते हैं। - चरण 3: रिडायरेक्ट को टाइमर से अलग करें: जाँच करें कि क्या गैर-जेस्चर नेविगेशन एक अधिकृत HTTP 3xx सर्वर रिडायरेक्ट (Android पर
request.isRedirect) बनाम एक बिना संकेत के JavaScript टाइमर है। - चरण 4: नई-विंडो ट्रिगर की जाँच करें: पुष्टि करें कि क्या
target="_blank"याwindow.open()ने एक नया-विंडो अनुरोध बनाया है (iOS परtargetFrame == nilया Android परonCreateWindow)। - चरण 5: OS पैकेज रिज़ॉल्यूशन सत्यापित करें: Android 11+ पर API 30+ को लक्षित करने वाले ऐप्स के लिए, पुष्टि करें कि क्या गायब
<queries>घोषणाओं के कारण प्री-फ़्लाइटresolveActivity()कॉल विफल हो रहे हैं।
निम्नलिखित नैदानिक वर्कफ़्लो कंटेनर रिडायरेक्शन विफलताओं को अलग करने के लिए अनुक्रमिक ट्राइएज पथ को दर्शाता है:
[WebView Navigation Failure]
│
▼
[Inspect URL + Network + Console via Chrome DevTools / Safari Web Inspector]
│
▼
[Identify Navigation Source]
│
├── App loadUrl() or HTTP POST
│ │
│ └── shouldOverrideUrlLoading is NOT invoked; inspect host-side call path
│
├── target="_blank" or window.open()
│ │
│ ├── Android (multiple-windows=false) ──> Replaces current WebView page
│ ├── Android (multiple-windows=true) ──> Inspect onCreateWindow + shouldInterceptRequest
│ └── iOS (targetFrame == nil) ──> Inspect WKNavigationDelegate + WKUIDelegate
│
├── HTTP / HTTPS Navigation
│ │
│ └── Inspect Host + Port Allowlist, 3xx Redirects, Universal Link, or App Link matching
│
└── Custom Scheme or Chrome intent://
│
├── Evaluate User Interaction + Main Frame policy
├── Verify Full URI Structure (Scheme, Host, Port, Path, No Duplicate Query Keys)
├── Sanitize Intent (Reject Explicit Components, Verify 1-to-1 Package, Zero Webpage Flags)
├── Check Target-App Resolution (<queries> / ActivityNotFoundException)
└── Validate Fallback Path + Query Allowlist + Monotonic Chain Guard (elapsedRealtime)
दूरस्थ डिबगिंग टूल का उपयोग करके WebView नेविगेशन इवेंट का निरीक्षण कैसे करें
Android पर Chrome DevTools और ADB Logcat के माध्यम से रिमोट डिबगिंग सक्षम करना
नेटिव डेलिगेट को संशोधित करने से पहले, सत्यापित करें कि लोड किया गया वेब पेज अपेक्षित रिडायरेक्ट उत्सर्जित करता है या नहीं। Android Chrome DevTools रिमोट डिबगिंग गाइड के अनुसार, ApplicationInfo.FLAG_DEBUGGABLE का निरीक्षण करके और WebView.setWebContentsDebuggingEnabled(true) को कॉल करके विकास बिल्ड में रिमोट WebView डिबगिंग को स्पष्ट रूप से सक्षम करें। उत्पादन रिलीज़ में कभी भी डिबगिंग सक्षम करके न भेजें:
// Android - Enable WebView debugging exclusively in debuggable builds
if (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0) {
WebView.setWebContentsDebuggingEnabled(true)
}
USB के माध्यम से डिवाइस को कनेक्ट करें, डेस्कटॉप Chrome में chrome://inspect/#devices खोलें, और Preserve log चेक के साथ Network टैब की निगरानी करें। ActivityNotFoundException, SecurityException, या कस्टम रैपर लॉग को कैप्चर करने के लिए adb logcat के माध्यम से नेटिव रनटाइम लॉग को एक साथ फ़िल्टर करें। ध्यान दें कि लीगेसी shouldOverrideUrlLoading(WebView, String) हस्ताक्षर के लिए अवमूल्यन चेतावनियाँ रनटाइम adb logcat के बजाय Android Studio / Gradle संकलन के दौरान दिखाई देती हैं:
# Terminal - Filter logcat for custom WebView tags and ActivityTaskManager intent resolution
adb logcat -s "WebViewDebug" "ActivityTaskManager" "PackageManager"
iOS पर isInspectable कॉन्फ़िगर करना और Safari Web Inspector तथा Xcode कंसोल को अटैच करना
iOS 16.4 और macOS 13.3 से शुरू होकर, Apple को WKWebView.isInspectable के माध्यम से ऑप्ट-इन करने के लिए एप्लिकेशन की आवश्यकता होती है, जो डिफ़ॉल्ट रूप से false होता है। #if DEBUG ब्लॉकों के अंदर webView.isInspectable = true सक्षम करें:
// iOS - Enable Safari Web Inspector opt-in on iOS 16.4+ debug builds
#if DEBUG
if #available(iOS 16.4, *) {
webView.isInspectable = true
}
#endif
भौतिक iOS डिवाइस पर, Settings > Apps > Safari > Advanced (पुराने iOS रिलीज़ पर, Settings > Safari > Advanced) पर जाएं और Web Inspector सक्षम करें। USB के माध्यम से कनेक्ट करें, डेस्कटॉप Safari का Develop मेनू खोलें, और नेटिव decidePolicyForNavigationAction, createWebViewWith, और UIApplication.shared.open पूर्णता आउटपुट के लिए एक साथ Xcode Console की निगरानी करें।

iOS WKWebView में साइलेंट न्यू विंडो ड्रॉप्स और गायब यूजर जेस्चर को हल करना
WKNavigationDelegate और WKUIDelegate में नीति मूल्यांकन को साइड इफ़ेक्ट से अलग करना
जब कोई वेब लिंक target="_blank" या window.open() निर्दिष्ट करता है, तो WebKit एक नई-विंडो नेविगेशन अनुरोध बनाता है जहाँ navigationAction.targetFrame nil होता है और इसमें WKNavigationDelegate और WKUIDelegate दोनों शामिल होते हैं। यदि होस्ट ऐप webView(_:createWebViewWithConfiguration:for:windowFeatures:) को लागू नहीं करता है, तो WebKit एक माध्यमिक WebView को स्पॉन नहीं कर सकता है, और नेविगेशन चुपचाप विफल प्रतीत हो सकते हैं।
जब दोनों डेलिगेट किसी अनुरोध का निरीक्षण करते हैं, तो डुप्लिकेट बाहरी ऐप लॉन्च या दो बार-वृद्धिशील पीढ़ी टोकन को रोकने के लिए, शुद्ध नीति मूल्यांकन (evaluateNavigationPolicy) को निष्पादन साइड इफेक्ट्स से अलग करें, और किसी मोटे समय सीमा पर पूरी तरह से भरोसा करने के बजाय विशिष्ट WKNavigationAction उदाहरण (ObjectIdentifier(navigationAction)) द्वारा डिडुप्लीकेट करें जो उपयोगकर्ता द्वारा जानबूझकर तेजी से दोहराए जाने वाले क्लिक को दबा सकता है। decidePolicyForNavigationAction में सीधे navigationAction.targetFrame == nil का मूल्यांकन करें: यदि मूल्यांकन एक बाहरी हैंडऑफ़ योजना लौटाता है, तो इसे एक बार निष्पादित करें (WKNavigationAction पहचानकर्ता को रिकॉर्ड करते हुए) और .cancel पास करें; यदि यह किसी अनुमत पॉपअप URL के लिए .allowInWebView लौटाता है, तो .allow पास करें ताकि createWebViewWith पॉपअप को सुरक्षित रूप से लोड करे। लक्षित iOS संस्करणों पर हमेशा सटीक डेलिगेट कॉलबैक क्रम को सत्यापित करें।
यूनिवर्सल लिंक संदर्भ, असमकालिक रेस सुरक्षा, और कस्टम स्कीम पहचान
यूनिवर्सल लिंक हैंडऑफ़ स्रोत ब्राउज़िंग संदर्भ, डोमेन संबंध और संबद्ध डोमेन कॉन्फ़िगरेशन (लक्ष्य सर्वर की apple-app-site-association फ़ाइल के माध्यम से सत्यापित) पर निर्भर करता है। Apple का तकनीकी नोट TN3155: डिबगिंग यूनिवर्सल लिंक्स यह दस्तावेज़ देता है कि कैसे Safari में समान-डोमेन नेविगेशन ब्राउज़र में रहने का पक्ष लेता है, जबकि अलग उपडोमेन पात्रता बदलते हैं। WKWebView के अंदर लक्षित iOS रिलीज़ पर हमेशा संबद्ध डोमेन व्यवहार का परीक्षण करें।
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) को कॉल करते समय, असमकालिक नेविगेशन रेस स्थितियों के खिलाफ सुरक्षा करें: यदि कोई उपयोगकर्ता सिस्टम द्वारा यूनिवर्सल लिंक हैंडऑफ़ को संसाधित करते समय कोई भी बाद का मुख्य-फ्रेम नेविगेशन प्रयास शुरू करता है, तो false लौटने वाला एक असुरक्षित पूर्णता हैंडलर उपयोगकर्ता की नई नेविगेशन स्थिति को अधिलेखित कर सकता है। प्रत्येक नए मुख्य-फ्रेम नेविगेशन मूल्यांकन (अवरुद्ध या पुनर्निर्देशित प्रयासों सहित) पर एक मोनोनोमिक activeNavigationGeneration टोकन को बढ़ाएं ताकि किसी भी लंबित पूर्व असमकालिक फ़ॉलबैक को तुरंत अमान्य कर दिया जाए, और फ़ॉलबैक URL को पुनः लोड करने से पहले self.isViewLoaded && self.view.window != nil के साथ self.activeNavigationGeneration == requestGeneration को सत्यापित करें।
दो सख्त सुरक्षा सीमाओं का पालन करें:
WKNavigationTypeवर्गीकरण: Apple केWKNavigationTypeदस्तावेज़ के अनुसार,formSubmittedलिंक टैप के बजाय फॉर्म सबमिट करने के अनुरोध का प्रतिनिधित्व करता है, और पेज स्क्रिप्ट प्रोग्रामेटिक रूप से फॉर्म सबमिट कर सकती हैं। बाहरी ऐप हैंडऑफ़ को.linkActivatedको एक पृथक क्रिप्टोग्राफिक जेस्चर टोकन मानने के बजाय WebKit-वर्गीकृत.linkActivatedघटनाओं तक सीमित करें जोsourceFrame.isMainFrameऔर पूर्ण URI अनुमति सूचियों के साथ संयुक्त हैं।- कस्टम स्कीम विशिष्टता और पैरामीटर प्रदूषण: अपने ऐप के लिए कस्टम URL स्कीम परिभाषित करने पर Apple की मार्गदर्शिका के अनुसार, एकाधिक ऐप्स समान कस्टम स्कीम का दावा कर सकते हैं।
isAllowedCustomURL(_:)URI संरचना (स्कीम, होस्ट, डिफ़ॉल्ट पोर्टnil, पथ पैटर्न, कोई यूज़रइफ़ो/फ़्रैगमेंट नहीं, और डुप्लिकेट क्वेरी कुंजियों को अस्वीकार करना) को सत्यापित करता है, न कि लक्षित बंडल आईडी पहचान को। जब भी ऐप पहचान बाइंडिंग की आवश्यकता हो, डोमेन-सत्यापित यूनिवर्सल लिंक का उपयोग करें।
संदर्भ वास्तुकला अस्वीकरण: निम्नलिखित कार्यान्वयन एक रक्षात्मक संदर्भ वास्तुकला है। आपके एप्लिकेशन द्वारा उपयोग किए जाने वाले सटीक AndroidX और iOS संस्करणों के विरुद्ध API उपलब्धता, डेलिगेट ऑर्डरिंग और जीवनचक्र व्यवहार को सत्यापित करें।
// iOS - WebViewContainerController.swift
// Reference architecture: compile and test against your specific project targets (iOS 15.0–18.0)
import UIKit
import WebKit
final class WebViewContainerController: UIViewController, WKNavigationDelegate, WKUIDelegate {
private enum NavigationPlan: Equatable {
case allowInWebView
case launchCustomScheme(URL)
case attemptUniversalLink(URL)
case block
}
private var webView: WKWebView!
// Explicit allowlist for external custom URL schemes, hosts, and query keys
private let allowedCustomSchemes: Set<String> = ["myapp", "partnerapp"]
private let allowedCustomHosts: Set<String> = ["open", "product", "promo"]
private let allowedCustomQueryKeys: Set<String> = ["id", "ref", "promo"]
// Explicit allowlist for HTTPS hosts permitted inside the primary WebView container
private let allowedWebHosts: Set<String> = [
"example.com",
"m.example.com",
"links.example.com"
]
// Isolated allowlists specifically for child popup windows (target="_blank")
private let allowedPopupHosts: Set<String> = ["example.com", "auth.example.com"]
private let allowedPopupPathPrefixes: [String] = ["/oauth", "/popup", "/window"]
// External Universal Link hosts that attempt native app handoff on link activation
private let externalUniversalLinkHosts: Set<String> = ["links.example.com"]
// Monotonic navigation generation token incremented on every new main-frame navigation attempt
private var activeNavigationGeneration: UInt64 = 0
// Action-level deduplication preventing duplicate dispatches for the same WKNavigationAction
private var dispatchedActionIDs: [ObjectIdentifier] = []
private let maxTrackedActionIDs = 16
// Monotonic-uptime TTL-bounded bypass cache keyed by normalized Universal Link key
private var bypassedUniversalLinkKeys: [String: TimeInterval] = [:]
private let maxBypassedKeys = 10
private let bypassTTLSeconds: TimeInterval = 300
// Adapt significant query keys to match your application's actual routing parameters
private let significantLoopQueryKeys: Set<String> = ["id"]
override func viewDidLoad() {
super.viewDidLoad()
let configuration = WKWebViewConfiguration()
webView = WKWebView(frame: view.bounds, configuration: configuration)
webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
webView.navigationDelegate = self
webView.uiDelegate = self
#if DEBUG
if #available(iOS 16.4, *) {
webView.isInspectable = true
}
#endif
view.addSubview(webView)
}
// MARK: - WKNavigationDelegate
func webView(
_ webView: WKWebView,
decidePolicyFor navigationAction: WKNavigationAction,
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void
) {
guard let url = navigationAction.request.url else {
decisionHandler(.cancel)
return
}
let isMainFrame = navigationAction.sourceFrame.isMainFrame
let isNewWindow = (navigationAction.targetFrame == nil)
// Increment generation token on every main-frame navigation attempt (including blocked attempts)
// so any pending prior asynchronous Universal Link fallback is invalidated immediately.
if isMainFrame && !isNewWindow {
activeNavigationGeneration &+= 1
}
let requestGeneration = activeNavigationGeneration
let plan = evaluateNavigationPolicy(
url: url,
navigationType: navigationAction.navigationType,
isMainFrame: isMainFrame,
isNewWindow: isNewWindow
)
switch plan {
case .allowInWebView:
decisionHandler(.allow)
case .launchCustomScheme(let targetURL):
if isMainFrame { activeNavigationGeneration &+= 1 }
executeExternalDispatchOnce(
action: navigationAction,
url: targetURL,
isUniversalLink: false,
requestGeneration: activeNavigationGeneration
)
decisionHandler(.cancel)
case .attemptUniversalLink(let targetURL):
if isMainFrame { activeNavigationGeneration &+= 1 }
let currentGen = activeNavigationGeneration
executeExternalDispatchOnce(
action: navigationAction,
url: targetURL,
isUniversalLink: true,
requestGeneration: currentGen
)
decisionHandler(.cancel)
case .block:
decisionHandler(.cancel)
}
}
// MARK: - WKUIDelegate (Handles target="_blank" and window.open)
func webView(
_ webView: WKWebView,
createWebViewWith configuration: WKWebViewConfiguration,
for navigationAction: WKNavigationAction,
windowFeatures: WKWindowFeatures
) -> WKWebView? {
guard navigationAction.targetFrame == nil,
let url = navigationAction.request.url else {
return nil
}
let isMainFrame = navigationAction.sourceFrame.isMainFrame
if isMainFrame {
activeNavigationGeneration &+= 1
}
let currentGen = activeNavigationGeneration
let plan = evaluateNavigationPolicy(
url: url,
navigationType: navigationAction.navigationType,
isMainFrame: isMainFrame,
isNewWindow: true
)
switch plan {
case .allowInWebView:
webView.load(navigationAction.request)
case .launchCustomScheme(let targetURL):
executeExternalDispatchOnce(
action: navigationAction,
url: targetURL,
isUniversalLink: false,
requestGeneration: currentGen
)
case .attemptUniversalLink(let targetURL):
executeExternalDispatchOnce(
action: navigationAction,
url: targetURL,
isUniversalLink: true,
requestGeneration: currentGen
)
case .block:
break
}
return nil
}
// MARK: - Pure Navigation Policy Evaluation (Zero Side Effects)
private func evaluateNavigationPolicy(
url: URL,
navigationType: WKNavigationType,
isMainFrame: Bool,
isNewWindow: Bool
) -> NavigationPlan {
guard let scheme = url.scheme?.lowercased() else {
return .block
}
let isLinkActivated = (navigationType == .linkActivated)
// 1. Evaluate non-HTTP/HTTPS Custom URL Schemes
// Note: Custom scheme allowlisting validates URI structure; it cannot guarantee target Bundle ID identity.
if scheme != "http" && scheme != "https" {
guard isMainFrame, isLinkActivated, isAllowedCustomURL(url) else {
return .block
}
return .launchCustomScheme(url)
}
// 2. Enforce HTTPS-only, default port (nil or 443), and Host Allowlists
let targetHost = url.host?.lowercased()
if isNewWindow {
guard isMainFrame, isLinkActivated, isAllowedPopupWebURL(url) else {
return .block
}
} else {
guard isAllowedWebURL(url), let host = targetHost, allowedWebHosts.contains(host) else {
return .block
}
}
// 3. Evaluate Universal Link Handoffs for designated external hosts on link activation
if let host = targetHost,
externalUniversalLinkHosts.contains(host),
isMainFrame,
isLinkActivated,
let loopKey = universalLinkLoopKey(for: url),
!isBypassedKeyActive(loopKey) {
return .attemptUniversalLink(url)
}
return .allowInWebView
}
// MARK: - Action-Level Deduplicated External Dispatch Execution
private func executeExternalDispatchOnce(
action: WKNavigationAction,
url: URL,
isUniversalLink: Bool,
requestGeneration: UInt64
) {
let actionID = ObjectIdentifier(action)
if dispatchedActionIDs.contains(actionID) {
return
}
if dispatchedActionIDs.count >= maxTrackedActionIDs {
dispatchedActionIDs.removeFirst()
}
dispatchedActionIDs.append(actionID)
if isUniversalLink {
guard let loopKey = universalLinkLoopKey(for: url) else { return }
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { [weak self] success in
// Verify view lifecycle AND generation token to prevent stale async fallback overwrites
guard let self = self,
self.isViewLoaded,
self.view.window != nil,
self.activeNavigationGeneration == requestGeneration else {
return
}
if !success {
self.recordBypassedKey(loopKey)
self.webView.load(URLRequest(url: url))
}
}
} else {
UIApplication.shared.open(url, options: [:]) { success in
if !success {
print("[WebViewDebug] Failed to launch custom scheme (app may not be installed)")
}
}
}
}
private func isAllowedWebURL(_ url: URL) -> Bool {
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let scheme = components.scheme?.lowercased(),
scheme == "https",
components.user == nil,
components.password == nil,
(components.port == nil || components.port == 443) else {
return false
}
return true
}
private func isAllowedPopupWebURL(_ url: URL) -> Bool {
guard isAllowedWebURL(url),
let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let host = components.host?.lowercased(),
allowedPopupHosts.contains(host),
components.fragment == nil else {
return false
}
let path = components.path
return allowedPopupPathPrefixes.contains { path == $0 || path.hasPrefix("\($0)/") }
}
private func isAllowedCustomURL(_ url: URL) -> Bool {
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let scheme = components.scheme?.lowercased(),
let host = components.host?.lowercased(),
allowedCustomSchemes.contains(scheme),
allowedCustomHosts.contains(host),
components.user == nil,
components.password == nil,
components.port == nil, // Reject explicit ports on custom schemes
components.fragment == nil else {
return false
}
let path = components.path
if !path.isEmpty &&
path.range(of: "^/[A-Za-z0-9/_-]{1,64}$", options: .regularExpression) == nil {
return false
}
if let queryItems = components.queryItems {
var seenKeys = Set<String>()
for item in queryItems {
if seenKeys.contains(item.name) {
return false
}
seenKeys.insert(item.name)
guard allowedCustomQueryKeys.contains(item.name),
let value = item.value,
value.count <= 64,
value.range(of: "^[A-Za-z0-9_-]+$", options: .regularExpression) != nil else {
return false
}
}
}
return true
}
private func universalLinkLoopKey(for url: URL) -> String? {
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let scheme = components.scheme?.lowercased(),
let host = components.host?.lowercased() else {
return nil
}
let portPart = (components.port != nil && components.port != 443) ? ":\(components.port!)" : ""
let significantParams = (components.queryItems ?? [])
.filter { significantLoopQueryKeys.contains($0.name) }
.sorted { $0.name < $1.name }
.map { "\($0.name)=\($0.value ?? "")" }
.joined(separator: "&")
let querySuffix = significantParams.isEmpty ? "" : "?\(significantParams)"
return "\(scheme)://\(host)\(portPart)\(components.path)\(querySuffix)"
}
private func isBypassedKeyActive(_ key: String) -> Bool {
let now = ProcessInfo.processInfo.systemUptime
bypassedUniversalLinkKeys = bypassedUniversalLinkKeys.filter {
(now - $0.value) < bypassTTLSeconds
}
return bypassedUniversalLinkKeys[key] != nil
}
private func recordBypassedKey(_ key: String) {
let now = ProcessInfo.processInfo.systemUptime
bypassedUniversalLinkKeys = bypassedUniversalLinkKeys.filter {
(now - $0.value) < bypassTTLSeconds
}
if bypassedUniversalLinkKeys.count >= maxBypassedKeys,
let oldestKey = bypassedUniversalLinkKeys.min(by: { $0.value < $1.value })?.key {
bypassedUniversalLinkKeys.removeValue(forKey: oldestKey)
}
bypassedUniversalLinkKeys[key] = now
}
}
Android WebView में ERR_UNKNOWN_URL_SCHEME और पैकेज विज़िबिलिटी विफलताओं को ठीक करना
अवमूल्यित कॉलबैक, hasGesture(), और POST सीमाएं
Android ने API लेवल 24 में shouldOverrideUrlLoading(WebView, WebResourceRequest) के पक्ष में shouldOverrideUrlLoading(WebView, String) को अवमूल्यित कर दिया है। WebResourceRequest isForMainFrame, isRedirect, और hasGesture() प्रदान करता है। दो आधिकारिक प्लेटफ़ॉर्म बाधाएं ध्यान दें: shouldOverrideUrlLoading होस्ट-आरंभ किए गए webView.loadUrl() कॉल या HTTP POST नेविगेशन के लिए आह्वान नहीं किया जाता है, और hasGesture() वैध असमकालिक JavaScript रिडायरेक्ट या सर्वर-साइड 302 हॉप्स के लिए false लौटा सकता है।
WebChromeClient.onCreateWindow में डिफेंस-इन-दप्थ पॉपअप हैंडलिंग और थ्रेड आइसोलेशन
Android पॉपअप व्यवहार WebSettings.setSupportMultipleWindows पर निर्भर करता है। यदि आपके ऐप को इंटरैक्टिव पॉपअप की आवश्यकता नहीं है, तो setSupportMultipleWindows(false) (या onCreateWindow से false लौटना) रखना तृतीय-पक्ष iframe को माध्यमिक कंटेनर खोलने से रोकता है—या एक स्पष्ट, होस्ट-नियंत्रित प्रविष्टि बिंदु के माध्यम से सत्यापित गंतव्य खोलता है।
जब setSupportMultipleWindows(true) सक्षम होता है, तो WebChromeClient.onCreateWindow अपने कॉलबैक हस्ताक्षर में गंतव्य URL प्रदान नहीं करता है, और कोई भी एकल कॉलबैक प्रत्येक नेविगेशन वेक्टर को कवर नहीं करता है। सटीक थ्रेड मॉडल और कॉलबैक सीमाओं को समझना डिफेंस-इन-दप्थ संदर्भ दृष्टिकोण के लिए आवश्यक है:
shouldOverrideUrlLoading(UI थ्रेड — नेविगेशन और सत्र स्थिति स्वामी): विशेष रूप से UI थ्रेड पर चलता है और सभी परिवर्तनशील पॉपअप सत्र स्थिति (isInitialTransportLoad,isAuthorizedPopupSession,popupRedirectHops, औरpopupChainStartMs) का मालिक है। केवल एक बार जब कोई सत्यापित प्रारंभिक लोड या प्रत्यक्ष उपयोगकर्ता जेस्चरpolicy.isAllowedPopupUriसे मेल खाता है, तोshouldOverrideUrlLoadingबाद के परिबद्ध HTTP 302 रिडायरेक्ट (request.isRedirect) के लिए सत्र को अधिकृत करता है, जिससे यह सुनिश्चित होता है कि रिडायरेक्ट श्रृंखलाएं मनमाने रिडायरेक्ट पर भरोसा करने के बजाय किसी अधिकृत सत्र से जुड़ी हैं।shouldInterceptRequest(बैकग्राउंड WebView IO थ्रेड — स्टेटलेस रीड-ओनली गार्ड): एक गैर-UI WebView थ्रेड पर चलता है। चूंकि इसे कभी भी UI-थ्रेड सत्र स्थिति को म्यूट नहीं करना चाहिए, यहsafeClient.policyपर एक स्टेटलेस, रीड-ओनली नीति जांच के रूप में कड़ाई से काम करता है (isFailedAllowedPopupUriमें विफल होने वाले मुख्य-फ्रेम HTTP/HTTPS अनुरोधों को अवरुद्ध करना और मुख्य थ्रेड परdisposeActivePopup()प्रेषित करना)। ध्यान दें कि Android दस्तावेज़ के अनुसार,shouldInterceptRequestको केवल प्रारंभिक संसाधन URL के लिए कॉल किया जाता है, बाद के HTTP 302 रिडायरेक्ट URL के लिए नहीं; बाद के रिडायरेक्ट URL का मूल्यांकनshouldOverrideUrlLoadingद्वारा किया जाना चाहिए।onPageStarted(UI थ्रेड — नेविगेशन-आरंभ फ़ॉलबैक जांच): मुख्य-फ्रेम लोड होने पर निष्पादित होता है (पूर्व-नेविगेशन फ़िल्टर के रूप में नहीं)। यह उपयोगकर्ता पारदर्शिता के लिए दिखाई देने वाले ओरिजिन बैनर को अपडेट करता है और यदि कोई अस्वीकृत गंतव्य लोड होना शुरू होता है तोstopLoading()औरdisposeActivePopup()को कॉल करने वाली नेविगेशन-आरंभ फ़ॉलबैक जांच प्रदान करता है।
लक्ष्य भौतिक WebView बिल्ड पर हमेशा दुर्भावनापूर्ण प्रारंभिक URL, क्रॉस-डोमेन HTTP 302 श्रृंखलाओं, लगातार 302 रिडायरेक्ट, target="_blank", window.open(), और तृतीय-पक्ष iframe ट्रिगर्स का परीक्षण करें।
Android 11+ पैकेज विज़िबिलिटी और अवमूल्यित canOpenURL मार्गदर्शन
Android पैकेज विज़िबिलिटी नियमों के तहत, Android 11 (API लेवल 30) या उच्चतर पर चलने वाले और API लेवल 30 या उच्चतर को लक्षित करने वाले (targetSdk >= 30) एप्लिकेशन को intent.resolveActivity() या queryIntentActivities() से null या खाली परिणाम प्राप्त होते हैं जब तक कि लक्ष्य ऐप्स को AndroidManifest.xml में <queries> के तहत घोषित न किया जाए। Android <queries> का विस्तार करने के बजाय ActivityNotFoundException और SecurityException के लिए try/catch के अंदर सीधे startActivity(intent) को कॉल करने की अनुशंसा करता है।
iOS पर, Apple ने UIApplication.canOpenURL(_:) को अवमूल्यित कर दिया है और सीधे UIApplication.shared.open(_:options:completionHandler:) का प्रयास करने और पूर्णता हैंडलर में किसी भी विफलता को संभालने (या स्कीम पूर्व-सत्यापन को हटाने के लिए यूनिवर्सल लिंक पर माइग्रेट करने) की अनुशंसा करता है। Info.plist में LSApplicationQueriesSchemes की आवश्यकता केवल तभी होती है जब लीगेसी कोड canOpenURL(_:) को कॉल करना जारी रखता है, जबकि open(_:options:completionHandler:) को Info.plist में स्कीम घोषित करने की आवश्यकता नहीं होती है। <queries> और LSApplicationQueriesSchemes दोनों क्वेरी विज़िबिलिटी को नियंत्रित करते हैं — वे अप्रमाणित वेब URI को सत्यापित करने के लिए सुरक्षा अनुमति सूचियां नहीं हैं।
<!-- Manifest Fragment: Merge <queries> into your existing AndroidManifest.xml -->
<!-- Required for targetSdk >= 30 on Android 11+ ONLY if calling resolveActivity or queryIntentActivities -->
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="partnerapp" />
</intent>
</queries>
<!-- Info.plist Fragment: Insert under the root <dict> in Info.plist -->
<!-- Legacy: Required on iOS ONLY if calling deprecated UIApplication.shared.canOpenURL; open(_:options:completionHandler:) does not require this key -->
<key>LSApplicationQueriesSchemes</key>
<array>
<string>myapp</string>
<string>partnerapp</string>
</array>
Chrome Intent URI को सुरक्षित रूप से कैसे पार्स करें और रिडायरेक्ट लूप को कैसे रोकें
Intent रिडायरेक्शन शोषण के विरुद्ध Intent.parseUri को सुरक्षित करना
Android intent:// URI एक लक्ष्य स्कीम, पैकेज, और फ़ॉलबैक URL (S.browser_fallback_url) को एन्कोड करते हैं। Android Intent Redirection सुरक्षा गाइड और OWASP मोबाइल एप्लिकेशन सुरक्षा परीक्षण गाइड में विस्तृत Intent.parseUri(rawUri, Intent.URI_INTENT_SCHEME) के माध्यम से अप्रमाणित वेब URI को पार्स करने से Intent Redirection जोखिम पैदा होते हैं। Android 16 (API 36) द्वारा प्लेटफ़ॉर्म-स्तरीय डिफ़ॉल्ट हार्डनिंग जोड़ने के बावजूद, अनुप्रयोगों को Intent प्रेषित करने से पहले कड़ाई से सत्यापन लागू करना चाहिए।

AndroidX IntentSanitizer (androidx.core:core:1.9.0+, या androidx.core:core-ktx:1.9.0+ जो androidx.core:core को बंडल करता है) का उपयोग करके फ़ेल-क्लोज़्ड सत्यापन लागू करने के लिए allowAnyComponent() और पैकेज/घटक अनुमति सूची विधियों के बीच बिल्डर परस्पर-अपवर्जन संघर्षों को ट्रिगर किए बिना:
- प्री-सैनिटाइजेशन जांच: गैर-शून्य
componentयाselectorफ़ील्ड (parsedIntent.component != null || parsedIntent.selector != null) ले जाने वाले intent को तुरंत अस्वीकार करें। सैनिटाइजेशन से पहलेbrowser_fallback_urlको निकालें और हटाएं, और मूल रूप से सत्यापित करें किparsedIntent.data?.schemecustomSchemeTargetPackagesके माध्यम सेparsedIntent.package`` से 1-से-1 मैप होता है (यह सुनिश्चित करते हुए किmyapp://कड़ाई सेcom.example.targetको हल करता है, किसी अन्य पार्टनर पैकेज को नहीं)। - सैनिटाइज़र निष्पादन: अप्रमाणित प्रतिलिपि पर अस्थायी रूप से
parsedIntent.package= nullसाफ़ करें,IntentSanitizer.Builder().allowAnyComponent().allowAction(Intent.ACTION_VIEW).allowCategory(Intent.CATEGORY_BROWSABLE).allowData { ... }.build().sanitizeByThrowing(parsedIntent)(शून्य वेबपेज-आपूर्ति किए गए टास्क फ़्लैग) निष्पादित करें, और पोस्ट-सैनिटाइजेशन मुखरताओं से पहले सैनिटाइज़्ड होस्ट-स्वामित्व वाले Intent पर सत्यापितexpectedPackageऔरCATEGORY_BROWSABLEको पुनः असाइन करें। - संदर्भ-जागरूक लॉन्च फ़्लैग: नेटिव डिस्पैचर (
launchWithContextSafety) के अंदरIntent.FLAG_ACTIVITY_NEW_TASKकेवल तभी इन्जेक्ट करें जबview.context !is Activityहो। डोमेन-से-ऐप एसोसिएशन सत्यापन के लिए, सत्यापित HTTPS Android ऐप लिंक (assetlinks.json) को प्राथमिकता दें।
मोनोनोमिक चेन स्थिति के साथ अनंत फ़ॉलबैक लूप को रोकना
जब startActivity ActivityNotFoundException फेंकता है, तो समर्पित isAllowedFallbackUri(uri) जांच (कड़ाई से HTTPS, डिफ़ॉल्ट पोर्ट, सत्यापित होस्ट, स्पष्ट फ़ॉलबैक पथ उपसर्ग, कोई डुप्लिकेट क्वेरी कुंजियाँ नहीं, और कोई फ़्रैगमेंट नहीं) के साथ browser_fallback_url को सत्यापित करें। uri.port == -1 और !uri.encodedAuthority.orEmpty().contains(":") दोनों को सत्यापित करके कस्टम स्कीम पर स्पष्ट पोर्ट अभ्यावेदन को अस्वीकार करें।
SystemClock.elapsedRealtime() (वॉल-क्लॉक System.currentTimeMillis() जंप से बचते हुए) का उपयोग करके फ़ॉलबैक श्रृंखलाओं को ट्रैक करें, fallbackLoopKey() के माध्यम से श्रृंखलाओं को अलग करें (पूर्ण IETF RFC 3986 कैनोनिकलन नहीं), स्पष्ट loadNewNavigation(webView, url) होस्ट रैपर के माध्यम से स्थिति रीसेट करें, और पॉपअप फ़ॉलबैक को onPopupFallbackHandoff के माध्यम से प्राथमिक कंटेनर पर रूट करें ताकि अनधिकृत डोमेन कभी भी पॉपअप संवाद के अंदर लोड न हों।
संदर्भ वास्तुकला अस्वीकरण: निम्नलिखित कार्यान्वयन एक रक्षात्मक संदर्भ वास्तुकला है। आपके एप्लिकेशन द्वारा उपयोग किए जाने वाले सटीक AndroidX और iOS संस्करणों के विरुद्ध API उपलब्धता, डेलिगेट ऑर्डरिंग और जीवनचक्र व्यवहार को सत्यापित करें।
// Android - SafeWebViewModules.kt
// Reference architecture: compile and test against your specific project targets
// Requires androidx.core:core:1.9.0+ (or androidx.core:core-ktx:1.9.0+) for IntentSanitizer; targets minSdk >= 24.
package com.example.hostapp.webview
import android.app.Activity
import android.app.Dialog
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.net.Uri
import android.os.Bundle
import android.os.Message
import android.os.SystemClock
import android.util.Log
import android.view.ViewGroup
import android.widget.TextView
import android.webkit.WebChromeClient
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.IntentSanitizer
import java.io.ByteArrayInputStream
import java.net.URISyntaxException
// 1. Policy Module (Immutable / Thread-Safe for read-only access from IO & UI threads)
class CustomUriPolicy(
val customSchemeTargetPackages: Map<String, String> = mapOf(
"myapp" to "com.example.target",
"partnerapp" to "com.partner.app"
),
val allowedCustomHosts: Set<String> = setOf("open", "product", "promo"),
val allowedCustomQueryKeys: Set<String> = setOf("id", "ref", "promo"),
val allowedWebHosts: Set<String> = setOf("example.com", "downloads.example.com"),
val allowedFallbackHosts: Set<String> = setOf("downloads.example.com", "example.com"),
val allowedFallbackPathPrefixes: List<String> = listOf("/download", "/app", "/landing"),
val allowedFallbackQueryKeys: Set<String> = setOf("id", "ref", "promo", "utm_source"),
// Isolated allowlists explicitly for popup windows; distinct from general web hosts
val allowedPopupHosts: Set<String> = setOf("example.com", "auth.example.com"),
val allowedPopupPathPrefixes: List<String> = listOf("/oauth", "/popup", "/window")
) {
val allowedCustomSchemes: Set<String> get() = customSchemeTargetPackages.keys
val allowedTargetPackages: Set<String> get() = customSchemeTargetPackages.values.toSet()
private val pathPattern = Regex("^/[A-Za-z0-9/_-]{1,64}$")
private val queryValuePattern = Regex("^[A-Za-z0-9_-]{1,64}$")
fun isAllowedWebUri(uri: Uri): Boolean {
val scheme = uri.scheme?.lowercase() ?: return false
val host = uri.host?.lowercase() ?: return false
return scheme == "https" &&
host in allowedWebHosts &&
(uri.port == -1 || uri.port == 443) &&
uri.userInfo == null
}
fun isAllowedPopupUri(uri: Uri): Boolean {
val scheme = uri.scheme?.lowercase() ?: return false
val host = uri.host?.lowercase() ?: return false
if (scheme != "https" || host !in allowedPopupHosts) return false
if ((uri.port != -1 && uri.port != 443) || uri.userInfo != null || uri.fragment != null) return false
val path = uri.path.orEmpty()
return allowedPopupPathPrefixes.any { path == it || path.startsWith("$it/") } && pathPattern.matches(path)
}
fun isAllowedFallbackUri(uri: Uri): Boolean {
val scheme = uri.scheme?.lowercase() ?: return false
val host = uri.host?.lowercase() ?: return false
if (scheme != "https" || host !in allowedFallbackHosts) return false
if ((uri.port != -1 && uri.port != 443) || uri.userInfo != null || uri.fragment != null) {
return false
}
val path = uri.path.orEmpty()
if (allowedFallbackPathPrefixes.none { path == it || path.startsWith("$it/") } ||
!pathPattern.matches(path)
) {
return false
}
// Validate query keys, enforce value syntax, and reject duplicate keys
val queryNames = uri.queryParameterNames
for (paramName in queryNames) {
if (paramName !in allowedFallbackQueryKeys) return false
val values = uri.getQueryParameters(paramName)
if (values.size != 1 || !queryValuePattern.matches(values[0])) return false
}
return true
}
fun isAllowedCustomUri(uri: Uri): Boolean {
val scheme = uri.scheme?.lowercase() ?: return false
val host = uri.host?.lowercase() ?: return false
if (scheme !in allowedCustomSchemes || host !in allowedCustomHosts) return false
// Reject network ports strictly by checking both uri.port == -1 and raw authority colon absence
val rawAuthority = uri.encodedAuthority.orEmpty()
if (uri.userInfo != null || uri.port != -1 || rawAuthority.contains(":") || uri.fragment != null) {
return false
}
val path = uri.path.orEmpty()
if (path.isNotEmpty() && !pathPattern.matches(path)) return false
// Validate query keys, enforce value syntax, and reject duplicate keys
val queryNames = uri.queryParameterNames
for (paramName in queryNames) {
if (paramName !in allowedCustomQueryKeys) return false
val values = uri.getQueryParameters(paramName)
if (values.size != 1 || !queryValuePattern.matches(values[0])) return false
}
return true
}
}
// 2. Fallback Manager: Monotonic Elapsed-Time Chain State (Isolates active chain from repeat sessions)
class FallbackLoopGuard(
private val maxHopsPerChain: Int = 3,
private val chainTtlMs: Long = 30_000L,
private val significantQueryKeys: Set<String> = setOf("id")
) {
private var chainStartElapsedMs: Long = 0L
private var fallbackHopCount: Int = 0
private val visitedInCurrentChain = mutableSetOf<String>()
fun resetChain() {
chainStartElapsedMs = 0L
fallbackHopCount = 0
visitedInCurrentChain.clear()
}
fun canLoadFallback(uri: Uri, currentWebViewUrl: String?): Boolean {
val now = SystemClock.elapsedRealtime()
if (chainStartElapsedMs == 0L || (now - chainStartElapsedMs) > chainTtlMs) {
chainStartElapsedMs = now
fallbackHopCount = 0
visitedInCurrentChain.clear()
}
val loopKey = fallbackLoopKey(uri)
val currentKey = currentWebViewUrl?.let { fallbackLoopKey(Uri.parse(it)) }
if (fallbackHopCount >= maxHopsPerChain ||
loopKey == currentKey ||
loopKey in visitedInCurrentChain
) {
return false
}
visitedInCurrentChain.add(loopKey)
fallbackHopCount++
return true
}
// Application-level loop key normalizing default HTTPS port and preserving significant query keys
private fun fallbackLoopKey(uri: Uri): String {
val scheme = uri.scheme?.lowercase().orEmpty()
val host = uri.host?.lowercase().orEmpty()
val portSuffix = if (uri.port != -1 && uri.port != 443) ":${uri.port}" else ""
val path = uri.path.orEmpty()
val sigParams = uri.queryParameterNames
.filter { it in significantQueryKeys }
.sorted()
.joinToString("&") { key -> "$key=${uri.getQueryParameter(key).orEmpty()}" }
val querySuffix = if (sigParams.isEmpty()) "" else "?$sigParams"
return "$scheme://$host$portSuffix$path$querySuffix"
}
}
// 3. Router & Fail-Closed IntentSanitizer WebViewClient (UI Thread Only)
class SafeRedirectWebViewClient(
val policy: CustomUriPolicy = CustomUriPolicy(),
val loopGuard: FallbackLoopGuard = FallbackLoopGuard(),
private val onPopupFallbackHandoff: ((fallbackUri: Uri) -> Unit)? = null
) : WebViewClient() {
// Explicit host-initiated navigation API that resets fallback chain state prior to loadUrl()
fun loadNewNavigation(webView: WebView, url: String) {
val targetUri = Uri.parse(url)
if (!policy.isAllowedWebUri(targetUri)) {
Log.w("WebViewDebug", "Blocked host-initiated navigation to untrusted URL")
return
}
loopGuard.resetChain()
webView.loadUrl(url)
}
// Dedicated fallback loader with internal validation preserving active chain state
fun loadFallbackNavigation(webView: WebView, fallbackUri: Uri) {
if (!policy.isAllowedFallbackUri(fallbackUri)) {
Log.w("WebViewDebug", "Blocked untrusted fallback navigation attempt")
return
}
webView.loadUrl(fallbackUri.toString())
}
override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
return handleNavigation(
view = view,
uri = request.url,
isForMainFrame = request.isForMainFrame,
hasUserGesture = request.hasGesture(),
isPopupContext = false
)
}
fun handleNavigation(
view: WebView,
uri: Uri?,
isForMainFrame: Boolean,
hasUserGesture: Boolean,
isPopupContext: Boolean
): Boolean {
val targetUri = uri ?: return true
val scheme = targetUri.scheme?.lowercase() ?: return true
// 1. Enforce HTTPS-only & Web Host Allowlist on all HTTP/HTTPS navigations
if (scheme == "http" || scheme == "https") {
if (!policy.isAllowedWebUri(targetUri)) {
Log.w("WebViewDebug", "Blocked non-HTTPS, custom-port, or untrusted web host")
return true
}
if (hasUserGesture && isForMainFrame) {
loopGuard.resetChain()
}
return false
}
// 2. Enforce main-frame and user-gesture constraints on external app launches
if (!isForMainFrame || !hasUserGesture) {
Log.w("WebViewDebug", "Blocked non-main-frame or non-gesture scheme: $scheme")
return true
}
// 3. Parse and fail-closed sanitize Chrome intent:// URIs
if (scheme == "intent") {
return handleIntentUri(view, targetUri.toString(), isPopupContext)
}
// 4. Validate and explicitly bind allowlisted custom URL schemes to 1-to-1 verified target packages
if (policy.isAllowedCustomUri(targetUri)) {
val expectedPackage = policy.customSchemeTargetPackages[scheme] ?: return true
val viewIntent = Intent(Intent.ACTION_VIEW, targetUri).apply {
addCategory(Intent.CATEGORY_BROWSABLE)
`package` = expectedPackage
}
launchIntentSafely(view, viewIntent)
return true
}
// 5. Block all unrecognized schemes
Log.w("WebViewDebug", "Blocked unrecognized URL scheme: $scheme")
return true
}
// UI-Thread Navigation Evaluator for child popup WebViews tying 302 redirects to authorized sessions
fun handlePopupNavigation(
view: WebView,
uri: Uri?,
isForMainFrame: Boolean,
hasUserGesture: Boolean,
isRedirect: Boolean,
isInitialTransportLoad: Boolean,
isAuthorizedPopupSession: Boolean,
onAuthorizedInitialSession: () -> Unit,
canProceedPopupRedirect: () -> Boolean
): Boolean {
val targetUri = uri ?: return true
val scheme = targetUri.scheme?.lowercase() ?: return true
if (scheme == "http" || scheme == "https") {
if (!isForMainFrame) {
Log.w("WebViewDebug", "Blocked subframe HTTPS navigation inside popup")
return true
}
if (!policy.isAllowedPopupUri(targetUri)) {
Log.w("WebViewDebug", "Blocked untrusted popup HTTPS host or path navigation")
return true
}
// Authorize session only on UI thread when initial load or user tap matches allowlist
if (isInitialTransportLoad || hasUserGesture) {
onAuthorizedInitialSession()
return false
}
// Permit bounded server-side 302 redirects ONLY for previously authorized popup sessions
if (isRedirect && isAuthorizedPopupSession && canProceedPopupRedirect()) {
return false
}
Log.w("WebViewDebug", "Blocked unauthorized redirect or non-gesture popup navigation")
return true
}
return handleNavigation(view, targetUri, isForMainFrame, hasUserGesture, isPopupContext = true)
}
private fun handleIntentUri(view: WebView, rawUri: String, isPopupContext: Boolean): Boolean {
val parsedIntent = try {
Intent.parseUri(rawUri, Intent.URI_INTENT_SCHEME)
} catch (e: URISyntaxException) {
Log.w("WebViewDebug", "Malformed intent URI syntax")
return true
}
val fallbackUrl = parsedIntent.getStringExtra("browser_fallback_url")
parsedIntent.removeExtra("browser_fallback_url")
// 1-to-1 Binding: Extract target scheme and validate natively against expected target package
val dataUri = parsedIntent.data ?: return true
val targetScheme = dataUri.scheme?.lowercase() ?: return true
val expectedPackage = policy.customSchemeTargetPackages[targetScheme] ?: run {
Log.w("WebViewDebug", "Blocked intent with unmapped custom scheme: $targetScheme")
return true
}
val rawPackage = parsedIntent.`package`
if (rawPackage != expectedPackage) {
Log.w("WebViewDebug", "Blocked intent package mismatch: expected $expectedPackage")
return true
}
// Reject webpage-specified explicit components and selectors immediately
if (parsedIntent.component != null || parsedIntent.selector != null) {
Log.w("WebViewDebug", "Blocked intent with explicit component or selector")
return true
}
// Clear verified package temporarily before invoking IntentSanitizer with allowAnyComponent()
// to avoid Builder mutual-exclusion constraints while strictly rejecting untrusted flags/extras.
parsedIntent.`package` = null
val sanitizedIntent = try {
IntentSanitizer.Builder()
.allowAnyComponent()
.allowAction(Intent.ACTION_VIEW)
.allowCategory(Intent.CATEGORY_BROWSABLE)
.allowData { uri -> policy.isAllowedCustomUri(uri) }
.build()
.sanitizeByThrowing(parsedIntent)
} catch (e: SecurityException) {
Log.w("WebViewDebug", "IntentSanitizer threw SecurityException for disallowed fields or flags")
return true
} catch (e: IllegalArgumentException) {
Log.w("WebViewDebug", "IntentSanitizer rejected invalid intent arguments")
return true
}
// Re-bind verified target package + host-enforced category + post-sanitization assertions
sanitizedIntent.`package` = expectedPackage
sanitizedIntent.addCategory(Intent.CATEGORY_BROWSABLE)
val sanitizedData = sanitizedIntent.data
if (sanitizedIntent.component != null ||
sanitizedIntent.action != Intent.ACTION_VIEW ||
sanitizedIntent.`package` != expectedPackage ||
sanitizedData == null ||
!policy.isAllowedCustomUri(sanitizedData)
) {
Log.w("WebViewDebug", "Post-sanitization intent assertions failed")
return true
}
try {
launchWithContextSafety(view, sanitizedIntent)
loopGuard.resetChain()
} catch (e: ActivityNotFoundException) {
if (!fallbackUrl.isNullOrBlank()) {
val fallbackUri = Uri.parse(fallbackUrl)
if (policy.isAllowedFallbackUri(fallbackUri) &&
loopGuard.canLoadFallback(fallbackUri, view.url)
) {
if (isPopupContext) {
onPopupFallbackHandoff?.invoke(fallbackUri)
} else {
loadFallbackNavigation(view, fallbackUri)
}
} else {
Log.w("WebViewDebug", "Blocked untrusted or looping fallback URL")
}
}
} catch (e: SecurityException) {
Log.w("WebViewDebug", "SecurityException blocked intent launch")
}
return true
}
private fun launchIntentSafely(view: WebView, intent: Intent) {
try {
launchWithContextSafety(view, intent)
} catch (e: ActivityNotFoundException) {
Log.i("WebViewDebug", "No installed application handles target package/scheme")
} catch (e: SecurityException) {
Log.w("WebViewDebug", "SecurityException blocked custom scheme launch")
}
}
private fun launchWithContextSafety(view: WebView, intent: Intent) {
val safeIntent = Intent(intent)
if (view.context !is Activity) {
safeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
view.context.startActivity(safeIntent)
}
}
// 4. Lifecycle-Managed Popup WebChromeClient (Strict UI-Thread Session State & Stateless Background Guard)
class SafePopupWebChromeClient(
private val safeClient: SafeRedirectWebViewClient
) : WebChromeClient() {
private var activeDialog: Dialog? = null
private var activeChildWebView: WebView? = null
private var isDisposed: Boolean = false
private fun disposeActivePopup() {
if (isDisposed) return
isDisposed = true
val dialog = activeDialog
val child = activeChildWebView
activeDialog = null
activeChildWebView = null
dialog?.setOnDismissListener(null)
dialog?.dismiss()
child?.let {
(it.parent as? ViewGroup)?.removeView(it)
it.stopLoading()
it.webViewClient = WebViewClient()
it.webChromeClient = null
it.destroy()
}
}
override fun onCreateWindow(
view: WebView,
isDialog: Boolean,
isUserGesture: Boolean,
resultMsg: Message?
): Boolean {
if (!isUserGesture) return false
val activity = view.context as? Activity
if (activity == null || activity.isFinishing || activity.isDestroyed) {
return false
}
val transport = resultMsg?.obj as? WebView.WebViewTransport ?: return false
disposeActivePopup()
isDisposed = false
val popupDialog = Dialog(activity)
val popupRoot = android.widget.LinearLayout(activity).apply {
orientation = android.widget.LinearLayout.VERTICAL
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}
val originBanner = TextView(activity).apply {
setPadding(24, 16, 24, 16)
setBackgroundColor(android.graphics.Color.DKGRAY)
setTextColor(android.graphics.Color.WHITE)
textSize = 12f
text = "Loading destination..."
}
popupRoot.addView(originBanner)
// All popup session state variables below are read and mutated strictly on the UI thread
var isInitialTransportLoad = true
var isAuthorizedPopupSession = false
var popupRedirectHops = 0
var popupChainStartMs = SystemClock.elapsedRealtime()
val maxPopupRedirects = 5
val maxPopupRedirectWindowMs = 30_000L
val childWebView = WebView(activity).apply {
layoutParams = android.widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
settings.apply {
javaScriptEnabled = true
allowFileAccess = false
allowContentAccess = false
setSupportMultipleWindows(false)
}
webViewClient = object : WebViewClient() {
// UI Thread: Owns navigation, redirect, and session authorization state
override fun shouldOverrideUrlLoading(
childView: WebView,
request: WebResourceRequest
): Boolean {
val hasGesture = request.hasGesture()
if (hasGesture) {
popupRedirectHops = 0
popupChainStartMs = SystemClock.elapsedRealtime()
}
val result = safeClient.handlePopupNavigation(
view = childView,
uri = request.url,
isForMainFrame = request.isForMainFrame,
hasUserGesture = hasGesture,
isRedirect = request.isRedirect,
isInitialTransportLoad = isInitialTransportLoad,
isAuthorizedPopupSession = isAuthorizedPopupSession,
onAuthorizedInitialSession = {
isAuthorizedPopupSession = true
},
canProceedPopupRedirect = {
val withinWindow = (SystemClock.elapsedRealtime() - popupChainStartMs) <= maxPopupRedirectWindowMs
if (withinWindow && popupRedirectHops < maxPopupRedirects) {
popupRedirectHops++
true
} else {
false
}
}
)
isInitialTransportLoad = false
return result
}
// Background WebView IO Thread: Strictly stateless, read-only policy check.
// Never mutates UI-thread session state; covers initial resource URL only (not subsequent 302 hops).
override fun shouldInterceptRequest(
childView: WebView,
request: WebResourceRequest
): WebResourceResponse? {
if (request.isForMainFrame) {
val targetUri = request.url
val scheme = targetUri?.scheme?.lowercase()
if ((scheme == "http" || scheme == "https") && !safeClient.policy.isAllowedPopupUri(targetUri)) {
Log.w("WebViewDebug", "Blocked unapproved popup main-frame request in shouldInterceptRequest")
childView.post { disposeActivePopup() }
return WebResourceResponse("text/plain", "utf-8", ByteArrayInputStream(ByteArray(0)))
}
}
return super.shouldInterceptRequest(childView, request)
}
// UI Thread: Navigation-start fallback check & origin display (not a pre-navigation filter)
override fun onPageStarted(childView: WebView, url: String?, favicon: android.graphics.Bitmap?) {
super.onPageStarted(childView, url, favicon)
isInitialTransportLoad = false
val uri = url?.let { Uri.parse(it) }
if (uri == null || !safeClient.policy.isAllowedPopupUri(uri)) {
Log.w("WebViewDebug", "Navigation-start fallback check terminated unapproved popup URL")
childView.stopLoading()
disposeActivePopup()
return
}
isAuthorizedPopupSession = true
val scheme = uri.scheme?.lowercase() ?: "https"
val host = uri.host?.lowercase() ?: "Unknown"
originBanner.text = "Origin: $scheme://$host"
}
}
webChromeClient = object : WebChromeClient() {
override fun onCloseWindow(window: WebView?) {
disposeActivePopup()
}
}
}
popupRoot.addView(childWebView)
popupDialog.setContentView(popupRoot)
popupDialog.setOnDismissListener {
disposeActivePopup()
}
activeDialog = popupDialog
activeChildWebView = childWebView
popupDialog.show()
transport.webView = childWebView
resultMsg.sendToTarget()
return true
}
fun destroyPopups() {
disposeActivePopup()
}
}
// 5. Complete Host Activity Registration & Lifecycle Cleanup Example (JavaScript Enabled on Main WebView)
class SafeWebViewActivity : AppCompatActivity() {
private lateinit var webView: WebView
private lateinit var safeClient: SafeRedirectWebViewClient
private lateinit var popupChromeClient: SafePopupWebChromeClient
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0) {
WebView.setWebContentsDebuggingEnabled(true)
}
val policy = CustomUriPolicy()
val loopGuard = FallbackLoopGuard()
safeClient = SafeRedirectWebViewClient(
policy = policy,
loopGuard = loopGuard,
onPopupFallbackHandoff = { fallbackUri ->
popupChromeClient.destroyPopups()
safeClient.loadFallbackNavigation(webView, fallbackUri)
}
)
popupChromeClient = SafePopupWebChromeClient(safeClient)
webView = WebView(this).apply {
settings.apply {
// Enable JavaScript explicitly for trusted landing pages requiring JS redirects or window.open()
javaScriptEnabled = true
allowFileAccess = false
allowContentAccess = false
// Enable multiple windows only if hosting interactive popup containers
setSupportMultipleWindows(true)
}
webViewClient = safeClient
webChromeClient = popupChromeClient
}
setContentView(webView)
// Use explicit host wrapper rather than bare webView.loadUrl()
safeClient.loadNewNavigation(webView, "https://example.com/landing")
}
override fun onDestroy() {
popupChromeClient.destroyPopups()
(webView.parent as? ViewGroup)?.removeView(webView)
webView.destroy()
super.onDestroy()
}
}
अक्सर पूछे जाने वाले प्रश्न (FAQ)
टारगेट ऐप इंस्टॉल होने पर भी Android WebView net::ERR_UNKNOWN_URL_SCHEME क्यों दिखाता है?
जब मेरा ऐप सीधे WebView loadUrl को कॉल करता है तो shouldOverrideUrlLoading क्यों ट्रिगर नहीं हो पाता है?
कस्टम स्कीम वाले टारगेट ब्लैंक लिंक WKWebView के अंदर चुपचाप क्यों विफल हो जाते हैं?
सारांश और निर्णय ढांचा
WebView डीप-लिंकिंग रिडायरेक्शन विफलताओं को हल करने के लिए WebView इंजन व्यवहार को होस्ट एप्लिकेशन नेविगेशन नीतियों से अलग करने की आवश्यकता होती है। Chrome DevTools या Safari Web Inspector में नेविगेशन इवेंट को पुनरुत्पादित करके, स्टेटलेस प्रारंभिक-अनुरोध स्क्रीनिंग के साथ सत्र-अधिकृत 302 रिडायरेक्ट जांच को जोड़ते हुए Android पॉपअप सत्र स्थिति को कड़ाई से UI थ्रेड तक सीमित करके, फ़ेल-क्लोज़्ड IntentSanitizer अनुमति सूचियों को लागू करके, और बासी असमकालिक ओवरराइट और डुप्लिकेट डेलिगेट लॉन्च के खिलाफ iOS यूनिवर्सल लिंक फ़ॉलबैक की सुरक्षा करके, इंजीनियरिंग टीमें टूटी हुई उपयोगकर्ता यात्राओं को कम कर सकती हैं और क्लाइंट-साइड रिडायरेक्शन Vulnerabilities को रोकने में मदद कर सकती हैं।
कंटेनर-स्तरीय नेटिव डेलिगेट और फ़ॉलबैक पथ सत्यापित होने के बाद, इंजीनियरिंग टीमों को ब्राउज़र-से-ऐप संक्रमणों में पैरामीटर संरक्षण की पुष्टि करने के लिए OpoInstall जैसे प्लेटफ़ॉर्म का उपयोग करके एंड-टू-एंड एट्रिब्यूशन लैंडिंग पेजों और वन-क्लिक लॉन्च रूटिंग श्रृंखलाओं को भी सत्यापित करना चाहिए।
एंटिटी शब्दावली
| शब्द | परिभाषा | संबंधित एंटिटी | सर्च इंटेंट भूमिका |
|---|---|---|---|
| WebView | मोबाइल एप्लिकेशन के अंदर वेब पेजों को रेंडर करने के लिए उपयोग किया जाने वाला एक एम्बेडेड नेटिव UI घटक। | WebViewClient / WKWebView |
सूचनात्मक / तकनीकी |
| Custom URL Scheme | नेटिव स्क्रीन में बाहरी नेविगेशन सक्षम करने वाला एक ऐप-पंजीकृत URI उपसर्ग (जैसे, myapp://)। |
Intent.ACTION_VIEW |
तकनीकी / सूचनात्मक |
| WKNavigationDelegate | WebKit प्रोटोकॉल जो होस्ट ऐप को WKWebView में नेविगेशन क्रियाओं को स्वीकार करने, रद्द करने या पुनर्निर्देशित करने की अनुमति देता है। |
decidePolicyForNavigationAction |
तकनीकी |
| WKUIDelegate | WKWebView में नई-विंडो निर्माण अनुरोधों को संभालने के लिए जिम्मेदार WebKit प्रोटोकॉल। |
createWebViewWith |
तकनीकी |
| WebResourceRequest | URL, फ्रेम, HTTP विधि, रिडायरेक्ट और जेस्चर मेटाडेटा को एनकैप्सुलेट करने वाला Android API 24+ ऑब्जेक्ट। | shouldOverrideUrlLoading |
तकनीकी |
| WebChromeClient | JavaScript संवादों, प्रगति और onCreateWindow को संभालने वाला Android WebView कॉलबैक इंटरफ़ेस। |
WebViewTransport |
तकनीकी |
| IntentSanitizer | प्रेषण से पहले अप्रमाणित Intent फ़ील्ड को फ़िल्टर करने या कड़ाई से सत्यापित करने के लिए उपयोग किया जाने वाला AndroidX Core यूटिलिटी। | Intent Redirection Defense | तकनीकी / सुरक्षा |
| Universal Links | स्थापित iOS अनुप्रयोगों के लिए सत्यापित वेब डोमेन को टाई करने वाला Apple का HTTPS-आधारित डीप-लिंकिंग मानक। | Associated Domains | तकनीकी / सूचनात्मक |
| Package Visibility | Android 11+ (targetSdk >= 30) OS फ़िल्टरिंग जो यह प्रतिबंधित करती है कि होस्ट ऐप PackageManager के माध्यम से किन स्थापित ऐप्स को क्वेरी कर सकता है। |
<queries> Manifest Tag |
तकनीकी |
| Intent URI | लक्ष्य पैकेज, स्कीम और ब्राउज़र फ़ॉलबैक URL को एन्कोड करने वाला एक संरचित Android URI (intent://)। |
Intent.URI_INTENT_SCHEME |
तकनीकी |
संगतता आधार रेखा और सत्यापन स्थिति
-
अभीष्ट संगतता लक्ष्य: Android
minSdk 24,compileSdk 34/35,targetSdk 34/35(Android 14/15), Android 16 (API 36) Intent Redirection हार्डनिंग संदर्भ,androidx.core:core:1.9.0+(IntentSanitizer); iOS 15.0–18.0 (iOS 16.4+ परisInspectableगेटेड), Xcode 15/16, Swift 5.9/6.0। -
सत्यापन स्थिति:
-
स्टेटिक API और विनिर्देश समीक्षा: आधिकारिक Android Developers, AndroidX Core, Apple Developer, IETF RFC 3986, और OWASP MASTG विनिर्देशों के विरुद्ध पूर्ण।
-
संकलन और भौतिक डिवाइस सत्यापन: इस समीक्षा चक्र में अभी तक निष्पादित नहीं किया गया है। टीमों को उत्पादन रोलआउट से पहले दुर्भावनापूर्ण प्रारंभिक पॉपअप URL, क्रॉस-डोमेन 302 श्रृंखलाओं, लगातार 302 हॉप्स, तृतीय-पक्ष iframe विंडो निर्माण, Android ऐप लिंक (
assetlinks.json), iOS संबद्ध डोमेन (AASA कैशिंग), बासी असमकालिक यूनिवर्सल लिंक रद्दीकरण,intent://फ़ॉलबैक श्रृंखलाओं, औरActivityNotFoundExceptionप्रेषण को कवर करने वाले भौतिक डिवाइस प्रतिगमन को संकलित और निष्पादित करना चाहिए।
-
संदर्भ
Share this article



