{"id":22840825,"url":"https://github.com/rustunit/bevy_ios_notifications","last_synced_at":"2025-04-28T10:50:19.629Z","repository":{"id":235902255,"uuid":"791492794","full_name":"rustunit/bevy_ios_notifications","owner":"rustunit","description":"Integrates iOS's native Notification API into a Bevy application","archived":false,"fork":false,"pushed_at":"2025-01-13T17:05:12.000Z","size":9392,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-21T07:00:51.352Z","etag":null,"topics":["bevy-engine","ios","notifications","rust","swift"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/bevy_ios_notifications","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustunit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"rustunit"}},"created_at":"2024-04-24T20:20:02.000Z","updated_at":"2025-01-13T17:05:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4f9ccd1-6d1f-470c-a9d9-0bbc2c4d1884","html_url":"https://github.com/rustunit/bevy_ios_notifications","commit_stats":null,"previous_names":["rustunit/bevy_ios_notifications"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustunit%2Fbevy_ios_notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustunit","download_url":"https://codeload.github.com/rustunit/bevy_ios_notifications/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251013574,"owners_count":21522869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bevy-engine","ios","notifications","rust","swift"],"created_at":"2024-12-13T01:13:33.577Z","updated_at":"2025-04-28T10:50:19.620Z","avatar_url":"https://github.com/rustunit.png","language":"Swift","readme":"# bevy_ios_notifications\n\n[![Following released Bevy versions](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/quick-start/plugin-development/#main-branch-tracking)\n[![crates.io](https://img.shields.io/crates/v/bevy_ios_notifications.svg)](https://crates.io/crates/bevy_ios_notifications)\n[![docs.rs](https://docs.rs/bevy_ios_notifications/badge.svg)](https://docs.rs/bevy_ios_notifications)\n[![discord][sh_discord]][lk_discord]\n\n[sh_discord]: https://img.shields.io/discord/1176858176897953872?label=discord\u0026color=5561E6\n[lk_discord]: https://discord.gg/rQNeEnMhus\n\nRust crate and Swift package to easily integrate iOS's native Notification API into a Bevy application.\n\nhttps://github.com/rustunit/bevy_ios_notifications/assets/776816/78e9d708-1cdd-4e54-af2a-c6a5b787f98b\n\nDemo from our game using this crate: [zoolitaire.com](https://zoolitaire.com)\n\n## Features\n\n* change/read badge\n* get remote push deviceToken\n* scheduling local notifications\n* enable/disable presenting notifications while app is foregrounded\n* and the notoriously hard (in unity) to do things like: what notification was clicked\n\n## Instructions\n\n1. Add to XCode: Add SPM (Swift Package Manager) dependency\n2. Add Rust dependency\n3. Setup Plugin\n\nUse [Apple Push Notification Dashboard](https://icloud.developer.apple.com/dashboard/notifications) to simply send push notifications for testing.\n\n### 1. Add to XCode\n\nGo to `File` -\u003e `Add Package Dependencies` and paste `https://github.com/rustunit/bevy_ios_notifications.git` into the search bar on the top right:\n![xcode](./assets/xcode-spm.png)\n\n### 2. Add Rust dependency\n\n```\ncargo add bevy_ios_notifications\n```\n\nor\n\n```\nbevy_ios_notifications = { version = \"0.4\" }\n```\n\n### 3. Setup Plugin\n\nInitialize Bevy Plugin:\n\n```rust\n// requests permissions for alerts, sounds and badges\napp.add_plugins(bevy_ios_notifications::IosNotificationsPlugin::request_permissions_on_start(true, true, true));\n```\n\nTrigger Alert in your application code:\n\n```rust\nfn system_triggering_notifications(ios_notifications: NonSend\u003cIosNotificationsResource\u003e) {\n\n    // should be called after the permission response arrives\n    ios_notifications.registered_for_push();\n\n    // set app icon badge\n    ios_notifications.set_badge(1);\n\n    // schedule a local notification\n    let id = IosNotificationsResource::schedule(\n        IosNotificationRequest::new()\n            .title(\"title\")\n            .body(\"body\")\n            .trigger(IosNotificationTrigger::one_shot(4))\n            // if not defined it will be creating a UUID for you\n            .identifier(\"custom id\")\n            .build(),\n    );\n\n}\n\n// this will clear the badge, the notification center and all pending ones\nfn process_occluded_events(\n    mut e: EventReader\u003cWindowOccluded\u003e,\n    ios_notifications: NonSend\u003cIosNotificationsResource\u003e,\n) {\n    for ev in e.read() {\n        if !ev.occluded {\n            ios_notifications.remove_all_pending();\n            ios_notifications.remove_all_delivered();\n            ios_notifications.set_badge(0);\n        }\n    }\n}\n\n// process async events coming in from ios notification system\nfn process_notifications(\n    mut events: EventReader\u003cIosNotificationEvents\u003e,\n) {\n    for e in events.read() {\n        match e {\n            IosNotificationEvents::PermissionResponse(_) =\u003e todo!(),\n            IosNotificationEvents::NotificationSchedulingSucceeded(_) =\u003e todo!(),\n            IosNotificationEvents::NotificationSchedulingFailed(_) =\u003e todo!(),\n            IosNotificationEvents::NotificationTriggered(_) =\u003e todo!(),\n            IosNotificationEvents::PendingNotifications(_) =\u003e todo!(),\n            IosNotificationEvents::NotificationResponse(_) =\u003e todo!(),\n            IosNotificationEvents::RemoteNotificationRegistration(_) =\u003e todo!(),\n        }\n    }\n}\n\n```\n\n## Implementation Details\n\n* due to the more complex nature of the types that need to be send in and out this crates uses protobuf for that ([see schema](./rust/bevy_ios_notifications/src/Data.proto))\n* because [winit](https://github.com/rust-windowing/winit) currently does not let you hook into the AppDelegates's `didRegisterForRemoteNotificationsWithDeviceToken` callback we use method swizzling to intercept these ([see code](https://github.com/rustunit/bevy_ios_notifications/blob/49e33b5a389f83ecd48eb6b851145ed57790eb23/Sources/bevy_ios_notifications/bevy_ios_notifications.swift#L177), [see winit PR (dont hold your breath)](https://github.com/rust-windowing/winit/pull/3650))\n\n## Our Other Crates\n\n- [bevy_debug_log](https://github.com/rustunit/bevy_debug_log)\n- [bevy_device_lang](https://github.com/rustunit/bevy_device_lang)\n- [bevy_web_popups](https://github.com/rustunit/bevy_web_popups)\n- [bevy_libgdx_atlas](https://github.com/rustunit/bevy_libgdx_atlas)\n- [bevy_ios_review](https://github.com/rustunit/bevy_ios_review)\n- [bevy_ios_gamecenter](https://github.com/rustunit/bevy_ios_gamecenter)\n- [bevy_ios_alerts](https://github.com/rustunit/bevy_ios_alerts)\n- [bevy_ios_iap](https://github.com/rustunit/bevy_ios_iap)\n- [bevy_ios_impact](https://github.com/rustunit/bevy_ios_impact)\n- [bevy_ios_safearea](https://github.com/rustunit/bevy_ios_safearea)\n\n## Bevy version support\n\n|bevy|bevy\\_ios\\_notifications|\n|----|---|\n|0.16|0.4,main|\n|0.15|0.3|\n|0.14|0.2|\n|0.13|0.1|\n\n# License\n\nAll code in this repository is dual-licensed under either:\n\n- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)\n- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)\n\nat your option. This means you can select the license you prefer.\n\n## Your contributions\nUnless 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.\n","funding_links":["https://github.com/sponsors/rustunit"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustunit%2Fbevy_ios_notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustunit%2Fbevy_ios_notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustunit%2Fbevy_ios_notifications/lists"}