뉴스 위젯 연동하기
두 단계를 거치면 웨이커의 위젯을 연동할 수 있습니다
Step 01
위젯 링크 복사하기
Step 02
상호 연동하기
Step 01
위젯 링크 복사하기
화면 종류
연동할 위젯 화면을 선택해 주세요
뉴스 리스트
실시간 최신 뉴스 목록 화면
뉴스 상세
관련 종목 및 태그, AI 요약 등을 포함한 본문 화면
미리보기
Step 02
상호 연동하기
위젯 내에서 특정 액션에 JS 인터페이스를 호출하여 고객사 앱과 연동할 수 있습니다. 위젯에서 참조할 javascript interface 이름은 WaikerInterface 입니다.
상호 연동 항목
1
닫기
웹뷰를 종료합니다
Function Name | Parameters | callbackReturn | 액션 설명 |
---|---|---|---|
close | - | - | 웹뷰를 종료합니다 |
JS인터페이스 연동 예시
1
2 webView.addJavascriptInterface(WebAppInterface(this), "WaikerInterface")
3
4class WebAppInterface(private val context: Context) {
5 @JavascriptInterface
6 fun close() {
7 // Logic to close the in-app webview that called this method
8 }
9 fun newWindow(url: String) {
10 // Logic to open a new in-app webview with the provided URL
11 }
12 // Implement the necessary logic from the list below
13}
14
1
2 webView.configuration.userContentController.add(
3 self,
4 name: "WaikerInterface"
5 )
6
7extension ViewController: WKScriptMessageHandler {
8 func userContentController(
9 _ userContentController: WKScriptMessage,
10 didReceive message: WKScriptMessage
11 ) {
12 if message.name == "WaikerInterface" {
13 if let body = message.body as? [String: Any] {
14 if let method = body["method"] as? String {
15 switch method {
16 case "close":
17 // Logic to close the in-app webview that called this method
18 break
19 case "newWindow":
20 if let url = body["url"] as? String {
21 // Logic to open a new in-app webview with the provided URL
22 }
23 break
24 // Implement the necessary logic from the list below
25 default:
26 break
27 }
28 }
29 }
30 }
31 }
32}