How can I sync plugin preferences between apps?

I know that the Preferences class in Omni automation allows for setting and getting plugin preferences, but it seems these settings are per-device and per-app.

Is there a way to store data for use by the plugin such that the data is available on every device? Perhaps saving a file to the iCloud folder for the app, then reading from it?

I’d be grateful for any pointers on doing this with the least amount of friction for the user.

I suppose another option is just that users could set plugin preferences on each app, although this comes with some hurdles in terms of resetting preferences on iOS

You can check @kaitlin website. She had an Omni Automation for synced preferences. I think her plugin created a project inside your OmniFocus database that stored synced preference values.

Thanks for this. I’d thought of a task or project to store data, but Kaitlin’s approach is far more feature-rich. Mirrors the native plugin preferences class too!

I wonder why OF hasn’t included a built-in way to do this (without the need to resort to using actions/projects for alternative purposes).

You can sync settings through your OmniFocus database by using the built-in Settings class:

https://www.omni-automation.com/omnifocus/settings.html

For example, on one device you can use:

settings.setObjectForKey("test-value", "kcase.test-setting");

And then you can read that setting on any device with a synced database:

settings.objectForKey("kcase.test-setting"); // returns "test-value"

(When making up your own settings, I recommend using a prefix as I did above so that they won’t accidentally collide with any current or future built-in settings or settings from other people’s plug-ins.)

1 Like

Great, thank you for this! I wasn’t aware. Is there a method for removing a custom key from the database?

You can set its value to null and you won’t be able to tell the setting is there (from the app interface or the plug-in API), but it does still leave a small empty setting in the database.

It would be useful to have a remove() function on Settings, like we have for Preferences.

1 Like