open apple signin consent url

Seto committed Feb 7, 2026 at 14:45 UTC e17acb64a8f771ccb42232b2d9abbbae32a0312f
2 files changed +118 -36
examples/tauri-app/src/App.svelte
+86 -23
@@ -1,30 +1,36 @@
1 <script>
2 import Greet from "./lib/Greet.svelte";
3 - import { ping, open } from "tauri-plugin-ios-window-api";
3 + import { open } from "tauri-plugin-ios-window-api";
4
5 - let response = $state("");
6 -
7 - function updateResponse(returnValue) {
8 - response +=
9 - `[${new Date().toLocaleTimeString()}] ` +
10 - (typeof returnValue === "string"
11 - ? returnValue
12 - : JSON.stringify(returnValue)) +
13 - "<br>";
14 - }
15 -
16 - function _ping() {
17 - ping("Pong!").then(updateResponse).catch(updateResponse);
18 - }
19 - function _open() {
5 + function openTauriWebsite() {
6 open("https://tauri.app")
7 .then(() => {
22 - console.log("Window opened successfully");
8 + console.log("Tauri website opened successfully");
9 })
10 .catch((error) => {
11 console.error("Failed to open window:", error);
12 });
13 }
14 +
15 + function signInWithApple() {
16 + // Apple ID authentication URL
17 + // In production, you would use proper OAuth flow with your client ID and redirect URI
18 + const appleAuthUrl =
19 + "https://appleid.apple.com/auth/authorize?" +
20 + "response_type=code&" +
21 + "response_mode=form_post&" +
22 + "client_id=YOUR_CLIENT_ID&" +
23 + "redirect_uri=YOUR_REDIRECT_URI&" +
24 + "scope=name%20email";
25 +
26 + open(appleAuthUrl)
27 + .then(() => {
28 + console.log("Sign in with Apple opened successfully");
29 + })
30 + .catch((error) => {
31 + console.error("Failed to open Sign in with Apple:", error);
32 + });
33 + }
34 </script>
35
36 <main class="container">
@@ -48,12 +54,19 @@
54 <Greet />
55 </div>
56
51 - <div>
52 - <button onclick={_ping}>Ping</button>
53 - <div>{@html response}</div>
54 - </div>
55 - <div>
56 - <button onclick={_open}>Open Window</button>
57 + <div class="button-container">
58 + <button onclick={openTauriWebsite} class="btn btn-primary">
59 + Open Tauri Website
60 + </button>
61 +
62 + <button onclick={signInWithApple} class="btn btn-apple">
63 + <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">
64 + <path
65 + d="M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"
66 + />
67 + </svg>
68 + Sign in with Apple
69 + </button>
70 </div>
71 </main>
72
@@ -65,4 +78,54 @@
78 .logo.svelte:hover {
79 filter: drop-shadow(0 0 2em #ff3e00);
80 }
81 +
82 + .button-container {
83 + display: flex;
84 + flex-direction: column;
85 + gap: 1rem;
86 + margin-top: 2rem;
87 + max-width: 300px;
88 + margin-left: auto;
89 + margin-right: auto;
90 + }
91 +
92 + .btn {
93 + padding: 0.75rem 1.5rem;
94 + border: none;
95 + border-radius: 8px;
96 + font-size: 1rem;
97 + font-weight: 600;
98 + cursor: pointer;
99 + transition: all 0.3s ease;
100 + display: flex;
101 + align-items: center;
102 + justify-content: center;
103 + gap: 0.5rem;
104 + }
105 +
106 + .btn-primary {
107 + background: #1a73e8;
108 + color: white;
109 + }
110 +
111 + .btn-primary:hover {
112 + background: #1557b0;
113 + transform: translateY(-2px);
114 + box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
115 + }
116 +
117 + .btn-apple {
118 + background: #000;
119 + color: white;
120 + }
121 +
122 + .btn-apple:hover {
123 + background: #333;
124 + transform: translateY(-2px);
125 + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
126 + }
127 +
128 + .btn:active {
129 + transform: translateY(0);
130 + }
131 </style>
ios/Sources/NewViewController.swift
+32 -13
@@ -6,47 +6,66 @@
6 //
7
8 import UIKit
9 +import WebKit
10
11 final class NewViewController: UIViewController {
12
13 var url: String = ""
14
15 + private var webView: WKWebView!
16 +
17 override func viewDidLoad() {
18 super.viewDidLoad()
19 title = "New Window"
20 view.backgroundColor = .systemBackground
21
22 setupUI()
23 + loadURL()
24 }
25
26 private func setupUI() {
23 - let label = UILabel()
24 - label.text = "URL: \(url)"
25 - label.textAlignment = .center
26 - label.font = .systemFont(ofSize: 20, weight: .medium)
27 - label.numberOfLines = 0
28 - label.translatesAutoresizingMaskIntoConstraints = false
29 - view.addSubview(label)
27 + // Configure WebView
28 + let webConfiguration = WKWebViewConfiguration()
29 + webView = WKWebView(frame: .zero, configuration: webConfiguration)
30 + webView.translatesAutoresizingMaskIntoConstraints = false
31 + webView.allowsBackForwardNavigationGestures = true
32 + view.addSubview(webView)
33
34 + // Close button
35 let closeButton = UIButton(type: .system)
36 closeButton.setTitle("Close", for: .normal)
37 closeButton.titleLabel?.font = .systemFont(ofSize: 17, weight: .semibold)
38 + closeButton.backgroundColor = .systemBackground.withAlphaComponent(0.9)
39 + closeButton.layer.cornerRadius = 8
40 + closeButton.contentEdgeInsets = UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16)
41 closeButton.translatesAutoresizingMaskIntoConstraints = false
42 closeButton.addTarget(self, action: #selector(closeButtonTapped), for: .touchUpInside)
43 view.addSubview(closeButton)
44
45 NSLayoutConstraint.activate([
39 - label.centerXAnchor.constraint(equalTo: view.centerXAnchor),
40 - label.centerYAnchor.constraint(equalTo: view.centerYAnchor),
41 - label.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
42 - label.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
46 + // WebView constraints
47 + webView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
48 + webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
49 + webView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
50 + webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
51
52 + // Close button constraints
53 closeButton.topAnchor.constraint(
45 - equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20),
46 - closeButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
54 + equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 12),
55 + closeButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -12),
56 ])
57 }
58
59 + private func loadURL() {
60 + guard let urlToLoad = URL(string: url) else {
61 + print("Invalid URL: \(url)")
62 + return
63 + }
64 +
65 + let request = URLRequest(url: urlToLoad)
66 + webView.load(request)
67 + }
68 +
69 @objc private func closeButtonTapped() {
70 dismiss(animated: true)
71 }