davibe / Phonegap-SQLitePlugin

A phonegap plugin to open and use sqlite databases on iOS.
191 stars 90 forks source link

Cordova support #14

Closed coomsie closed 12 years ago

coomsie commented 12 years ago

I think you need to update this in your PGSQLitePlugin.h

#import <Foundation/Foundation.h>
#import "sqlite3.h"

#ifdef CORDOVA_FRAMEWORK
#import <CORDOVA/CDVPlugin.h>
#import <CORDOVA/JSONKit.h>
#import <CORDOVA/CDVFile.h>
#else
#import "CDVPlugin.h"
#import "JSON.h"
#import "File.h"
#endif

#import "AppDelegate.h"

@interface PGSQLitePlugin : CDVPlugin {
    NSMutableDictionary *openDBs;
}

and this in your m file....

-(CDVPlugin*) initWithWebView:(UIWebView*)theWebView
{
    self = (PGSQLitePlugin*)[super initWithWebView:theWebView];
    if (self) {
        openDBs = [NSMutableDictionary dictionaryWithCapacity:0];
        [openDBs retain];

        CDVFile* pgFile = [[self appDelegate] getCommandInstance: @"com.phonegap.file"];
        NSString *docs = [pgFile appDocsPath];
        [self setAppDocsPath:docs];

    }
    return self;
}

plus in your plugin file you will need to replace PhoneGap.execute with Cordova.

===> Though I haven't got it working yet ...

looks like the plugin js file needs a change around for a newer architecture , maybe?

Interesting project by the way ...

davibe commented 12 years ago

Thanks for the infos.

Unfortunately I don't have a lot of time to look into it these days.

It has to be done though .. so .. I will

Davide Bertola

On Mar 18, 2012, at 11:23 AM, coomsie wrote:

I think you need to update this in your PGSQLitePlugin.h

#import <Foundation/Foundation.h>
#import "sqlite3.h"

#ifdef CORDOVA_FRAMEWORK
#import <CORDOVA/CDVPlugin.h>
#import <CORDOVA/JSONKit.h>
#import <CORDOVA/CDVFile.h>
#else
#import "CDVPlugin.h"
#import "JSON.h"
#import "File.h"
#endif

#import "AppDelegate.h"

@interface PGSQLitePlugin : CDVPlugin {
   NSMutableDictionary *openDBs;
}

and this in your m file....

-(CDVPlugin*) initWithWebView:(UIWebView*)theWebView
{
   self = (PGSQLitePlugin*)[super initWithWebView:theWebView];
   if (self) {
       openDBs = [NSMutableDictionary dictionaryWithCapacity:0];
       [openDBs retain];

       CDVFile* pgFile = [[self appDelegate] getCommandInstance: @"com.phonegap.file"];
       NSString *docs = [pgFile appDocsPath];
       [self setAppDocsPath:docs];

   }
   return self;
}

plus in your plugin file you will need to replace PhoneGap.execute with Cordova.

===> Though I haven't got it working yet ...

looks like the plugin js file needs a change around for a newer architecture , maybe?

Interesting project by the way ...


Reply to this email directly or view it on GitHub: https://github.com/davibe/Phonegap-SQLitePlugin/issues/14

ns-1m commented 12 years ago

I got the problem with JSON.h for both PhoneGap 1.3 and Cordova (PhoneGap 1.5)?

Where can I get JSON.h?

Is it the same with JSONKit.h?

I am using Xcode 3.2.6 (iOS 4.3 SDK).

Thanks.

Edited: OK. I got it. We need JSON framework to make this error go away.

http://code.google.com/p/json-framework/downloads/detail?name=JSON_2.2.dmg&can=1&q=

Now, File.h is missing again.

What framework is File.h included?

Not working, mixing Cordova and PhoneGap framework.

ns-1m commented 12 years ago

@coomsie, if you want a PhoneGap 1.3.0 with iPhone, I can share my dropbox

Noli

brodybits commented 12 years ago

I would make another suggestion to rename the plugin from PGSQLitePlugin to SQLitePlugin for slightly better consistency with other PhoneGap/Cordova plugins. I am busy for the next few weeks with an urgent project and will be happy to try working on this issue once the project is delivered.

brodybits commented 12 years ago

In addition, people may be interested in Apahe Cordova CB-330 with an incubator change to make the SQLite database in the WebKit store the data in a permanent location. It is very interesting to see how they are handling the SQLite in the main Cordova library, however I am afraid that if an app or even a device would crash there could be some SQLite user data that is not backed up. What I like about this plugin is that I believe it does provide a more fail-safe solution for apps that are storing important user data.

ns-1m commented 12 years ago

Ian aka Coomsie managed to port this plugin into Cordova_SQLitePlugin.

However, there is problem - "Cannot create a CDVSQLitePlugin instance without a dbPath"

https://github.com/coomsie/Cordova_SQLitePlugin/issues/1

He converted all the javascript that goes with the plugin as far I can see.

coomsie commented 12 years ago

looks like it's sorted .. have a look if you want ...

brodybits commented 12 years ago

Is there any reason the project coomsie/Cordova_SQLitePlugin is/was not registered as a fork of davibe/Phonegap-SQLitePlugin?

coomsie commented 12 years ago

No reason.

Happy to change

Cheers Iain

Sent from my iPhone 4

On 27/03/2012, at 3:39 AM, Chris Brodyreply@reply.github.com wrote:

Is there any reason the project coomsie/Cordova_SQLitePlugin is/was not registered as a fork of davibe/Phonegap-SQLitePlugin?


Reply to this email directly or view it on GitHub: https://github.com/davibe/Phonegap-SQLitePlugin/issues/14#issuecomment-4695380

brodybits commented 12 years ago

Hi Iain,

Only change it if it is easy for you, this is like "starting over" as far as github is concerned. Is it an idea to get rid of the PG/CDV prefix in the class name[s]?

Also, how hard would it be to fix the returned db object to follow the HTML5 Web SQL API? Do you want to do this or is it better to leave it for someone else, such as myself, for the future?

Thanks, Chris

brodybits commented 12 years ago

@coomsie I just tried your version in Cordova and it works great, nice work!

ns-1m commented 12 years ago

@coomsie, Nice job. Thanks. It is working perfectly. Now, we can create not just 1 sqlite3 database but more.

Noli

On 3/27/12, Chris Brody reply@reply.github.com wrote:

@coomsie I just tried your version in Cordova and it works great, nice work!


Reply to this email directly or view it on GitHub: https://github.com/davibe/Phonegap-SQLitePlugin/issues/14#issuecomment-4707010

coomsie commented 12 years ago

mmm.

I did notice that plus some other things as well ...

I would like to change the js style too as i find it hard to work with as it is.

I'll change to fork it and change some naming conventions .... tonight

then i want to try a few tests out for a project im doing ... as I'm using Ti instead of phonegap, but wanted to have the db native and work with html side for leaflet ...

if it looks like performance hasnt suffered i will then push on and try some of those changes u suggested.

Cheers Iain

On Tue, Mar 27, 2012 at 7:48 AM, Chris Brody < reply@reply.github.com

wrote:

Hi Iain,

Only change it if it is easy for you, this is like "starting over" as far as github is concerned. Is it an idea to get rid of the PG/CDV prefix in the class name[s]?

Also, how hard would it be to fix the returned db object to follow the HTML5 Web SQL API? Do you want to do this or is it better to leave it for someone else, such as myself, for the future?

Thanks, Chris


Reply to this email directly or view it on GitHub:

https://github.com/davibe/Phonegap-SQLitePlugin/issues/14#issuecomment-4701233

Cheers Coomsie