Native notifications support for macOS#55
Conversation
# Conflicts: # examples/notifications-demo/src-tauri/gen/android/build.gradle.kts
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #55 +/- ##
============================================
- Coverage 60.33% 58.22% -2.12%
- Complexity 64 65 +1
============================================
Files 21 29 +8
Lines 2975 5065 +2090
Branches 218 235 +17
============================================
+ Hits 1795 2949 +1154
- Misses 1148 2082 +934
- Partials 32 34 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR implements native notifications for macOS using Swift and the UserNotifications framework. The implementation adds a macOS-specific backend that can be toggled with the notify-rust feature flag, refactors several APIs to async, and improves cross-platform consistency.
Key changes:
- New macOS native implementation using Swift/FFI bridge for UserNotifications framework
- Refactored permission and notification APIs to async across mobile and desktop platforms
- Added listener management system for desktop platforms
- Fixed Android notification storage and click handling issues
Reviewed changes
Copilot reviewed 42 out of 44 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/macos.rs | New macOS implementation with Swift FFI bridge and validation |
| src/listeners.rs | Desktop listener management replicating mobile plugin functionality |
| src/models.rs | Added PermissionResponse/PushNotificationResponse models and Serialize derives |
| src/mobile.rs | Converted APIs to async using run_mobile_plugin_async |
| src/lib.rs | Integrated macOS module with conditional compilation |
| src/commands.rs | Updated commands to call async APIs and added new commands |
| src/desktop.rs | Added stub implementations for new notification APIs |
| src/error.rs | Added desktop equivalents of mobile PluginInvokeError types |
| build.rs | Added Swift compilation and FFI bridge generation for macOS |
| macos/Sources/*.swift | Swift implementation for macOS notifications, handlers, categories |
| macos/Tests/*.swift | Test files (contain wrong plugin references - IAP instead of notifications) |
| macos/Package.swift | Swift package configuration for macOS |
| ios/Sources/*.swift | Minor iOS improvements (Codable conformance, indentation fixes) |
| android/*.kt | Improved logging, notification storage, and click handling |
| guest-js/index.ts | Fixed command names for cancel_all and list_channels |
| Cargo.toml | Added swift-bridge dependency and notify-rust as optional feature |
| permissions/* | Added permissions for new commands (cancel_all, remove_listener) |
| examples/* | Updated demo with better error handling and macOS support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 43 out of 45 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
src/listeners.rs:1
- The documentation incorrectly references 'transaction updates and other IAP events' which appears to be copied from an in-app purchase plugin. This should describe notification events instead.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let notifications: [RemoveActiveNotification] | ||
| } | ||
|
|
||
| extension RustString { |
There was a problem hiding this comment.
The decode extension method lacks documentation. Consider adding a doc comment explaining its purpose and the FFIResult error type.
| extension RustString { | |
| extension RustString { | |
| /// Decodes this `RustString`, interpreted as a UTF-8 JSON string, into the specified `Decodable` type. | |
| /// | |
| /// - Parameter type: The `Decodable` type to decode from the JSON representation. | |
| /// - Throws: An `FFIResult.Err` if the string cannot be converted from UTF-8 data or if JSON decoding fails. |
| for (key in extras.keySet()) { | ||
| // Skip Android/Firebase internal keys | ||
| if (key.startsWith("android.") || key.startsWith("google.") || | ||
| key.startsWith("gcm.") || key == "from" || key == "collapse_key") continue |
There was a problem hiding this comment.
The hardcoded list of internal keys to filter could be extracted to a constant set for better maintainability and reusability.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 44 out of 46 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/models.rs:1
- The
ActionTypestruct has fields with similar naming patterns that should use consistent field ordering. Consider grouping related boolean flags together (e.g., allhidden_previews_*fields) for better code organization and readability.
src/mobile.rs:1 - The method name is
cancel_all(snake_case in Rust) but callscancelAll(camelCase). While this is correct for the mobile plugin interface, consider adding a comment explaining this intentional naming convention difference between Rust and the mobile plugin API.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 48 out of 50 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 51 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.