StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | # MacOS User Notifcations |
| 2 | |
| 3 | The Apple framework we use to support notifications is `UNUserNotifications`: https://developer.apple.com/documentation/usernotifications?language=objc |
| 4 | |
| 5 | ## Developing notifications locally |
| 6 | The framework needs a signed app to be able to request authorization and schedule notifications to Apple's Notification Center. For this reason, it is not enough to `cargo build && cargo run`. Instead, there are a couple of options: |
| 7 | |
| 8 | ### 1. Bundle the app |
| 9 | This takes a longer time than option 2, but it is more stable, and it is what the user will ultimately experience. |
| 10 | |
| 11 | 1. Run `script/user_notifications --nouniversal --open` |
| 12 | |
| 13 | If you want to test the authorization flow specifically, you will have to: |
| 14 | 1. Delete all the `WarpDev` apps you have installed locally |
| 15 | 2. Ensure that `WarpDev` isn't an app in your Notification Center by checking which apps show up in `Notifications` in your System Preferences. |
| 16 | 3. Log out* |
| 17 | 4. Log back in and bundle&run the app again. |
| 18 | |
| 19 | ### 2. Nosign the local build (script) |
| 20 | This is less stable than option 1 and is not recommended if you're testing the authorization flow. |
| 21 | |
| 22 | 1. Ensure that you have a WarpDev app installed, _and in your Applications folder_. It's important to have the app in your Applications, or Apple won't be able to find the app while testing notifications. |
| 23 | 2. Run `script/local_build_and_sign` |
| 24 | |
| 25 | If you want to test the authorization flow specifically, you will have to: |
| 26 | 1. Delete all the `WarpDev` apps you have installed locally, including the one in your Applications folder. |
| 27 | 2. Ensure that `WarpDev` isn't an app in your Notification Center by checking which apps show up in `Notifications` in your System Preferences. |
| 28 | 3. Log out* and log back in. |
| 29 | 4. Move the `WarpDev` from `Bin` to `Applications` (i.e. install `WarpDev`). |
| 30 | 5. Run the script to nosign and run the app again: `script/local_build_and_sign`. |
| 31 | |
| 32 | *NB: If you already have all the permissions to send notifications, and you're not testing the authorization flow, you should be able to do the following instead of logging out & in: |
| 33 | 1. Delete all `WarpDev` apps. |
| 34 | 2. Run `sudo lsof | grep usernoted | grep db2` to find the path to a database that Notification Center uses. |
| 35 | 3. Run `killall usernoted && killall NotificationCenter` |
| 36 | 4. Run `rm <path-to-notification-center-db>` |
| 37 | 5. Build and run the app again (if you're not bundling, you still have to move `WarpDev` back to your `Applications` folder). |
| 38 | |
| 39 | ## Debugging notifications |
| 40 | Some useful methods for debugging errors / if things aren't working as expected: |
| 41 | - Check Notification Center to figure out if `WarpDev` is a registered app and to play around with the settings (e.g. turning on/off, enabling sound, etc) |
| 42 | - Use `NSLog` to print debug statements in local builds |
| 43 | - Use the Console app for more helpful framework errors - this is particularly helpful when you don't see any error from your own logs. Filter the messages by `NotificationCenter` or `usernoted` or `dev` |
| 44 | - When in doubt, delete all `WarpDev` apps and restart your laptop. Sometimes Notification Center needs a gentle nudge. |
| 45 |