Closed IrfanKnowledge closed 10 months ago
I just want to share that the current solution is just don't remove that setState(() {}).
Hi
Is there solution for this issue? I am experiencing the same problem.
I added addForegroundWillDisplayListener
and addClickListener
when first init my app.
But listener will continue to be added multiple times every time starting my app.
Is there a good way to ensure that there is only 1 listener?
Hi Is there solution for this issue? I am experiencing the same problem. I added
addForegroundWillDisplayListener
andaddClickListener
when first init my app. But listener will continue to be added multiple times every time starting my app. Is there a good way to ensure that there is only 1 listener?
From the onesignal_flutter example, we can see setState() is used to change the string. But its main purpose is actually not to change the string from the example. Its main purpose is to prevent multiple listeners. I got this conclusion after still using setState() in my code.
@halfmoon-mind it happened when do hot restart. So i put debounce method inside addForegroundWillDisplayListener((){//debounce})
What happened?
OneSignal.Notifications.addForegroundWillDisplayListener can be executed multiple times.
Everytime I enter page with OneSignal.Notifications.addForegroundWillDisplayListener placed inside void initState() {}, it will add the amount of executed everytime notification enter my android phone.
Steps to reproduce?
What did you expect to happen?
OneSignal.Notifications.addForegroundWillDisplayListener((event){}) should executed 1 time only.
OneSignal Flutter SDK version
onesignal_flutter: ^5.1.0
Which platform(s) are affected?
Relevant log output
No response
Code of Conduct