Cordova onPause,onResume事件在iOS中使用相机或扫描仪时未触发

时间:2017-06-20 13:35:36

标签: ios cordova events

我正在尝试让我的应用程序存储并恢复它所在的屏幕,当应用切换到原生相机或其他应用时。它似乎适用于Android,但不会触发iOS。

初始化:function(){

    this.bindEvents();
},

bindEvents: function() {
    console.log("Binding Events");
    document.addEventListener('deviceready', this.onDeviceReady, false);
    document.addEventListener('pause', this.onPause, false);
    document.addEventListener('resume', this.onResume, false);

onPause: function() {
    // Here, we check to see if we are in the middle of taking a picture. If
    // so, we want to save our state so that we can properly retrieve the
    // page url in onResume().
     window.localStorage.setItem(APP_STORAGE_KEY, window.location.href);
     console.log(window.location.href);
},

onResume: function(event) {
    // Here we check for stored state and restore it if necessary.
    setTimeout(function(){
        var storedState = window.localStorage.getItem(APP_STORAGE_KEY);

        if(storedState) {
            console.log(storedState);
            window.location.href=storedState;
        } 
    },0);
},

0 个答案:

没有答案