3using Microsoft.Maui.Devices;
4using Plugin.Firebase.CloudMessaging;
5using Plugin.Firebase.CloudMessaging.EventArgs;
16 private bool isInitialized;
29 CancellationToken.ThrowIfCancellationRequested();
31 if (this.isInitialized)
32 return Task.CompletedTask;
34 this.isInitialized =
true;
38 CrossFirebaseCloudMessaging.Current.TokenChanged += this.OnTokenChanged;
45 return Task.CompletedTask;
48 private async
void OnTokenChanged(
object? Sender, FCMTokenChangedEventArgs EventArgs)
52 string? Token = EventArgs?.Token;
53 if (
string.IsNullOrEmpty(Token))
63 EventHandlerAsync<TokenInformation>? Handler = this.
TokenChanged;
64 if (Handler is not
null)
65 await Handler.Raise(
this, TokenInformation);
69 ServiceRef.LogService.LogException(ex);
75 if (DeviceInfo.Platform == DevicePlatform.Android)
78 if (DeviceInfo.Platform == DevicePlatform.iOS || DeviceInfo.Platform == DevicePlatform.MacCatalyst)
Firebase Cloud Messaging transport adapter.
Task InitializeAsync(CancellationToken CancellationToken)
Initializes the transport and wires platform callbacks.
EventHandlerAsync< TokenInformation >? TokenChanged
Raised when the transport receives a refreshed token.
Base class that references services in the app.
static ILogService LogService
Log service.
Abstraction for platform push transports (Firebase, APNS, WNS).
ClientType
Type of client requesting notification.
PushMessagingService
Push messaging service used.