withCredentials works in Android and webapp but not iOS

I have an ionic app that interacts with a webapp’s services that rely on maintaining session… It doesn’t do a token-based authentication, but instead it’s something like this:

Do an initial login using Basic authentication within the headers:
this.httpClient
.get(encodeURI(url), { headers: this.httpHeaders, withCredentials: true })
.subscribe(data =>

Then subsequent calls use withCredentials:true

this.httpClient
.get(encodeURI(url), { withCredentials: true })
.subscribe(data =>

It works fine when the ionic app is run as a webapp, or when run under Android (android 10 & 11). But it doesn’t work on iOS (I’ve tried on an ios 13 and ios14 device)… With iOS, the session is not maintained.

With this webapp, I can also pass the headers parameter (containing the Basic authentication info) with each call, but then the server still loads a new session each time, which also isn’t acceptable. Interestingly, on Android/webapp, the previous session is still maintained when using withCredentials, even if the headers info is passed again.

I’ve tried reading about this issue on other posts, but didn’t fully understand if it was a known issue that will be fixed, or something that has to be “worked around”… If someone could explain/assist, would be appreciated

Below is ionic info snippet of the project
% ionic info

Ionic:

Ionic CLI : 6.12.2 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.2.3
@angular-devkit/build-angular : 0.901.11
@angular-devkit/schematics : 9.1.11
@angular/cli : 9.1.11
@ionic/angular-toolkit : 2.3.3

Capacitor:

Capacitor CLI : 2.2.1
@capacitor/core : 2.2.1

Having the same problem :confused:

1 Like

Does anyone found the solution ? I stack in this too …