HTTP Get Requests (Wordpress website Rest API calls) not working in iOS App

My Ionic4 App (with angular) is published in both PlayStore (Android) and App Store (iOS). App is expected to show latest articles from https://thesosial.org/ website. App makes http get request to fetch json data (calling the wordpress rest api at url https://thesosial.org/wp-json/wp/v2/posts). Sample code from page ts file:

import { HttpClient} from ‘@angular/common/http’;

this.http.get(url).pipe(map(res => {return res}));

My app is working fine in Android but failing to display content in iOS device.

Apple support team is unable to help as they only look into swift code. For Ionic code, they are suggesting to get help from Ionic community experts. This issue has blocked our release and became a show stopper for us. Request you to help us resolving this issue at the earliest.

In case there is any other channel/option to get faster service from Ionic experts, kindly suggest.

iOS app link is https://apps.apple.com/us/app/the-sosial/id1492790435?ls=1
Android app link is https://play.google.com/store/apps/details?id=com.binacraft.strsosial

Regards,
Nanda Kishore

My guess is it’s likely a CORS issue and WKWebView. Do you have CORS setup on the wordpress api? Here’s a couple of posts that should help if that’s the problem.

The first explains CORS and Ionic by Josh Morony.

The second is enabling CORS on Wordpress. ***Make sure you read up on Access-Control-Allow-Origin and be careful on what you are allowing. Only allow the methods you need ie: GET.
https://www.coditty.com/code/enable-cors-on-wordpress-rest-api

HTH

1 Like

Thank you @caffic for responding. I have looked at the articles shared but it didn’t help. CORS is not an issue here as it is working fine when I run it in the browser and from Android device.

Do you face any console errors while debugging ios?

I would focus attention on the server; I don’t think this is an Ionic issue. Your SSL cert is for www.thesosial.org, not the bare domain.