iOS 개발/WebKit

    [WKWebview] webkit에서 보낸 message.body 형변환 방법, Could not cast value of type 'NSTaggedPointerString' to 'NSNumber'

    [WKWebview] webkit에서 보낸 message.body 형변환 방법, Could not cast value of type 'NSTaggedPointerString' to 'NSNumber'

    1. 문제 상황 나의 경우에는 value 라는 js 변수의 값을 swift의 네이티브로 넘겨주는 작업을 진행 중이었다. value에는 1 이나 2와 같은 int 형 값이 들어간다. webkit.messageHandlers.updateFollowStatus.postMessage(value); // JavaScript 파일 axios({ method: 'post', url: btnUrl, data: { userId: currentUserID, followValue: value, }, }) .then((res) => { section_display_change(btnId); if (btnUrl === 'follow') { if (isMobile.iOS()) { webkit.messageHandlers.upda..

    [WKWebView] Can't find variable: webkit, undefined is not an object(evaluating 'window.webkit.messageHandlers) error 해결 방법

    [WKWebView] Can't find variable: webkit, undefined is not an object(evaluating 'window.webkit.messageHandlers) error 해결 방법

    1. 문제 상황 하이브리드 앱 프로젝트를 진행하던 도중, WKwebview 에서 보여주는 web js 파일에서 native 앱으로 DB 관련한 파일을 전송해야 하는 작업을 해야 할 일이 생겼다. 정말 iOS에 엄청난 생초보로서 처음 해보는 부분이었지만, stackoverflow와 블로그의 도움을 받아 쓱쓱 해가는 중이고, 나름대로 와 이렇게 체계적으로 잘 만들어져있구나! 끄덕끄덕 하면서 기능을 추가해나갔다. 가장 깔끔하게 정리되어 있는 블로그이니 이 기능 구현 해보고싶은 분들은 따라해봐도 좋을 것 같다ㅎㅎ https://oingbong.tistory.com/225 WKWebview를 이용한 Javascript, Swift 양방향 통신 아래 작성된 방법은 WebView 가 로드될 때 실행되는 것을 기준으로..