Skip to content

[Bug]: (Push-Notification) Registration listener returns old Token if register is called immediatly after unregister #2593

Description

@DSInga

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

https://stackblitz.com/edit/angular-4zsdop-napdpb7a?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions