【问题标题】:PouchDB data is not persisted on iOS Cordova app after new install新安装后 PouchDB 数据不会保留在 iOS Cordova 应用程序上
【发布时间】:2018-01-25 08:05:28
【问题描述】:

在我的 Cordova 基础应用程序“硬”关闭后,PouchDB 数据将被删除。

步骤如下:

  1. 安装应用程序
  2. 在 PouchDB 名称测试中保存一些数据
  3. 验证数据是否已保存
  4. 关闭应用程序(在 iOS 上双击 hone 按钮)
  5. 重新打开应用
  6. 验证保存丢失

这只发生在第一次安装时

作为测试,我使用示例代码在表单上创建了两个按钮

$scope.saveme=function(){
       var db =new PouchDB("test");
       var todo = {
         _id: new Date().toISOString(),
         title: "test",
         completed: false
       };
       db.put(todo, function callback(err, result) {
         if (!err) {
            alert('Successfully posted a todo!');
         }
         else{
            alert(err);
         }
      });
    }



$scope.showme = function(){

   var db =new PouchDB("test");
   db.allDocs({include_docs: true, descending: true}, function(err, doc) 
      {
          alert(JSON.stringify(doc));
      });
     }

ios 版本:4.5.4 科尔多瓦:6.5 小袋:6.4.1

请告诉我如何解决这个问题

【问题讨论】:

    标签: ios cordova pouchdb cordova-ios


    【解决方案1】:

    有时候IOS会因为他的内部清理策略而删除localstorage,这个问题也可能出现在Android 6+平台上。

    尝试使用这个插件,在IOS平台的sharedPreferences中持久化localstorage信息。

    Cordova persist localStorage

    Git Repository

    【讨论】:

    • 谢谢...但是我正在使用 Pouch DB 来保存我的数据,并且数据仅在首次安装后才从袋中删除,并且用户双击主页按钮
    • 我也有同样的问题,我把我的登录名改成一个组件,从那以后我就遇到了这个问题,我没有找到解决方案。
    猜你喜欢
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多