Exemple #1
0
 private void NotificationText(string text, string subtext)
 {
     notificationBuilder.SetContentText(text);
     if (!string.IsNullOrEmpty(subtext))
     {
         notificationBuilder.SetSubText(subtext);
     }
     notificationManager.Notify(NOTIFICATION_ID, notificationBuilder.Build());
 }
Exemple #2
0
        void SendNotification(MessaggioNotifica m)
        {
            var intent = new Intent (this, typeof(MainActivity));

            intent.AddFlags (ActivityFlags.ClearTop);

            var notifica = new Notification.Builder (this);
            switch (m.Tipo) {
            case "1":
                notifica.SetSmallIcon (Resource.Drawable.alert_1);
                break;
            case "2":
                notifica.SetSmallIcon (Resource.Drawable.alert_2);
                break;
            case "3":
                notifica.SetSmallIcon (Resource.Drawable.alert_3);
                break;
            default:
                notifica.SetSmallIcon (Resource.Drawable.InvioDoc);
                break;
            }

            if (m.Tipo == "4") {
                Messaggio mess = new Messaggio (m.Titolo, m.Messaggio);
                intent.PutExtra ("messaggio", JsonConvert.SerializeObject(mess));
            } else {
                intent.PutExtra ("commessanum", m.Commessa);
            }
            var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);

            notifica.SetContentTitle (m.Titolo);
            notifica.SetContentText (m.Messaggio);
            notifica.SetAutoCancel (true);
            notifica.SetContentInfo (m.Commessa);
            notifica.SetSubText ("Commessa " + m.Commessa);
            notifica.SetVibrate (new long[] {100,200,100});
            notifica.SetSound (RingtoneManager.GetDefaultUri(RingtoneType.Notification));
            notifica.SetContentIntent (pendingIntent);
            var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
            notificationManager.Notify (0, notifica.Build());
        }
        void SendNotification(string title, string body)
        {
            Body = body;
            var intent = new Intent(this, typeof(MainActivity));

            intent.PutExtra("title", title);
            intent.PutExtra("body", body);

            intent.AddFlags(ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);

            long[] pattern = { 500, 500, 500, 500, 500 };

            var notificationBuilder = new Notification.Builder(this)
                                      .SetSmallIcon(Resource.Drawable.ic_save)
                                      .SetContentTitle("Coin Rate")
                                      .SetContentText(body)
                                      .SetAutoCancel(true)
                                      .SetVibrate(pattern)
                                      .SetLights(Color.Blue, 1, 1)
                                      .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                      .SetContentIntent(pendingIntent);

            //.setContentTitle(URLDecoder.decode(getString(R.string.app_name), "UTF-8"))
            //.setContentText(URLDecoder.decode(message, "UTF-8"))

            notificationBuilder.SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.xamarin_logo));
            notificationBuilder.SetSubText("Tap to view");
            //notificationBuilder.SetNumber(2);
            //notificationBuilder.SetWhen
            //notificationBuilder.SetTicker("you received another value");

            var notificationManager = NotificationManager.FromContext(this);

            notificationManager.Notify(0, notificationBuilder.Build());
        }