allenu,
@allenu@mastodon.social avatar

Doing a local-only app can be quite restrictive. I've been working on adding a Share Extension to my journaling app. With it, you'd be able to share text, a link, or images to the app to post. However, I only store data in your iCloud Documents folder.

My plan was to use an App Group to share the iCloud folder between the main app and the extension. The extension would load the document and add new content to it itself and let NS/UIDocument handle file coordination.

allenu,
@allenu@mastodon.social avatar

It seems like I can't "register" the document type easily in the Mac share extension, though. At least Xcode's UI doesn't bubble up the ability to add supported file types in the extension's settings. Maybe I could hack it by entering the data directly in the Info.plist? Seems wrong, though.

It looks like what I might have to do is dump the data I want to post to the journal in a shared folder, then on next app launch, read the post and insert it into the doc from the main app.

allenu,
@allenu@mastodon.social avatar

Kind of crappy if you do this from an iOS device and then expect the journal to update the contents on a Mac that's also running the app. It won't show up in the Mac app immediately since the main iOS app would have to launch, read the shared folder, and insert the post into the database... then the Mac would see it via the shared iCloud document.

If this app was not local-only, I could just call some REST API to post the new journal entry to the cloud...

nighthawk,
@nighthawk@aus.social avatar

@allenu I have a similar functionality in my document-based app and faced the same issue. I ended up dumping what's to be shared as a Data blob into the UserDefaults, which the app then picks up and adds to the appropriate document. But indeed you need to open the app on the same device first then. I wonder if dumping it instead into the iCloud KVO store would work cross-device. 🤔

allenu,
@allenu@mastodon.social avatar

@nighthawk Thanks for sharing your experience.

iCloud KVO seems like a slightly better way since the Mac app could pick up the job. There might be some coordination complexity though if processing takes slightly longer and another devices comes online.

I'll probably just dump the contents to a shared folder since I might have multiple file assets that are shared to the app and have the app pick them up on next launch.

nighthawk,
@nighthawk@aus.social avatar

@allenu Yeah, iCloud KVO wouldn't work for bigger assets for sure.

The coordination issue could be addressed by assigning a UUID to the data dump, that way you could make sure the same thing doesn't get added twice. I might give it a try.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • everett
  • tacticalgear
  • magazineikmin
  • thenastyranch
  • rosin
  • tester
  • Youngstown
  • khanakhh
  • slotface
  • ngwrru68w68
  • kavyap
  • mdbf
  • InstantRegret
  • megavids
  • osvaldo12
  • GTA5RPClips
  • ethstaker
  • normalnudes
  • Durango
  • cisconetworking
  • anitta
  • modclub
  • cubers
  • Leos
  • provamag3
  • JUstTest
  • lostlight
  • All magazines