Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not to backup to iCloud Options(iOS) #143

Closed
ericyu76 opened this issue Oct 9, 2014 · 25 comments
Closed

Not to backup to iCloud Options(iOS) #143

ericyu76 opened this issue Oct 9, 2014 · 25 comments

Comments

@ericyu76
Copy link

ericyu76 commented Oct 9, 2014

Is there possible to add not to backup to iCloud as an options? I'm facing the Apple reject by this reason. We actually no need to backup to iCloud, is there any workaround?

@dilignt
Copy link

dilignt commented Oct 22, 2014

I am also having big problems with this - could this be prioritised?

@svapreddy
Copy link

For our app also, we do not need to backup data to iCloud and would like to know if it is possible to store in Cordova's NoClould/ folder inside Library folder.

@svapreddy
Copy link

@ericyu76 Could you please share the solution if you have got any?

@dilignt
Copy link

dilignt commented Oct 24, 2014

My solution was simply not to use the plugin and use local storage in the
browser. This works because my app has got less that 5mb of data to store,
but I'll need the plugin back when the volume of data grows to greater than
5mb.

Hope this helps

On 24 October 2014 08:58, Prathap Reddy notifications@github.com wrote:

@ericyu76 https://github.com/ericyu76 Could you please share the
solution if you have got any?


Reply to this email directly or view it on GitHub
#143 (comment)
.

@svapreddy
Copy link

@brodybits If the below code is used to not to backup to iCloud in iOS

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask,  YES);
  NSString *libraryDirectory = [paths objectAtIndex:0];
  libraryDirectory = [libraryDirectory stringByAppendingString:@"/NoCloud"];
  NSError *err = nil;
  [self setAppDocsPath:libraryDirectory];

In place of

 NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
 NSLog(@"Detected docs path: %@", docs);
 [self setAppDocsPath:docs];

Does it still backup to iCloud? NoCloud folder created by Cordova to place files that will not be synced with iCloud.

And any plans to support WP7?

@dilignt But for us, 5MB is very low to use. Because we will be storing lot of text inside that.

Thanks.

@nolanlawson
Copy link
Contributor

This sounds like maybe an option that should be passed in to the openDatabase() function, just for iOS. Something like {icloud: false}. A pull request from anyone familiar with Objective-C/iOS development would be welcome. :)

@ericyu76
Copy link
Author

@svapreddy I removed this SQLite plugin from my code, and my app still review in progress. The limited storage space problem still there.

@ericyu76
Copy link
Author

Here is some information regarding the backup to iCloud optional. Not quite sure this progress.

https://groups.google.com/forum/#!searchin/Cordova-SQLitePlugin/icloud/cordova-sqliteplugin/X9qWxMeHv-8/6k5k0XylMCAJ

@svapreddy
Copy link

@ericyu76 Use the code I have referred in my previous comment. Which does not backup to iCloud. I have tested it and it's working fine for me :)

@nolanlawson Code I have provided in previous comment can be used to for not backing up to iCould at all.

@brodycj
Copy link
Contributor

brodycj commented Oct 30, 2014

@brodycj
Copy link
Contributor

brodycj commented Oct 30, 2014

As commented in #16, it is better to support and use the standard paths defined in the Cordova File API, i.e. cordova.file.dataDirectory or cordova.file.syncedDataDirectory

@tannerlinsley
Copy link

Any word on this? This is really important to a lot of devs that can't get their app approved. I'm using PouchDB on cordova and this plugin is awesome, but needs this options asap.

@dilignt
Copy link

dilignt commented Jan 20, 2015

@tannerlinsley - I managed to get my app approved by changing the NSDocumentDirectory reference to NSLibraryDirectory on line 172 of SQLitePlugin.m. I'm also using PouchDB. I don't know why this isn't the default - it should be an enhancement to provide an option to turn iCloud backup on rather than off IMO

Don't forget to also add <preference name="BackupWebStorage" value="none"/> to your config.xml.

Hope this helps

@brodycj
Copy link
Contributor

brodycj commented Jan 21, 2015

Thanks guys! I am planning to make the solution in the next couple weeks or
so (I will try to make it sooner but cannot make any promises due to some
business distractions).

What I am thinking is to add an optional parameter to specify the documents
path, according to the Cordova File api (but avoiding the dependency,
unless absolutely necessary).

I would also favor the default NOT to be sync'd to iCloud, but with
consideration that this would be a BREAKING CHANGE to existing (iOS) apps
(I did already make a breaking change to the Android version last year).

For now I give the solution as described by @Diligent as the workaround.

@brodybits

On Tuesday, January 20, 2015, Dilignt Ltd notifications@github.com wrote:

@tannerlinsley https://github.com/tannerlinsley - I managed to get my
app approved by changing the NSDocumentDirectory reference to
NSLibraryDirectory on line 172 of SQLitePlugin.m. I don't know why this
isn't the default - it should be an enhancement to turn iCloud backup on
rather than off IMO

Don't forget to also add to your config.xml.

Hope this helps


Reply to this email directly or view it on GitHub
#143 (comment)
.

Sent from my mobile

@brodycj
Copy link
Contributor

brodycj commented Feb 5, 2015

Hi @svapreddy it should be possible to build the WP(8) version to run on WP7 as well (using the CSharp-SQLite classes) but I have not been able to test it. If you (or someone else) could try to run it on WP7 and send a pull request if it works, it may help someone else 😄

@n40jpj
Copy link

n40jpj commented Feb 7, 2015

Ok I have a working solution which I am just about to upload to Apple. This is taking some information from the above link, and from applying a bit of common sense.

Step 1 : Find the file SQLitePlugin.m and go to line 170 ish. Now put the below lines:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = [paths objectAtIndex:0];
libraryDirectory = [libraryDirectory stringByAppendingString:@"/NoCloud"];
NSError *err = nil;
[self setAppDocsPath:libraryDirectory];

In place of :

NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
NSLog(@"Detected docs path: %@", docs);
[self setAppDocsPath:docs];

What this does is to tell the SQLitePlugin where to look for your database. The bit you are still missing is to get dbcopy to copy the .db file from the resources directory into the correct directory on the phone. To do this I did the following:

Step 2: Find and open the plugin file sqlDB.m:

Find the below:

paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];

Replace with :

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = [paths objectAtIndex:0];
libraryDirectory = [libraryDirectory stringByAppendingString:@"/NoCloud"];

That's it your app is back into a working state and now uses the Library/NoCloud directory rather than the Documents directory on the iphone.

I'll let you know if this solves the issues for Apples tests.

brodycj pushed a commit that referenced this issue Feb 17, 2015
…sable iCloud backup (iOS ONLY) ref: #143

Changes to db map code in iOS version

Minor updates to readme
brodycj pushed a commit that referenced this issue Feb 18, 2015
Major changes from common-src:
Implement pre-population ref: #10/#172
Choose DB location to make iCloud backup optional ref: #16/#143
Fix db close conditions & prevent double-marshaling of data ref: pull #170
brodycj pushed a commit that referenced this issue Feb 18, 2015
Major changes from common-src & master-src:
- Implement pre-population ref: #10/#172
- Choose DB location to make iCloud backup optional ref: #16/#143
- Fix db close conditions & prevent double-marshaling of data ref: pull #170
brodycj pushed a commit that referenced this issue Feb 18, 2015
Important changes:
- Implement pre-population ref: #10/#172
- Choose DB location to make iCloud backup optional ref: #16/#143
- Fix db close conditions & prevent double-marshaling of data ref: pull #170
@brodycj
Copy link
Contributor

brodycj commented Feb 18, 2015

I have just pushed a new release to master with this feature. Please see README.md for usage. The plugin creates a new LocalDatabase subdirectory under Library, with the iCloud backup disabled, and uses the new subdirectory only if the location option with value of 2 is used in openDatabase. If you encounter any problems please log a new issue.

@dilignt
Copy link

dilignt commented Mar 4, 2015

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

On 18 February 2015 at 10:48, Chris Brody notifications@github.com wrote:

Closed #143 #143
.


Reply to this email directly or view it on GitHub
#143 (comment)
.

@blablapolicja
Copy link

@brodybits what if I use pre-populated DB? I need to disable iCloud back-up. Will this code work?

db = sqlitePlugin.openDatabase({name: "db.db", createFromLocation: 2});

in Xcode console I get

open full db path: /var/mobile/Containers/Data/Application/FCD72BA1-DF71-420A-95E5-95414ECEFD83/Documents/db.db

Thank you in advance

@brodycj
Copy link
Contributor

brodycj commented Mar 16, 2015

On Mar 16, 2015 9:54 PM, "Stanislav Dzhus" notifications@github.com wrote:

@brodybits what if I use pre-populated DB? I need to disable iCloud
back-up. Will this code work?

db = sqlitePlugin.openDatabase({name: "db.db", createFromLocation: 2});

In your case you have to include both location and createFromLocation
options. Also you gave the wrong value for the createFromLocation option.

To fix your code:

db = sqlitePlugin.openDatabase({name: "db.db", location: 2,

createFromLocation: 1});

I will make this more clear in the readme. Please report if it still does
not work.

Chris

@blablapolicja
Copy link

I used your fix
now my DB copied to /Library/LocalDatabase/
but I get

DB opened: db.db
{"code":5,"message":"no such table: stores"}

@brodycj
Copy link
Contributor

brodycj commented Mar 16, 2015

Make sure your db file does not already exist (in the target directory).

I made an example pre-populated db project (Android version only) at: https://github.com/brodybits/Cordova-pre-populated-db-example-android

@blablapolicja
Copy link

it works! thank you
I deleted my app from device, and then build/run again

@brodycj
Copy link
Contributor

brodycj commented Mar 16, 2015

Thanks happy to hear!

@svapreddy
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants