如何在iOS UIWebView/WKWebView中配置Web Skype插件
Hey there, let's break down why you're seeing that "install plugin" prompt with no action, and how to get Skype calls working in your iOS WebView.
The Core Problem: iOS WebViews Don't Support Browser Plugins
First off, here's the key truth: neither UIWebView nor WKWebView on iOS supports traditional browser plugins (like the Skype desktop plugin). Apple's WebKit framework on iOS intentionally restricts plugin support for security and performance reasons.
Your custom Mac UserAgent is tricking web.skype.com into serving the desktop version of the site, which expects a plugin that simply can't run on iOS. That's why clicking the "install plugin" button does nothing—there's no way to install or run that plugin in an iOS WebView.
Solution 1: Use the Mobile-Friendly Skype Web Version (WebRTC-Based)
The mobile version of web.skype.com uses WebRTC instead of plugins for calls, which is supported in WKWebView. Here's how to configure it properly:
Step 1: Remove the Mac UserAgent
Ditch the custom Mac UserAgent you set—let the site detect it's running on iOS, so it serves the mobile, plugin-free version.
Step 2: Configure WKWebView for Media Access
Calls require camera and microphone access, so you need to set up permissions and WebView settings:
Add Permission Descriptions to Info.plist
Open yourInfo.plistand add these entries to explain why you need camera/microphone access (required by iOS):<key>NSCameraUsageDescription</key> <string>Access to your camera is needed for video calls on Skype</string> <key>NSMicrophoneUsageDescription</key> <string>Access to your microphone is needed for audio calls on Skype</string>Update WKWebView Configuration
Use this adjusted code to set up your WKWebView with proper media settings and handle permission requests:import WebKit class SkypeWebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate { var webView: WKWebView! override func viewDidLoad() { super.viewDidLoad() let webConfig = WKWebViewConfiguration() // Enable inline media playback and picture-in-picture webConfig.allowsInlineMediaPlayback = true webConfig.allowsPictureInPictureMediaPlayback = true // Allow media to play without user interaction (helps with call audio/video) webConfig.mediaTypesRequiringUserActionForPlayback = [] webView = WKWebView(frame: view.bounds, configuration: webConfig) webView.uiDelegate = self webView.navigationDelegate = self webView.isUserInteractionEnabled = true // Load the mobile Skype web app if let skypeUrl = URL(string: "https://web.skype.com/") { let request = URLRequest(url: skypeUrl) webView.load(request) } view.addSubview(webView) } // Handle media permission requests from the web page func webView(_ webView: WKWebView, requestMediaCapturePermissionFor mediaType: WKMediaCaptureType, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) { // You can show a custom alert to confirm with the user here if needed completionHandler(true) } // Optional: Handle any navigation issues or link intercepts func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { // Allow all regular navigation decisionHandler(.allow) } }
Solution 2: Use Skype URL Scheme to Launch the Native App
If you prefer to use the native Skype app for calls (which offers better performance), you can intercept Skype links in your WebView and open them in the native app:
- Add this method to your WKNavigationDelegate
This will handle links likefunc webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { guard let url = navigationAction.request.url else { decisionHandler(.allow) return } // Check if the link is a Skype URL scheme if url.scheme == "skype" { // Open the native Skype app if UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url) } // Cancel the WebView navigation since we're opening the app decisionHandler(.cancel) return } decisionHandler(.allow) }skype:username?callorskype:+1234567890?callby launching the native Skype app directly.
Final Notes
- Avoid UIWebView: Apple has deprecated UIWebView, so stick with WKWebView for all new development—it's faster, more secure, and supports modern web features like WebRTC better.
- Test Permissions: Make sure your app requests camera/microphone permissions properly; users will need to allow them for calls to work.
内容的提问来源于stack exchange,提问作者Akif Demirezen

