Open mayhammf opened 4 years ago
GetTokenAsync has a static taskcompletionsource as field behind. This is a very dangerous design. When multiple calls to GetTokenAsync happen, some taskcompletionsources may wait forever.
This bug is open for 3 years now. Is anyone taking care of this plugin anymore?
Bug Report
In some cases the task returned by
CrossFirebasePushNotification.Current.GetTokenAsync()
never gets resolved. When that happens no exception is thrown norCrossFirebasePushNotification.Current.OnNotificationError
is invoked. This is caused by the way theGetTokenAsync
method is implementedExpected behavior
await GetTokenAsync()
must always return token or null and should invokeOnNotificationError
in that case.Reproduction steps
around the same time of calling
FirebasePushNotificationManager.Initialize()
. You'll notice theWriteLine
method is never called.Configuration
Version: 3.16
Platform:
Proposed solution
This issue can be resolved by encapsulating the
TaskCompletionSource
(which is used later byOnComplete
) rather than using an unsafe reference which will be replaced every timeGetTokenAsync
is called (even if the previous task has not been resolved yet.)Example below: