This is my first post here, so hello to everybody.
So i've been reading on share extensions for a few hours...and i still cannot make up my mind with regards to the "right way" to implement my intended functionality. The official documentation is lacking a "real world" end to end scenario, and the rest of the information available in forums is scattered.
This is the high level use case i'm trying to solve for.
- User goes to photo library, taps share on a picture.
- User taps on my app share extension.
- My app brings up a window where the user can choose where to store the picture (it actually becomes a file attachment for a contact record).
- Use chooses where to store file.
- A process kicks in, that updates the main app local database (SQLite) and uploads the file to a server-side backend.
What i'm fuzzy here is the very last step in my description above.
For what i can gather, so far:
- The share extension has its own container.
- The only way to share data between share extension and main app is via Apple app groups (using NSUserDefaults and Shared Files).
- The share extension has no way to open or invoke the main app ->This is key.
Is the above correct?
Assuming the above is correct, it seems i would need to implement the whole logic on the share extension itself (vs relying on the main app to be "notified" of a share action, and then have the main app be responsible for dealing with updating the database/uploading file).
So, here is where it gets tricky. The main app actually is the one that owns the local database, and information about a server side backend (url/username/password), etc. So...if the share extension has to solve the entire share problem, somehow i need to be able to get access from the share extension to the main app database and the url/username/password for the backend, so i can implement the entire logic from there.
Am i getting this right? Is that the right way to implement share extension?
If that is the case...then, should the local database live inside the application group shared folder, so that both main app and share extension have access to it? what about backend information? should that live in NSUserDefaults?
Would love if someone can comment.