# Universal login broken on homescreen app in iOS 12.2

**URL:** <https://community.auth0.com/t/universal-login-broken-on-homescreen-app-in-ios-12-2/25787>\
**Category:** Get Help\
**Tags:** jwt, login, auth0\
**Created:** [May 28, 2019, 2:27pm UTC](https://community.auth0.com/t/universal-login-broken-on-homescreen-app-in-ios-12-2/25787 "2019-05-28T14:27:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![loke.sonne](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/loke.sonne/32/13523_2.png) [@loke.sonne](https://community.auth0.com/u/loke.sonne)\
**Post date:** [May 28, 2019, 2:27pm UTC](https://community.auth0.com/t/universal-login-broken-on-homescreen-app-in-ios-12-2/25787/1 "2019-05-28T14:27:31Z")

</div>

Universal login is not working on iOS 12.2 when saving it to homescreen.

I created a web app. In Safari it works perfectly. However, when I save it to the homescreen i get the error "Invalid token ´state´ does not match.

There is no simple way to debug a web app saved to homescreen but, sprinkling lots of alerts in the Auth0 source code I’ve narrowed it down to auth0 is trying to fetch the cookie before it returns from the Universal login back to the site. Here’s what I’ve observed:

## Running in Safari

Open app url (would have put link to app, but apparently that is not allowed for new user 🤯  
Click login  
Generates state and nonce and stores it in cookie (com.auth0.auth.statevalue)  
Redirects to Universal login with state value as a parameter (/login?state=statevalue)  
User logs in  
Redirects to app url with the state value as part of the hash (#accesstoken=someaccesstoken&state=statevalue)  
Gets state value stored in cookie  
Compares state value from cookie with state value from hash  
Logged in!

## Running as homescreen app (webclip)

Click login  
Generates state and nonce and stores it in cookie (com.auth0.auth.statevalue)  
Redirects to Universal login with state value as a parameter (/login?state=statevalue)  
User logs in  
Redirects to app url with the state value as part of the hash (#accesstoken=someaccesstoken&state=statevalue)  
Gets state value stored in cookie → **no cookie present!!**  
Compares state value from cookie with state value from hash  
Error → ´state´ does not match

If I check the cookie afterwards (document.cookie) it is there. It shouldn’t be since the auth0-js should have removed it. Doing the same check when opened in Safari the cookie has been correctly removed.

I suspect when opened as a homescreen app, auth0 tries to get the cookie before it has completely returned to site. It will therefore not find the token. The login fails and the and the cookie is not removed.

For testing, I have commented out the part of the storage handler that forces it to use cookies.

```auto
  this.storage = new CookieStorage();
  if (options.__tryLocalStorageFirst !== true) {
    return;
  }

```

This makes it use localstorage and then everything works.

Here is my test application: [https://test-35763.firebaseapp.com/](https://test-35763.firebaseapp.com/)

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 3, 2019, 9:43am UTC](https://community.auth0.com/t/universal-login-broken-on-homescreen-app-in-ios-12-2/25787/2 "2019-09-03T09:43:27Z")

</div>

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?

---

<div class="post-metadata">

**Author:** ![loke.sonne](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/loke.sonne/32/13523_2.png) [@loke.sonne](https://community.auth0.com/u/loke.sonne)\
**Post date:** [September 3, 2019, 10:24am UTC](https://community.auth0.com/t/universal-login-broken-on-homescreen-app-in-ios-12-2/25787/3 "2019-09-03T10:24:20Z")

</div>

I made a very hacky workaround using a setTimeout. It works but obviously it is not a preferred solution. So yes, I would very much appreciate further assistance.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 19, 2020, 3:49pm UTC](https://community.auth0.com/t/universal-login-broken-on-homescreen-app-in-ios-12-2/25787/5 "2020-03-19T15:49:46Z")

</div>

Hey there!

Terribly sorry for the delay in response again. It’s iOS 13 now and as far as I know regarding the updates from the team responsible for Universal Login it should be fixed by now so I’m closing this topic but feel free to ping me via DM if you still struggle with that so I can reopen that topic.

Once more sorry for the delay!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 19, 2020, 3:49pm UTC](https://community.auth0.com/t/universal-login-broken-on-homescreen-app-in-ios-12-2/25787/6 "2020-03-19T15:49:55Z")

</div>


