| 1 | fn main() -> Result<(), String> { |
| 2 | cfg_if::cfg_if! { |
| 3 | if #[cfg(all(target_os = "macos", not(feature = "preview-macos-un")))] { |
| 4 | use notify_rust::{ |
| 5 | error::MacOsError, get_bundle_identifier_or_default, set_application, Notification, |
| 6 | }; |
| 7 | |
| 8 | let safari_id = get_bundle_identifier_or_default("Safari"); |
| 9 | set_application(&safari_id).map_err(|f| format!("{f}"))?; |
| 10 | |
| 11 | match set_application(&safari_id) { |
| 12 | Ok(_) => {} |
| 13 | Err(MacOsError::Application(error)) => println!("{error}"), |
| 14 | Err(MacOsError::Notification(error)) => println!("{error}"), |
| 15 | } |
| 16 | |
| 17 | Notification::new() |
| 18 | .summary("Safari Crashed") |
| 19 | .body("Just kidding, this is just the notify_rust example.") |
| 20 | .appname("Safari") |
| 21 | .icon("Safari") |
| 22 | .show() |
| 23 | .map_err(|f| format!("{f}"))?; |
| 24 | |
| 25 | } else if #[cfg(all(target_os = "macos", feature = "preview-macos-un"))] { |
| 26 | println!("macos app-id is a feature that no longer applies to the un-usernotifications api") |
| 27 | } else { |
| 28 | println!("this is a mac only feature"); |
| 29 | } |
| 30 | } |
| 31 | Ok(()) |
| 32 | } |