API Call does not work in ios Mobile App version



  • We have created Hybrid mobile app to work in browser, as an Android App and iOS app. We have 3rd party APIs called in the App. These work fine browsers and Android app, but throws exception in iOS app. Can anyone please help on what can be the issue or probable solution for this?

    Below is the code. Exception when printed shows empty string {}, so not able to figure out what is the exact issue in iOS.

    /*
    export function someAction (context) {
    }
    */
    import Vue from ‘vue’
    import {Notify, Loading, LoadingBar} from ‘quasar’

    export const doRecipes = ({state, commit, dispatch}) =>{
    Loading.show()
    LoadingBar.start()
    return Vue.prototype.$axios
    .get(API Call here)
    .then(response => {
    console.log(response)
    commit(‘SetRecipes’,response.data)
    Loading.hide()
    LoadingBar.stop()
    return response;
    })
    .catch(e => {
    Loading.hide()
    LoadingBar.stop()
    return e;
    })
    }



  • Follow up comment -
    Experts,
    Please let us know if you have faced similar issue or pointers to debug this issue.



  • @Siddharth
    Can you add log to catch block and post here the full text it shows from console?

    .catch(e => {
      Loading.hide()
      LoadingBar.stop()
    
      console.log(e)
    
      return e;
    })
    


  • Thanks @Ilia for the response.

    We had tried this earlier
    .catch(e => {
    console.log(“blog error”)
    console.log(e)

    and response was as follows:
    2020-12-01 11:02:18.684446+0530 Food Finder[2003:71399] blog error
    2020-12-01 11:02:18.685218+0530 Food Finder[2003:71399] {“config”:{“transformRequest”:{},“transformResponse”:{},“timeout”:0,“xsrfCookieName”:“XSRF-TOKEN”,“xsrfHeaderName”:“X-XSRF-TOKEN”,“maxContentLength”:-1,“headers”:{“Accept”:“application/json, text/plain, /”},“method”:“get”,“url”:“API”},“request”:{}}
    2020-12-01 11:02:18.689187+0530 Food Finder[2003:71399] ERROR: {}

    Error just shows {}

    So kind of stuck and not able to understand how to proceed.



  • OK, in config.xml try this tags: <allow-navigation href=“https://yourdomain.com/*” /> and re-build the app. Also check if the app is allowed to make internet calls at all.

    Also, after that just in case, try to switch to another web-view and see if that makes any difference: https://quasar.dev/quasar-cli/developing-cordova-apps/preparation#Switching-to-iOS-WkWebView

    For now, that’s all I can think of, sorry…





  • Thanks a lot @Ilia @dobbel . I will check with my Team on this.



  • @Siddharth

    wkwebview

    You’ll need it to pass the iOS App review.



  • Thanks a lot @dobbel @Ilia for your responses.
    Just to let you know, we introduced integration platform(Mulesoft) to handle the API calls to 3rd parties from our Application. This way we eliminated the need for wkwebview or the need for 3rd party to make a change to their server settings(to handle external calls). So from our Application point of view, this issue was resolved for ios.



  • @Siddharth

    Great you solved the issue.

    This way we eliminated the need for wkwebview

    If you don’t have wkwebview than you’ll use UIWebView(default). Apple will (automatically) reject any webview based app uploaded to the iTunes store with code(used or not) that contains UIWebView.


Log in to reply