private void ShowNotification(object pushNotification, PushNotificationModel parsedPushNotification, bool inForeground) { if (_showForegroundNotificationsInSystemOptions.ShouldShow() || !inForeground) { var remoteMessage = pushNotification as RemoteMessage; var notificationData = remoteMessage?.Data ?? new Dictionary <string, string>(); NotificationsHelper.CreateNotification(_appContext, parsedPushNotification, notificationData); } }
public override void Initialize(ForegroundNotificationOptions showForegroundNotificationsInSystemOptions) { if (_isInitialized) { throw new ArgumentException($"{nameof(DroidPushNotificationsService)}: Already Initialized"); } _isInitialized = true; _showForegroundNotificationsInSystemOptions = showForegroundNotificationsInSystemOptions; NotificationsHelper.CreateNotificationChannels(_appContext); FirebaseApp.InitializeApp(_appContext); XFirebaseMessagingService.OnTokenRefreshed += OnPushTokenRefreshed; XFirebaseMessagingService.OnNotificationReceived += OnNotificationReceived; }
public DroidPushNotificationsService( IRemotePushNotificationsService remotePushNotificationsService, IPushTokenStorageService pushTokenStorageService, IPushNotificationsHandler pushNotificationsHandler, IPushNotificationParser pushNotificationParser, INotificationsSettingsProvider notificationsSettings, ILogManager logManager) : base( remotePushNotificationsService, pushTokenStorageService, pushNotificationsHandler, pushNotificationParser, logManager) { _appContext = Application.Context; NotificationsHelper.Init(notificationsSettings); _lifecycleObserver = new AppLifecycleObserver(); ProcessLifecycleOwner.Get().Lifecycle.AddObserver(_lifecycleObserver); }
public override void OnReceive(Context context, Intent intent) { NotificationsHelper.CreateNotificationChannels(context); }