Skip to content

Commit c59aaf0

Browse files
committed
Update NotificationsBuilder to use NotificationData and improve imports
1 parent f1889f6 commit c59aaf0

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ impl<R: Runtime> NotificationsBuilder<R> {
6262
Self {
6363
app,
6464
plugin,
65-
data: Default::default(),
65+
data: NotificationData::default(),
6666
}
6767
}
6868

6969
#[cfg(mobile)]
7070
fn new(handle: PluginHandle<R>) -> Self {
7171
Self {
7272
handle,
73-
data: Default::default(),
73+
data: NotificationData::default(),
7474
}
7575
}
7676

src/macos.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ use tauri::{
44
AppHandle, Runtime,
55
};
66

7-
use crate::models::*;
7+
use crate::models::{ActionType, ActiveNotification, PendingNotification};
88

99
use std::{collections::HashMap, sync::Arc};
1010

1111
pub use ffi::NotificationPlugin;
1212

1313
/// Validation checks for macOS notifications functionality.
1414
///
15-
/// UserNotifications requires the app to run from a signed .app bundle.
15+
/// `UserNotifications` requires the app to run from a signed .app bundle.
1616
/// During development with `tauri dev`, the binary runs
17-
/// directly without a bundle, causing UserNotifications calls to fail silently or crash.
17+
/// directly without a bundle, causing `UserNotifications` calls to fail silently or crash.
1818
mod validation {
1919
/// Ensures the app is running from a .app bundle.
2020
pub fn require_bundle() -> crate::Result<()> {
@@ -141,6 +141,8 @@ impl ParseFfiVoidResponse for Result<i32, ffi::FFIResult> {
141141
}
142142

143143
/// Called by Swift via FFI when transaction updates occur.
144+
// Owned strings come straight from the Swift bridge.
145+
#[allow(clippy::needless_pass_by_value)]
144146
fn bridge_trigger(event: String, payload: String) -> Result<(), ffi::FFIResult> {
145147
crate::listeners::trigger(&event, payload)
146148
.map_err(|e| ffi::FFIResult::Err(format!("Failed to trigger event '{event}': {e}")))
@@ -165,7 +167,7 @@ impl<R: Runtime> crate::NotificationsBuilder<R> {
165167
self.plugin
166168
.show(
167169
serde_json::to_string(&self.data)
168-
.map_err(|e| crate::error::PluginInvokeError::CannotSerializePayload(e))?,
170+
.map_err(crate::error::PluginInvokeError::CannotSerializePayload)?,
169171
)
170172
.await
171173
.parse_void()
@@ -236,7 +238,7 @@ impl<R: Runtime> Notifications<R> {
236238
self.plugin
237239
.registerActionTypes(
238240
serde_json::to_string(&args)
239-
.map_err(|e| crate::error::PluginInvokeError::CannotSerializePayload(e))?,
241+
.map_err(crate::error::PluginInvokeError::CannotSerializePayload)?,
240242
)
241243
.parse_void()
242244
}
@@ -259,7 +261,7 @@ impl<R: Runtime> Notifications<R> {
259261
self.plugin
260262
.removeActive(
261263
serde_json::to_string(&args)
262-
.map_err(|e| crate::error::PluginInvokeError::CannotSerializePayload(e))?,
264+
.map_err(crate::error::PluginInvokeError::CannotSerializePayload)?,
263265
)
264266
.parse_void()
265267
}
@@ -291,7 +293,7 @@ impl<R: Runtime> Notifications<R> {
291293
self.plugin
292294
.cancel(
293295
serde_json::to_string(&args)
294-
.map_err(|e| crate::error::PluginInvokeError::CannotSerializePayload(e))?,
296+
.map_err(crate::error::PluginInvokeError::CannotSerializePayload)?,
295297
)
296298
.parse_void()
297299
}
@@ -313,7 +315,7 @@ impl<R: Runtime> Notifications<R> {
313315
self.plugin
314316
.setClickListenerActive(
315317
serde_json::to_string(&args)
316-
.map_err(|e| crate::error::PluginInvokeError::CannotSerializePayload(e))?,
318+
.map_err(crate::error::PluginInvokeError::CannotSerializePayload)?,
317319
)
318320
.parse_void()
319321
}

src/mobile.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use tauri::{
44
AppHandle, Runtime,
55
};
66

7-
use crate::models::*;
7+
#[cfg(feature = "push-notifications")]
8+
use crate::models::PushNotificationResponse;
9+
use crate::models::{
10+
ActionType, ActiveNotification, Channel, PendingNotification, PermissionResponse,
11+
};
812

913
use std::collections::HashMap;
1014

@@ -15,6 +19,8 @@ const PLUGIN_IDENTIFIER: &str = "app.tauri.notification";
1519
tauri::ios_plugin_binding!(init_plugin_notification);
1620

1721
// initializes the Kotlin or Swift plugin classes
22+
// `PluginApi` is consumed by the framework's register helpers.
23+
#[allow(clippy::needless_pass_by_value)]
1824
pub fn init<R: Runtime, C: DeserializeOwned>(
1925
_app: &AppHandle<R>,
2026
api: PluginApi<R, C>,
@@ -157,7 +163,7 @@ impl<R: Runtime> Notifications<R> {
157163
.map_err(Into::into)
158164
}
159165

160-
#[allow(unused_variables)]
166+
#[allow(unused_variables, clippy::needless_pass_by_value)]
161167
pub fn create_channel(&self, channel: Channel) -> crate::Result<()> {
162168
#[cfg(target_os = "android")]
163169
return self
@@ -170,7 +176,7 @@ impl<R: Runtime> Notifications<R> {
170176
)));
171177
}
172178

173-
#[allow(unused_variables)]
179+
#[allow(unused_variables, clippy::needless_pass_by_value)]
174180
pub fn delete_channel(&self, id: impl Into<String>) -> crate::Result<()> {
175181
#[cfg(target_os = "android")]
176182
{

0 commit comments

Comments
 (0)