BuildIt.Bot.Client.Impl.Droid.Utilities.GcmService.DisplayPushNotification C# (CSharp) Method

DisplayPushNotification() private method

private DisplayPushNotification ( string title, string body ) : void
title string
body string
return void
        private void DisplayPushNotification(string title, string body)
        {
            Intent intent = new Intent(Application.Context, Settings.Instance.PushNotificationSettings.MainActivityType);
            intent.PutExtra(Constants.PushNotificationExtra, true);
            intent.SetFlags(Settings.Instance.PushNotificationSettings.ActivityFlags);
            // Create a PendingIntent; we're only using one PendingIntent (ID = 0):
            const int pendingIntentId = 0;
            PendingIntent pendingIntent = PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.OneShot);
            var notificationBuilder = new Notification.Builder(this).SetContentTitle(title)
                                                                    .SetContentText(body)
                                                                    .SetAutoCancel(true)
                                                                    .SetContentIntent(pendingIntent);
            if (Settings.Instance.PushNotificationSettings?.SmallIcon.HasValue ?? false)
            {
                notificationBuilder.SetSmallIcon(Settings.Instance.PushNotificationSettings.SmallIcon.Value);
            }

            var notificationManager = GetSystemService(NotificationService) as NotificationManager;
            notificationManager?.Notify(new Random().Next(100000), notificationBuilder.Build());
        }
    }