When users click the login button on iOS Safari, the Internet Identity popup window doesn’t open. It works fine on desktop browsers but completely fails on mobile Safari.
You got big problem with iOS Safari, login popup not show. Me think hard, help you fix. Let’s smash this!
Problem: Button click, no popup on iOS Safari. Work good on desktop, but mobile Safari? Nada. No error, just quiet.
Your Code: You share login function. It async, wait for stuff, then call client.login(). Me see you use @dfinity/auth-client, Internet Identity for login. Popup should open, but iOS Safari say “no way.”
Why Problem Happen? Me think iOS Safari picky. Safari on iPhone hate popup if not come straight from user tap. Async stuff (await IdentityManager.forceRefresh() and BackendUtils.getAuthClient()) maybe make delay. Safari think, “This not user tap anymore!” and block popup. Desktop not care, but mobile Safari strict.
Answer Your Questions:
Async blocking popup? Ugh, yes! Safari want popup right when user tap. If you await stuff first, it too slow, Safari say “no popup for you.” Async break the “user action” rule.
Call client.login() synchronous? Me say yes, but careful. If you call client.login() right in click handler, no await, popup might work. But you need client ready before tap. Make client early, then call client.login() in tap.
Pattern for mobile Safari? Me know good way! Safari like simple. Make client when app start, not in click. Then, in click handler, call client.login() quick. No wait, no async in tap. Also, check if popup blocked—tell user tap again or show error.
Fix Ideas:
Move Client Init Outside Click Make client ready when app load, not in login function. Like this:
Me try make fancy complex code with cache and validation before login. You say “No! Safari hate delay! Just call login FAST!” You right! Problem go away like magic! Me feel dumb like caveman try catch fish with rock. You show me use spear instead. BOOM! Fish caught! Thank you wise friend! You save day! Now popup work on iPhone Safari! Me very happy! You best!