You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/12/03 14:22:33 UTC

[GitHub] [cordova-plugin-inappbrowser] diesieben07 commented on issue #539: message event fires only once for same inAppBrowser window

diesieben07 commented on issue #539: message event fires only once for same inAppBrowser window
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/539#issuecomment-561189204
 
 
   I am using Ionic, so you'll have to adapt this if you are using plain cordova. I am also just using pseudocode here, but it should be clear:
   ```typescript
   class MyComponent {
     private iabSubscriptions = [];
     private iabObject: InAppBrowserObject|null = null;
   
     private subscribeIab(iab: InAppBrowserObject)
       // unsubscribe from the old IAB object
       for (const s of iabSubscriptions) {
         s.unsubscribe();
       }
       this.iabObject = iab;
       this.iabSubscriptions = [
         // do your subscriptions here
         iab.on('message').subscribe(arg => {
           const newIab = this.inAppBrowser.create(/* new url here */, '_system');
           this.subscribeIab(newIab);
         })
       ]; 
     }
   
     private openIab(url: string) {
       this.subscribeIab(this.inAppBrowser.create(url));
     }
   
     private closeIab() {
       if (this.iabObject) {
         this.iabObject.close();
         this.iabObject = null;
       }
     }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org