Swift-4 Siren, Update App dialog disappears immediately

872 views Asked by At

I use Siren library to check app version. It shows a dialog to notify there is an update, but after the webview is loaded dialog disappears so user is not able to click anything. How to prevent this?

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    let gcmMessageIDKey = "gcm.message_id"

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: 
    [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    FirebaseApp.configure()

    Messaging.messaging().delegate = self

    Siren.shared.wail { (results, error) in
        if let results = results {
        print("AlertAction ", results.alertAction)
            print("Localization ", results.localization)
            print("LookupModel ", results.lookupModel)
            print("UpdateType ", results.updateType)
        } else if let error = error {
            print(error.localizedDescription)
        }
    }
}

...

class ViewController: UIViewController , WKUIDelegate , WKScriptMessageHandler, WKNavigationDelegate{

...........

var webView : WKWebView!

override func viewDidLoad() {
    super.viewDidLoad()

    //let url = URL(string: "http://dev.smartiq.io/mars/mobile/index.html#main" )!

    //let url = URL(string: "http://mars.visteknoloji.com/mars/mobile/index.html#main")!

    let url = URL(string: "https://dev.smartiq.io/mars/mobile/index.html#main")!

    //let url = URL(string: "http://192.168.3.22:8080/mars/mobile/index.html#main")!

    webView.scrollView.bounces = false;
    webView.load(URLRequest(url: url))
    webView.navigationDelegate = self

    .....

    let websiteDataTypes = NSSet(array: [WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeMemoryCache])
    let date = Date(timeIntervalSince1970: 0)
    WKWebsiteDataStore.default().removeData(ofTypes: websiteDataTypes as! Set<String>, modifiedSince: date, completionHandler:{ })

    // Do any additional setup after loading the view, typically from a nib.
}

Here I load the wkwebview, when it shows update dialog disappears

override func loadView() {
    let webConfiguration = WKWebViewConfiguration()
    let controller = WKUserContentController()

    controller.add(self ,name : "JSListener")
    webConfiguration.userContentController = controller
    webView = WKWebView(frame: .zero, configuration: webConfiguration)
    navigationController?.navigationBar.isTranslucent = false
    navigationController?.navigationBar.barTintColor = .gray
    webView.uiDelegate = self
    view = webView
}
0

There are 0 answers