首页 > 解决方案 > 使cordova android应用程序在30天后过期

问题描述

我试图在我的科尔多瓦应用程序中设置到期时间,这将强制关闭应用程序或允许我显示带有自定义消息的页面。

标签: androidcordovacordova-plugins

解决方案


在 localStorage 的帮助下。

document.addEventListener('deviceready', function(){
    if (typeof window.localStorage.getItem('someKey') === 'undefined'){
        window.localStorage.setItem('someKey', new Date() );
    }else{
        var current = new Date().getTime();
        if(current > ( window.localStorage.getItem('someKey') + 2592000 ) ){
           ///  Expired
        }
    }
});

推荐阅读