Issue
I recently switched HTTP calls from the Cordova plugin to CapacitorHttp, and having sporadic issues with IOS (only).
Using the latest Ionic 7.2.2 and Capacitor 5.2.2. Running against a back-end web service in the cloud using "https".
Everything works fine for Android, and in the Web App -- but iOS is failing every other call. Here is what I see in my logs for iOS:
Successful call to API, but just before call is made:
... [NSURLSession sharedSession] may not be invalidated
Unsuccessful call to API, after it has failed:
... (NSURLErrorDomain error -1000.)","message":"The operation couldn’t be completed"
The above cycle repeats consistently with the pattern as ... works, fails, works, fails, etc...
For the life of me I cannot find anything online that indicates what these errors are and how they pertain to my usage of CapacitorHttp. There must be some specific configuration needed for iOS -- any ideas? Who else has this working and care to share what your code looks like? I am following the tutorial/examples...
Solution
Figured it out, though I'm not sure why it worked 50% of the time without this for iOS, nor why it always worked for Android/web.
The line of code I was missing is simply this:
url = encodeURI(url);
Annoyingly, I had this line for the Cordova plugin I used before Capacitor. Anyway, I hope this helps someone out there who may run into the same issue.
Answered By - Various Artist
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.