台灣最大程式設計社群網站
線上人數
1394
 
會員總數:246221
討論主題:189783
歡迎您免費加入會員
討論區列表 >> iOS APP/ swift 開發 >> Wkwebview embed facebook comments plugin
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
Wkwebview embed facebook comments plugin
價值 : 20 QP  點閱數:228 回應數:0
樓主

林耿立
門外漢
0 1
24 0
發送站內信




大家好,我是IOS初學者,近期遇到一個問題
關於wkwebview作facebook留言外掛程式
點選登入即可留言時,都無反應,登入後也無法留言的情況
在UIwebview時顯示都沒問題,但這個要被destroy了
所以想問各位大大,是否跟cors有關,此題有解嗎??

import UIKit
import WebKit
import FBSDKCoreKit

class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
lazy var testWebView: WKWebView = { [unowned self] in
let wkWebView = WKWebView(frame: self.view.frame)
wkWebView.uiDelegate = self
wkWebView.navigationDelegate = self
wkWebView.configuration.preferences.javaScriptEnabled = true
wkWebView.configuration.preferences.javaScriptCanOpenWindowsAutomatically = true
wkWebView.configuration.suppressesIncrementalRendering = true
return wkWebView
}()

override func viewDidLoad() {
super.viewDidLoad()
setupView()
loadWebUrl()
}
func setupView() {
view.addSubview(testWebView)
}
func loadWebUrl() {
let url = URL(string: "XXXX")
testWebView.load(request)
testWebView.loadHTMLString("<html><head> <meta name='viewport' content='width=device-width, initial-scale=1.0'> </head><body><div id='fb-root'></div><script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = 'https://connect.facebook.net/zh_TW/sdk.js#xfbml=1&version=v8.0&appId=XXXX&autoLogAppEvents=1';fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script><div class='fb-comments' data-href='XXXX' data-numposts='5'></div></body></html>", baseURL: url)

}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Add FBSDK fix
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions);
return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Add FBSDK fix
return ApplicationDelegate.shared.application(app, open: url, options: options)
//return CAPBridge.handleOpenUrl(url, options)
}
func webView(webView: WKWebView, createWebViewWithConfiguration configuration: WKWebViewConfiguration, forNavigationAction navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
// A nil targetFrame means a new window (from Apple's doc)
if (navigationAction.targetFrame == nil) {
// Let's create a new webview on the fly with the provided configuration,
// set us as the UI delegate and return the handle to the parent webview
let popup = WKWebView(frame: self.view.frame, configuration: configuration)
popup.uiDelegate = self
self.view.addSubview(popup)
return popup
}
return nil;
}
func webViewDidClose(webView: WKWebView) {
// Popup window is closed, we remove it
webView.removeFromSuperview()
}



}


搜尋相關Tags的文章: [ swift ] , [ wkwebview ] , [ cors ] , [ facebook ] , [ ] ,
本篇文章發表於2020-11-07 10:38
目前尚無任何回覆
   

回覆
如要回應,請先登入.