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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to