Native app accessing server

Wondering if someone can someone point me in the direction to help me make a native app save data to my server?

With iOS15 not allowing sqlite use in PWAs, am I correct in thinking my app, deployed as a native ios app, will use sqlite? I just need to know how this app will access my server.

Hi,

Not sure why you are saying "IOS15 not allowing sqlite use’?

I have several NSB Apps on IOS using Sqlite and I am running IOS 15.0.1. Just re-built some to check that they were still working.

Regards.

I can’t get my apps working on ios15. From the linked discussion I thought it was all over.

Do you know what you do to allow it to work?

Apologies. I didn’t get the bit about PWA . Mine are, as stated in the part about workarounds, native apps.

Cheers!

I just edited the post for clarification.

You can’t help with the native app accessing my server for storage?

Wish I could :slightly_smiling_face:. I would like to see an example for that too, for a future app.

Accessing data on the server is unrelated to SQLite.

(For clarification, iOS 15 only supports SQLite in native apps, like you’d make with VoltBuilder. Web apps no longer support it)

The usual way to access data on a server is to use Ajax or JavaScript’s fetch().

It’s indirectly related. As sqlite is not supported in iOS I need to develop a native app. Consequently I need to know how to get data to and from my server from a native app. I’m confident with Ajax just not sure how to implement it in a native app.

It works the same way in native apps. You may need to define your content-security-policy to allow your app to access outside data.

Yes, thats the part I’ve no idea about. I was looking over online AS docs, tech examples etc but couldn’t find any documentation explaining what to do exactly. Is there anything you’ve done there I’ve missed?

First, lets stop saying that SQLlite isn’t supported in iOS. It is. It’s not supported in Safari browsers which your PWA requires because it was deprecated years ago in exchange for innodb. Just because Chrome hasn’t removed it yet, doesn’t mean they won’t… it’s scheduled to be fully deprecated in M94 (Sept 2021) and removed in the next version.

See this thread

As for your Content-Security-Policy, I’ve posted several examples on here as have other people. If you search for CSP you should find a bunch of examples. Also note, your server has to be https and you have to return some stuff in a header or your server side scripts will fail.

Here’s Cordova’s documentation on allow-list and CSP.

Is AS going to have functions, like sqllite, in the future for (as PPeTree mentioned) innodb or similar?

I think @PPetree may be referring to IndexedDB, which is fully supported by AppStudio.

SQlite will always work for native apps built with AppStudio. We’re looking at ways to continue using it in the browser.

1 Like

@AppStudioSupport is right, I meant indexedDB.

So is IndexDB the foreseeable future for saving data in a pwa?

The ‘Basic’ IndexDB sample project is actually Javascript.

From my, perhaps misguided, experience trying a new native SQLite app on IOS since I upgraded to IOS15 I have found the following:

  • A new app using the same SQLite code as used in an existing app works to create the database on the first opening after installation, but will not run any further SQL commands in the code. E.g., won’t populate a table with some data using a simple INSERT statement.

  • Opening the new app a second time after installation gives the error : “Error: Web SQL is deprecated”

  • Rebuilds of existing IOS SQLite database apps work - as long as I don’t delete the app first!

Looks like I’ll have to learn IndexDB :slightly_frowning_face:

1 Like

What version of AppStudio was your app built with? Some of the recent updates were to improve use of the SQLite plugin.

SQLite databases created with the web app will not be picked up by the plugin.

I’m using 8.5.5.2

I found the solution. Here’s how:

Created a new project to copy of the sample SQL solution 3. Created a new form in the new project and copied the code from the sample 3.

No dice with running SQL in the browser (or native app, I suspect). Threw an error on Button 1:
"Uncaught ReferenceError: Right is not defined.
line 21 column 13"
and on Button 2:
"SQL error"

So I went and checked every detail of the sample directory files versus my new project.

Found that replacing the line:
"libraries": [],
with
"libraries": [ “BASIC” ],
in the .project file fixed the problem.

Regards.

UPDATE: …which I now realise I could have done by clicking the BASIC library in the files properties. Whoops! Mea culpa :roll_eyes:

@jim - you figured it out. The Right() function isn’t part of JavaScript. Since it’s in Visual BASIC, we added it to the BASIC library.

1 Like