storesafe/cordova-sqlite-storage

[SURVEY] Change default iOS location to prevent iCloud backup [BREAKING CHANGE]?

brodycj opened this issue · 9 comments

In February 2015 I published a change with a location option that can be used to select the location of the database for iOS. Using location: 2 would store the database in Library/LocalDatabase which will NOT be backed up by iCloud [1: #143]. I did not make this the default option since I wanted to avoid breaking existing app code.

As a consequence, PouchDB had to also add a location option [2: #200] [3: pouchdb/pouchdb#3617].

I would like to change the plugin to store the database in Library/LocalDatabase by default for some reasons including:

  • According to [4] it is not allowed to store a SQLite database in iCloud (as documented in README.md)
  • From [5 - https://github.com//issues/370#issuecomment-185716232] I learned that the the BackupWebStorage setting in config.xml does not apply to the iCloud backup [6 - https://github.com/phonegap/build/issues/338#issuecomment-113328140]
  • Also from [5 - https://github.com//issues/370#issuecomment-185716232] there was confusion about how to prevent iCloud backup when using the plugin from PouchDB
  • [7 - https://github.com//issues/143#issuecomment-77147967] quoted below:

As @dilignt wrote in [7 - https://github.com//issues/143#issuecomment-77147967]:

This fix is wrong - there should be an option to disable backup to iCloud
without using the openDatabase call, and the default should have backup
off, not on. Using this plugin with PouchDB gives me no option to disable
backup without editing 3rd party source code, either PouchDB or the plugin.

I fixed this issue in the previous version by changing NSDocumentDirectory
to NSLibraryDirectory in the source, but this no longer works and I'm back
to square one.

Please disable the backup to iCloud

The downside to this change is that it would potentially break some applications and libraries that depend on this plugin. Existing apps for iOS that do not use the location option would have to explicitly add this option in order to use the database from the old default location.

An additional change I would like to make is to introduce an iosLocation option (perhaps with different values) and deprecate the existing location option.

A note with a link to this survey is going into README.md. I would like to ask the user community to comment as follows:

  • If you do not like this change then please write something like -1, stupid idea. Please feel free to add a reason.
  • If you do like this change please add a +1 comment and feel free to add a reason.
  • If there is anything else you would like to say please feel free to add a comment.
  • If there is anything you would like to say privately please feel free to write to info@litehelpers.net or brodybits@litehelpers.net

I will leave this open for 2-3 weeks and take all input seriously.

references:

  1. #143
  2. #200
  3. pouchdb/pouchdb#3617 - Implement new 'location' option for SQLite Plugin
  4. https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/Chapters/iCloudFundametals.html
  5. #370 (comment)
  6. phonegap/build#338 (comment)
  7. #143 (comment)

+1 makes it easier to get an app up and running and accepted into the Apple app store.

Indeed, way easier for ios! Lets do it!

+1 my app was rejected because of this, so I had to spent one more week waiting for another review to finally release the app

+1 - it certainly should not violate AppStore rules by default. Plugins in cordova do not get upgraded automatically; when authors upgrade plugins, they should always check for backwards compatibility. It's not too difficult to add a piece of code that will move databases from old location for their existing users, and it will have to be done anyway to get app approved.

Thanks for the feedback, I will make this change sometime in March.

Hey there what is the status and / or if it is fixed now, how do I make sure my application is using the proper directory? Thanks

I will still need a couple of weeks or so. Until this is fixed, please use the location: 2 option in openDatabase as documented in README.md. Apps that do not use the location option in openDatabase will be broken by this change.

I have added a new, more explicit iosDatabaseLocation openDatabase/deleteDatabase option and made it mandatory to specify the iOS database location in openDatabase and deleteDatabase.

This will definitely break some app source code but would avoid a more silent upgrade issue.

In case someone needs to overwrite window.openDatabase, it can be done with something like this (edited):

window.openDatabase = function(dbname, ignored1, ignored2, ignored3) {
  return window.sqlitePlugin.openDatabase({name: dbname, iosDatabaseLocation: 'default'});
};

In the case of PouchDB it would be mandatory to use the location parameter. I plan to add an Android location option and will ask the PouchDB team to add the new options once they are all ready.