简体   繁体   中英

$window.open not working on iOS devices

 alertPopup.then (function(res) {
      if(ionic.Platform.isAndroid()) {
        $window.open('android_link_here', '_system')
      }

      else if(ionic.Platform.isIOS()) {
        $window.open('ios_link_here', '_system')
      }

      else {
        $window.open('other_link_here', '_system');
      }

    })

Hey Guys, I am trying to set up a popup that pops up informing the user when a new version of the application is available. What I want this to do is basically go to the page that i have in the string quotations. For iOS, this doesn't work and it fails to open up Safari and load the webpage I want it to. Note: I have not tested on Android yet as of this point.

It might be that I am doing something wrong but I looked around and no one seemed to have this problem.

Since the function is executed on the completion of the alertPopup , you will lose the reference to the $window element.

A possible solution is to keep a locally scoped reference to the $window object. And use that instead of trying to use $window directly.

let windowRef = $window;

alertPopup.then (function(res) {
      if(ionic.Platform.isAndroid()) {
        windowRef.open('android_link_here', '_system')
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM