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

Fixed issue when updated push token was not sent to backend. Reverted… #541

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Softeq.XToolkit.PushNotifications.Droid.Services
/// interfaces for Android platform. Handles all interactions with the platform, related to push notifications.
/// </summary>
public sealed class DroidPushNotificationsService :
IPushNotificationsService, IActivityLauncherDelegate, IDroidFirebaseMessagingHandler, IDisposable
IPushNotificationsService, IActivityLauncherDelegate, IDroidFirebaseMessagingHandler
{
private readonly IDroidPushNotificationsConsumer _pushNotificationsConsumer;
private readonly ILogger _logger;
Expand All @@ -40,11 +40,6 @@ public DroidPushNotificationsService(
_logger = logManager.GetLogger<DroidPushNotificationsService>();
}

~DroidPushNotificationsService()
{
Dispose(false);
}

private bool IsRegistered { get; set; }

/// <inheritdoc />
Expand Down Expand Up @@ -119,20 +114,6 @@ public bool TryHandleLaunchIntent(Intent? intent)
return intent != null && _pushNotificationsConsumer.TryHandlePushNotificationIntent(intent);
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

private void Dispose(bool isDisposing)
{
if (isDisposing)
{
_registrationSemaphore.Dispose();
}
}

/// <inheritdoc />
void IDroidFirebaseMessagingHandler.OnNotificationReceived(RemoteMessage message)
{
Expand Down
17 changes: 8 additions & 9 deletions Softeq.XToolkit.PushNotifications/PushTokenSynchronizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ await UnregisterFromRemotePushNotificationsAsync()
private async Task OnRegisterSuccessInternalAsync(string token)
{
IsTokenRegisteredInSystem = true;
IsTokenSavedOnServer = false;
dimysa marked this conversation as resolved.
Show resolved Hide resolved
_pushTokenStorageService.PushToken = token;

if (!IsTokenSavedOnServer)
{
_pushTokenStorageService.PushToken = token;

await DoSendTokenToServer(token)
.ConfigureAwait(false);
}
await DoSendTokenToServer(token)
.ConfigureAwait(false);

_pushNotificationsHandler.OnPushRegistrationCompleted(
true,
Expand All @@ -156,8 +153,10 @@ private async Task DoSendTokenToServer(string token)
{
do
{
if (IsTokenSavedOnServer = await _remotePushNotificationsService
.SendPushNotificationsToken(token, cancellationToken).ConfigureAwait(false))
IsTokenSavedOnServer = await _remotePushNotificationsService
.SendPushNotificationsToken(token, cancellationToken)
.ConfigureAwait(false);
if (IsTokenSavedOnServer)
{
break;
}
Expand Down
Loading