示例#1
0
        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);
            }
        }
示例#2
0
        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;
        }
示例#3
0
        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);
        }
示例#4
0
 public override void OnReceive(Context context, Intent intent)
 {
     NotificationsHelper.CreateNotificationChannels(context);
 }