No firing event issue with Cordova's In App Browser on IOS

Seeking help to authenticate users on my Ionic application using an external service, and I need to utilize Cordova's InAppBrowser. The code functions correctly on Android, but on iOS, the "loadstop" event never triggers, preventing the browser from redirecting back to the application. My current code is as follows:

$rootScope.$on('$cordovaInAppBrowser:loadstop', function (e, event) {
        console.log('inappbrowser loaded', event);

        var regex = /* regex to determine if url is correct redirected url */
        var res = regex.test(event.url);
        alert('loaded: ' + event.url);
        alert('regex result: ' + res);
        if(res === true) {
          $cordovaInAppBrowser.close();
        }
      });

      if(okta) {
        if (typeof window.localStorage.msRefreshToken === 'undefined') {
          document.addEventListener('deviceready', function () {
            $cordovaInAppBrowser.open('urlforExternalservicehere', '_blank', options);
          }, false);
        } else {
          TokenStore.refreshAccessToken();
        }
      }

No alerts are displayed when running the code. Furthermore, after reaching the external service and entering the user's username, they are redirected to another URL where they must use a different set of credentials for authentication, resulting in a token being returned for app authentication.

In an ideal scenario mirroring Android behavior, the loadstop event should trigger three times on iOS, with the third time closing the in-app browser upon regex validation.

If additional code is needed to address this issue, please let me know!

Cordova Version: 4.2.0
Ionic: 1.4.5
iOS: 8 and 9
NgCordova used for Cordova functionality

UPDATE: While running the app on an emulator and reviewing the console logs, the following error is encountered:

Error: Module cordova-plugin-inappbrowser.inappbrowser does not exist., , Line: 1402

Despite having the plugin installed, it seems to be missing. Any suggestions for resolving this issue would be greatly appreciated. Thank you!

Answer №1

 openLink = window.open('http://ABC.php', '_blank', 'location=no,toolbar=no');
         openLink.addEventListener('loadstart', openLinkLoadStart);
         openLink.addEventListener('loadstop', openLinkLoadStop);
         openLink.removeEventListener('loaderror', openLinkLoadError);
         openLink.addEventListener('exit', openLinkClose);
         openLink.addEventListener('loadstart', function(event) {

          if (event.url.match("mobile/close")) {
              openLink.close();
              window.location = 'home.html';

          }
        }
                               );

Answer №2

The issue I encountered was due to my iOS platform not being the latest version.

When developing apps using Cordova, it is important to ensure that your platform versions and plugins are updated to match the operating system upgrades.

To resolve this issue, I followed these steps:

1. Removed the iOS platform by running the command cordova platform rm ios

2. Added the iOS platform with the latest version using cordova platform add ios

3. Removed the plugin cordova-plugin-inappbrowser with

cordova plugin remove cordova-plugin-inappbrowser

4. Added the plugin cordova-plugin-inappbrowser with the latest version using

cordova plugin add cordova-plugin-inappbrowser

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The directives applied within ng-include are not functioning correctly

Below is a custom directive I have implemented. var fancySelectDirective = pluginDirecitvesModule.directive("custom-select",function(){ return { restrict: 'C', link: function (scope, element, attrs) { ...

Failed AJAX Request - Google Chrome Experiences Issue

I have been working on a website that loads HTML content from a template page and then pulls in data from an XML file. This process is initiated in the document.ready function as shown below: $.ajax({ type : "GET", url : "t ...

Vue's beforeRouteEnter hook patiently awaits for the child component to complete its request

My Vue app utilizes beforeRouteEnter to load data and prevent the undesirable "flash of unloaded content." Loading data on some pages is straightforward: async beforeRouteEnter(to, from, next) { const newestPosts = await getNewestPosts(); next(vm ...

Dynamic web page updates from server using an Ajax request

I have a JavaScript client application and an Express.js server. I am looking to update a page on my server with information sent through an AJAX call from my client application. I need the page to be updated in real-time. Here is the code snippet in my ...

Unlocking the potential of Vue within shadow dom environments

I am facing an issue with a shadow DOM that includes the root element and a Vue component. <template> <div class="container"> <div id="app"></div> </div> <script src="http://my-site.com/app/js/vue-compo ...

You can obtain the values of multiple div selections using jQuery

In a display with two columns, I want to be able to perform a common operation (such as delete) based on the selection of certain div IDs. If a user selects the div IDs participant_1, participant_4, participant_6 at the same time, I need to collect these ...

Connecting a JavaScript script from my HTML file to Django's static files - here's how

I recently started a Django project with frontend code that wasn't initially written for Django. I am having trouble connecting this script: <script> document.body.appendChild(document.createElement('script')). src='js/ma ...

The AJAX call to retrieve data from a file dynamically is experiencing issues

I am currently trying to use AJAX to dynamically retrieve data from my PHP page and display it on my HTML page. However, I am running into some issues with getting it to work properly. You can view the page here Here is the snippet from the HTML Page wher ...

Creating a 404 Error Response in Express.js

Inside app.js, I currently have the following code: // catch 404 and forward to error handler app.use(function(req, res, next) { var err = new Error('Not Found'); err.status = 404; next(err); }); This code executes when a non-existent URL ...

Calculations of string height using CoreText attributes may yield imprecise results

CoreText seems to be giving an incorrect height for the attributed string, often falling short by a line or more. Despite numerous posts on Stack Overflow about this issue, I have yet to find a satisfactory explanation or solution. Can anyone shed some lig ...

Update the bundle identifier for an application that has been tested on TestFlight but has not yet been published on the

I am facing an issue with my app on iTunes Connect and TestFlight. Despite uploading multiple builds, I am unable to transfer the app to a different iTunes account due to the name and bundleID being associated with the older version already on TestFlight. ...

Interactions with Open Graph objects: Likes and Comments

Currently in the process of developing a native iOS app that integrates with Facebook's Open Graph and utilizes single sign on. Progress has been made: Single sign on is operational The app has been granted permissions for: user_about_me, user_likes ...

Exclusive pair of vertices within a network

I am working with a diagram that includes nodes A, B, C and several edges connecting these nodes. How can I extract the distinct pairs (A, B), (A, C), (B, C)? One potential method is: visited = []; for item1 in nodes: for item2 in nodes: if (item ...

When executing class methods, Ember.js encounters errors stating "method does not exist."

I am facing a situation where I need to trigger a model reload when a user clicks a refresh button. In the past, I successfully implemented this with Ember-Model. However, since migrating to Ember-Data, I am encountering an error when attempting to execute ...

Gulp halts when watching code and reloads upon any changes made

Hey there, I'm new to GULP and could use some help... I've been trying to configure GULP for a template that uses AngularJS. When I run the gulp command, the console displays the message "**Done Waching code and reloading on changes" but nothing ...

Concealing a button within a specific interface

I am currently facing an issue with a data table that includes two control buttons: edit and save. My problem lies in hiding the save button on the initial preview. Basically, what I want to achieve is displaying only the Edit button on the first page. Wh ...

Learn how to seamlessly integrate React Hooks Form with the Select component from @Mui for a powerful

I am currently facing an issue while using react-hooks-form to manage forms in conjunction with the @Mui library. The specific problem I'm encountering is figuring out how to integrate the Select component from the @Mui library with react-hooks-form s ...

Suggestions for deleting browser cache programmatically by utilizing JS or HTML

Having trouble clearing the Chrome browser cache using Add-ons. Working on a site development project using JSP with Java, it's crucial for security reasons to clear the cache. Tried multiple methods but none have been successful. Any suggestions? Ple ...

Not adhering to directive scope when transclusion is used, despite explicit instructions to do so

Trying to use a transcluding directive within another controller, but the inner scope isn't being redefined as expected. Despite trying different methods, I can't seem to figure out what's going wrong. The simplified code looks like this: ...

Is there a way to customize the look of the time selected in the <input matInput type="time" step="1" /> time picker?

Currently, I am utilizing the following code as a time picker in my Angular 9 application. My goal is to modify the selected time's color to a bright blue shade. How can I accomplish this task? <input matInput type="time" step="1&quo ...