Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-ui-renderer/src/platform/mac/objc/notifications/README.md
1# MacOS User Notifcations
2 
3The Apple framework we use to support notifications is `UNUserNotifications`: https://developer.apple.com/documentation/usernotifications?language=objc
4 
5## Developing notifications locally
6The 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
9This takes a longer time than option 2, but it is more stable, and it is what the user will ultimately experience.
10 
111. Run `script/user_notifications --nouniversal --open`
12 
13If you want to test the authorization flow specifically, you will have to:
141. Delete all the `WarpDev` apps you have installed locally
152. Ensure that `WarpDev` isn't an app in your Notification Center by checking which apps show up in `Notifications` in your System Preferences.
163. Log out*
174. Log back in and bundle&run the app again.
18 
19### 2. Nosign the local build (script)
20This is less stable than option 1 and is not recommended if you're testing the authorization flow.
21 
221. 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.
232. Run `script/local_build_and_sign`
24 
25If you want to test the authorization flow specifically, you will have to:
261. Delete all the `WarpDev` apps you have installed locally, including the one in your Applications folder.
272. Ensure that `WarpDev` isn't an app in your Notification Center by checking which apps show up in `Notifications` in your System Preferences.
283. Log out* and log back in.
294. Move the `WarpDev` from `Bin` to `Applications` (i.e. install `WarpDev`).
305. 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:
331. Delete all `WarpDev` apps.
342. Run `sudo lsof | grep usernoted | grep db2` to find the path to a database that Notification Center uses.
353. Run `killall usernoted && killall NotificationCenter`
364. Run `rm <path-to-notification-center-db>`
375. 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
40Some 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