Open brodycj opened 5 years ago
In case anyone needs to support the shared database with app groups in a hurry, and does not care about the existing database location support, here is a quick guide:
The code that determines the actual database path is in the following lines: https://github.com/xpbrew/cordova-sqlite-storage/blob/9a93be51d633ad32f7315fc7ed4e8d9658d4bdca/src/ios/SQLitePlugin.m#L111-L117
This code should be replaced by some code that determines the shared database path, as shown in the Stack Overflow question.
Be sure to use the correct shared database path when opening the database in the following lines: https://github.com/xpbrew/cordova-sqlite-storage/blob/9a93be51d633ad32f7315fc7ed4e8d9658d4bdca/src/ios/SQLitePlugin.m#L147-L149
Some of the code in these blocks are using variable names "dbname" and "name" to refer to the full database path. I think this could be a little misleading.
The actual database name between JavaScript and Objective-C remains important since it is used to determine the correct database handle for executing the SQL batches.
The code blocks related to appDBPaths and the getDBPath would not be used if the existing iOS database location options would be replaced by the app group support.
There is interest in supporting this kind of a feature. How to do this in pure Objective-C (no Swift, no JavaScript) can be seen in the description (not an answer) in the following: https://stackoverflow.com/questions/45277097/ios-swift-accessing-shared-db-using-app-groups
I think the hard part would be to add the flexibility between iosDatabaseLocation and using app groups.