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

@ghenne 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