fix(badge): clear badge on iOS cold launch when autoClear is enabled#835
Merged
Conversation
56 tasks
Agent-Logs-Url: https://github.com/capawesome-team/capacitor-plugins/sessions/1097e6be-95ec-403f-bee5-0265cb1f363f Co-authored-by: robingenz <13857929+robingenz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix capacitor-badge autoClear not clearing badge on iOS cold launch
fix(badge): clear badge on iOS cold launch when autoClear is enabled
Apr 15, 2026
Agent-Logs-Url: https://github.com/capawesome-team/capacitor-plugins/sessions/dcd88b90-4815-4546-a93a-1dde008c69ed Co-authored-by: robingenz <13857929+robingenz@users.noreply.github.com>
Contributor
Author
robingenz
approved these changes
Apr 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes iOS badge autoClear not running on a cold launch by triggering the same resume-handling logic during plugin initialization, ensuring badges are cleared on first app start as well as on background→foreground transitions.
Changes:
- Invoke
handleOnResume()fromBadgePlugin.load()immediately after creating theBadgeimplementation (covers cold launch). - Add a Changesets entry to publish a patch release for
@capawesome/capacitor-badge.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/badge/ios/Plugin/BadgePlugin.swift | Calls handleOnResume() during plugin load so autoClear applies on cold launch. |
| .changeset/fix-badge-autoclear-ios-cold-launch.md | Adds a patch changeset documenting the iOS cold-launch auto-clear fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@capawesome/capacitor-age-signals
@capawesome-team/capacitor-android-battery-optimization
@capawesome/capacitor-android-dark-mode-support
@capawesome/capacitor-android-edge-to-edge-support
@capawesome-team/capacitor-android-foreground-service
@capawesome/capacitor-app-review
@capawesome/capacitor-app-shortcuts
@capawesome/capacitor-app-update
@capawesome/capacitor-apple-sign-in
@capawesome/capacitor-asset-manager
@capawesome/capacitor-background-task
@capawesome/capacitor-badge
@capawesome/capacitor-cloudinary
@capawesome-team/capacitor-datetime-picker
@capawesome-team/capacitor-file-opener
@capawesome/capacitor-file-picker
@capawesome/capacitor-google-sign-in
@capawesome/capacitor-libsql
@capawesome/capacitor-live-update
@capawesome/capacitor-managed-configurations
@capawesome/capacitor-photo-editor
@capawesome/capacitor-pixlive
@capawesome/capacitor-posthog
@capawesome/capacitor-realtimekit
@capawesome/capacitor-screen-orientation
@capawesome/capacitor-screenshot
@capawesome/capacitor-square-mobile-payments
@capawesome/capacitor-superwall
@capawesome/capacitor-torch
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
autoClear: true, the badge was not cleared on iOS cold launch — only on subsequent background→foreground transitions. ThewillEnterForegroundNotificationis not fired on initial app launch, so the auto-clear logic was never triggered.Changes
BadgePlugin.swift: CallhandleOnResume()inload()after initializing theBadgeinstance, so auto-clear runs on cold launch in addition to foreground re-entry.handleOnResume()is a no-op whenautoClearisfalse, so default behavior is unaffected.Close #834