[ios] SafariServices를 이용한 팝업 차단 설정
iOS Safari에서는 SafariServices 프레임워크를 사용하여 팝업 창을 차단할 수 있습니다.
SafariServices 개요
SafariServices를 사용하면 앱에서 웹 뷰를 열어 Safari와 같은 사용자 경험을 제공할 수 있습니다. 이것은 Safari의 내장된 팝업 차단 기능을 활용할 수 있게 해줍니다.
팝업 창 차단 설정하기
SafariServices를 사용하여 웹 뷰를 열 때, 팝업 차단을 활성화하는 방법은 다음과 같습니다.
import SafariServices
let url = URL(string: "https://example.com")!
let safariViewController = SFSafariViewController(url: url)
safariViewController.configuration.entersReaderIfAvailable = true
present(safariViewController, animated: true, completion: nil)
위의 코드에서 SFSafariViewController
의 entersReaderIfAvailable
속성을 true
로 설정하여 팝업 창을 자동으로 차단할 수 있습니다.
참고 자료
- SafariServices - Apple Developer Documentation
- SFSafariViewController - Apple Developer Documentation
이렇게하면 iOS Safari에서 팝업 창을 손쉽게 차단할 수 있습니다.