1
2

More than 1 year has passed since last update.

【SwiftUI】プライバシーポリシーの設置方法

Posted at

はじめに

AppStoreReviewガイドラインには様々な条件があり、その中にプライバシーポリシーを設置を義務付ける項目があります。
今回はSwiftUIでどのようにプライバシーポリシーを設置すれば良いのかを解説します。

方法1

ContentView.swift
import SwiftUI

struct ContentView: View {
    var body: some View {
        List {
            Link(destination: URL(string: "https://taishin-miyamoto.conohawing.com/PrivacyPolicy/DigitalClock.html")!) {
                Text("プライバシーポリシー")
            }
        }
    }
}

方法2

ContentView.swift
import SwiftUI

struct ContentView: View {
    @State var ShowPrivacyPolicy: Bool = false
    var body: some View {
        List {
            Button("プライバシーポリシー") {
                ShowPrivacyPolicy = true
            }
        }
        .fullScreenCover(isPresented: $ShowPrivacyPolicy) {
            SafariView(url: "https://taishin-miyamoto.conohawing.com/PrivacyPolicy/DigitalClock.html")
                .edgesIgnoringSafeArea(.all)
        }
    }
}
SafariView.swift
import SafariServices

struct SafariView: UIViewControllerRepresentable {
    var url: String
    func makeUIViewController(context: UIViewControllerRepresentableContext<SafariView>) -> SFSafariViewController {
        let safariViewController = SFSafariViewController(url: URL(string: url)!)
        safariViewController.dismissButtonStyle = .close
        return safariViewController
    }
    func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SafariView>) {
    }
}
1
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2