Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: (android): pushSubscription listener not resolved #993

Open
2 of 3 tasks
EinfachHans opened this issue May 10, 2024 · 3 comments
Open
2 of 3 tasks

[Bug]: (android): pushSubscription listener not resolved #993

EinfachHans opened this issue May 10, 2024 · 3 comments

Comments

@EinfachHans
Copy link

EinfachHans commented May 10, 2024

What happened?

Hey there,

i have the following logic in my app on startup:

  1. Check if there is a token via await OneSignal.User.pushSubscription.getIdAsync();

If the token is not existent ( i understand why this is possible - read here) i add a listener via OneSignal.User.pushSubscription.addEventListener('change', listener);

This works well on ios, but on android it seems to never resolve when the previous subscription was deleted. In this case the listener never gets resolved. But i can see the new created subscription id on the onesignal dashboard. Even an app restart does not work. I have to delete and reinstall the app. Then a new id is created and the listener resolves.

Steps to reproduce?

Let me know if you need a repro for this and to best set it up.

What did you expect to happen?

Even after the subscription is deleted, the listener should resolve when the new id is existent.

OneSignal Cordova SDK version

5.1.3

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jennantilla
Copy link
Contributor

Hello @EinfachHans thanks for reaching out! Yes, if you could please provide reproduction steps we'll dig into this deeper.

Appreciate it!

@EinfachHans
Copy link
Author

EinfachHans commented May 15, 2024

Hey @jennantilla,

created a repo for this issue: https://github.com/EinfachHans/onesignal-issue

Steps to reproduce:

  1. Check out the repo
  2. In the onesignal.service.ts: Add your correct app id
  3. Run ionic capacitor build android
  4. In Android Studio: Run the app on a device
  5. The app will start and initialize correctly, a subscription is created and visible in the dashboard
  6. Close the app
  7. Delete the subscription in the dashboard
  8. Restart the app
  9. Now there are two possible cases:
  • The Subscription id was kinda cached and the previous and now deleted id is logged. Restart the app in this case...
  • The error occurs: The log [OneSignal]: No token exists, adding listener... will be printed, but the listener will never be resolved and o token is available frontend side. On the other hand there is a new subscription created in the dashboard. On most cases a restart does not solve the problem, only a re-install does.

Let me know if this works for you to reproduce the problem 😊

@TierryBr
Copy link

This problem still occurs, is there any solution? @EinfachHans @jennantilla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants