[Bug]: (Push-Notification) Registration listener returns old Token if register is called immediatly after unregister
Maintainers usually reply within 9 days
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- android, java, javascript
- Domain
- mobile-dev
Research direction
Start with the linked StackBlitz reproduction and run it on Android, focusing on the addListener → unregister → register sequence. Then trace the Android implementation of @capacitor/push-notifications and its registration event path. Done means each register call after unregister delivers a newly issued token rather than the previous token, with coverage for the alternating behavior.
Written by the indexing model from the issue text.
Description
Capacitor Version
Capacitor Doctor
Latest Dependencies:
@capacitor/cli: 8.5.1
@capacitor/core: 8.5.1
@capacitor/android: 8.5.1
@capacitor/ios: 8.5.1
Installed Dependencies:
@capacitor/core: 8.4.0
@capacitor/android: 8.4.0
@capacitor/cli: 8.4.0
@capacitor/ios: 8.4.0
@capacitor/push-notifications: 8.0.3
[success] Android looking great! 👌
[error] Xcode is not installed
Other API Details
npm --version output: 11.12.1
node --version output: 24.16.0
Platforms Affected
- iOS
- Android
- Web
Current Behavior
If we call register immediatly after having called unregister, we get the already existing token again.
This behaviour can be reproduced every second time this sequence is called.
await PushNotifications.addListener('registration', (token: Token) => {...});
await PushNotifications.unregister();
await PushNotifications.register();
Expected Behavior
We get a new Token everytime we call await PushNotifications.register();
Project Reproduction
Additional Information
The reproduction is only theoretical since a real setup requires a running Android System.
In our App we would like to give the User the option to exchange the existing token with a new one.
- Dominant language
- Java
- Stars
- 683
- Forks
- 692
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ionic-team/capacitor-plugins
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageOpentriage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ionic-team/capacitor-plugins#2604 ·
Maintainers usually reply within 9 days
-
platform: android
Difficulty 3/5 1-2 days Newbie friendliness 78/100
ionic-team/capacitor-plugins#2605 ·
Maintainers usually reply within 9 days
-
bug(camera): chooseFromGallery blocks the main thread on iOS while the photo grid opensPossibly taken @masimplo claimed this 16 days ago. Openplatform: ios
Difficulty 4/5 3-5 days Newbie friendliness 58/100
ionic-team/capacitor-plugins#2603 · 1 comment ·
Maintainers usually reply within 9 days
-
platform: android
Difficulty 3/5 1-2 days Newbie friendliness 76/100
ionic-team/capacitor-plugins#2599 ·
Maintainers usually reply within 9 days
-
platform: ios
Difficulty 3/5 1-2 days Newbie friendliness 68/100
ionic-team/capacitor-plugins#2595 · 2 reactions ·
Maintainers usually reply within 9 days
All issues in ionic-team/capacitor-plugins
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
utopia-rise/godot-jvm#1004 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
spring-projects/spring-grpc#442 ·
-
Expose numberOfPermits in RateLimiterEvent.toString() and the ratelimiterevents actuator DTOPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
resilience4j/resilience4j#2547 ·
Maintainers usually reply within 9 days
-
Clock.MakeDate continues execution and returns a rolled-over instant after dispatching error on invalid datePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
mit-cml/appinventor-sources#4155 ·
Maintainers usually reply within 1 day