private static void HandleShowLocalNotificationIfNeeded(FCMNotification fcmNotification)
 {
     if (!string.IsNullOrEmpty(fcmNotification.Title) || !string.IsNullOrEmpty(fcmNotification.Body))
     {
         HandleShowLocalNotification(fcmNotification);
     }
 }
 private static NotificationCompat.Builder CreateDefaultNotificationBuilder(FCMNotification notification)
 {
     return(new NotificationCompat.Builder(_context, ChannelId)
            .SetSmallIcon(SmallIconRef)
            .TrySetBigPictureStyle(notification)
            .SetContentTitle(notification.Title)
            .SetContentText(notification.Body)
            .SetPriority(NotificationCompat.PriorityDefault)
            .SetAutoCancel(true));
 }
Esempio n. 3
0
 public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
 {
     if (_notificationTapped == null)
     {
         _missedTappedNotification = response.Notification.ToFCMNotification();
     }
     else
     {
         _notificationTapped.Invoke(this, new FCMNotificationTappedEventArgs(response.Notification.ToFCMNotification()));
     }
 }
        private static void HandleShowLocalNotification(FCMNotification notification)
        {
            var intent = _context.PackageManager.GetLaunchIntentForPackage(_context.PackageName);

            intent.PutExtra(IntentKeyFCMNotification, notification.ToBundle());
            intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            var pendingIntent       = PendingIntent.GetActivity(_context, 0, intent, 0);
            var builder             = NotificationBuilderProvider?.Invoke(notification) ?? CreateDefaultNotificationBuilder(notification);
            var notificationManager = (NotificationManager)_context.GetSystemService(Context.NotificationService);

            notificationManager.Notify(1337, builder.SetContentIntent(pendingIntent).Build());
        }
        private void HandleNotificationFromIntent(Intent intent)
        {
            var notification = intent.GetNotificationFromExtras(IntentKeyFCMNotification);

            if (_notificationTapped == null)
            {
                _missedTappedNotification = notification;
            }
            else
            {
                _notificationTapped.Invoke(this, new FCMNotificationTappedEventArgs(notification));
            }
            intent.RemoveExtra(IntentKeyFCMNotification);
        }
Esempio n. 6
0
 public void OnNotificationReceived(FCMNotification message)
 {
     NotificationReceived?.Invoke(this, new FCMNotificationReceivedEventArgs(message));
 }
 public void OnNotificationReceived(FCMNotification fcmNotification)
 {
     NotificationReceived?.Invoke(this, new FCMNotificationReceivedEventArgs(fcmNotification));
     HandleShowLocalNotificationIfNeeded(fcmNotification);
 }