| Crates.io | bevy_ios_notifications |
| lib.rs | bevy_ios_notifications |
| version | 0.4.0 |
| created_at | 2024-04-25 01:56:39.319238+00 |
| updated_at | 2025-04-26 15:58:59.899218+00 |
| description | Bevy plugin to interact with iOS Notifications API |
| homepage | |
| repository | https://github.com/rustunit/bevy_ios_notifications |
| max_upload_size | |
| id | 1219658 |
| size | 73,749 |
Rust crate and Swift package to easily integrate iOS's native Notification API into a Bevy application.
Demo from our game using this crate: zoolitaire.com
Use Apple Push Notification Dashboard to simply send push notifications for testing.
Go to File -> Add Package Dependencies and paste https://github.com/rustunit/bevy_ios_notifications.git into the search bar on the top right:

cargo add bevy_ios_notifications
or
bevy_ios_notifications = { version = "0.4" }
Initialize Bevy Plugin:
// requests permissions for alerts, sounds and badges
app.add_plugins(bevy_ios_notifications::IosNotificationsPlugin::request_permissions_on_start(true, true, true));
Trigger Alert in your application code:
fn system_triggering_notifications(ios_notifications: NonSend<IosNotificationsResource>) {
// should be called after the permission response arrives
ios_notifications.registered_for_push();
// set app icon badge
ios_notifications.set_badge(1);
// schedule a local notification
let id = IosNotificationsResource::schedule(
IosNotificationRequest::new()
.title("title")
.body("body")
.trigger(IosNotificationTrigger::one_shot(4))
// if not defined it will be creating a UUID for you
.identifier("custom id")
.build(),
);
}
// this will clear the badge, the notification center and all pending ones
fn process_occluded_events(
mut e: EventReader<WindowOccluded>,
ios_notifications: NonSend<IosNotificationsResource>,
) {
for ev in e.read() {
if !ev.occluded {
ios_notifications.remove_all_pending();
ios_notifications.remove_all_delivered();
ios_notifications.set_badge(0);
}
}
}
// process async events coming in from ios notification system
fn process_notifications(
mut events: EventReader<IosNotificationEvents>,
) {
for e in events.read() {
match e {
IosNotificationEvents::PermissionResponse(_) => todo!(),
IosNotificationEvents::NotificationSchedulingSucceeded(_) => todo!(),
IosNotificationEvents::NotificationSchedulingFailed(_) => todo!(),
IosNotificationEvents::NotificationTriggered(_) => todo!(),
IosNotificationEvents::PendingNotifications(_) => todo!(),
IosNotificationEvents::NotificationResponse(_) => todo!(),
IosNotificationEvents::RemoteNotificationRegistration(_) => todo!(),
}
}
}
didRegisterForRemoteNotificationsWithDeviceToken callback we use method swizzling to intercept these (see code, see winit PR (dont hold your breath))| bevy | bevy_ios_notifications |
|---|---|
| 0.16 | 0.4,main |
| 0.15 | 0.3 |
| 0.14 | 0.2 |
| 0.13 | 0.1 |
All code in this repository is dual-licensed under either:
at your option. This means you can select the license you prefer.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.