WordPress LMS for Web and mobile Forums Ionic App Support IOS Cannot log-in and doesnt load couses

IOS Cannot log-in and doesnt load couses

Tagged: ,

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #46058

    ben
    Participant
    This reply has been marked as private.
    #46102

    ben
    Participant

    Just something I missed out, I have made previous builds of the app and it has worked fine in Testflight, Issues began when updating my app to the latest version.

    Thanks again!

    #46126

    Harry
    Spectator
    This reply has been marked as private.
    #46133

    ben
    Participant
    This reply has been marked as private.
    #46336

    Scott Lang
    Keymaster

    Please clear your app cache on the device to run your app again it can old configured site data.

    Also, you can run your ios app in XCode and debug the app on safari. The error will be shown in-network and console.

    Checking with your given file.

    #46403

    ben
    Participant

    Thanks Scott! I will give it a try.

    I will post my results for reference to others

    #46443

    ben
    Participant

    Hi Guys,

    Issue in debug is:

    Origin ionic://localhost is not allowed by Access-Control-Origin

    I have tried allowing access control origin in .htaccess and adding code suggested in other posts into the wplms customizer plugin – but with no sucess!:

    function add_cors_http_header(){

    header(“Access-Control-Allow-Origin: *”);

    }

    add_action(‘init’,’add_cors_http_header’);

     

    The app worked in previous old versions of the app, which leads me to believe it’s something in the new app files?

    Any help would be greatly appreciated.

    #46597

    Scott Lang
    Keymaster

    Refer our config.xml:https://we.tl/t-IqU8FGGRcG

    Compare origin error which is not present in your app.

     

    #46876

    ben
    Participant

    Thanks for that Scott! All working now.

    To anyone else trying to find a fix for this:

    It was a mixture of errors, although the app worked in previous builds, since updating the app files it seems to pull requests from the site in different ways. I updated my config.xml with the additional access origin parameters that I missed out, provided by the vibe guys,

    • <access origin=”*://*/*” />
    • <access origin=”file:///*” />
    • <access origin=”cdvfile://*” />

    After which I got more of a response and a different set of errors when inspecting the IOS simulator in safari! So I rechecked my site and removed all of the Access-Control-Allow-Origin ”*” snippets I may have added in .htaccess or wplms-customiser plugin etc.

    In the end I added the following function to my functions.php along with SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 in my .htacess.

    function my_customize_rest_cors() {
    remove_filter( ‘rest_pre_serve_request’, ‘rest_send_cors_headers’ );
    add_filter( ‘rest_pre_serve_request’, function( $value ) {
    header( ‘Access-Control-Allow-Origin: *’ );
    header( ‘Access-Control-Allow-Methods: GET,HEAD,OPTIONS,POST,PUT’ );
    header( ‘Access-Control-Allow-Credentials: true’ );
    header( ‘Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization’ );
    header( ‘Access-Control-Expose-Headers: Link’, false );
    return $value;
    } ); }
    add_action( ‘rest_api_init’, ‘my_customize_rest_cors’, 15 );

     

    And it worked!!! Just a reminder to make sure your using your child theme!

    Thank you Scott & Harry for your help.

    #47355

    Harry
    Spectator
    This reply has been marked as private.
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.