// Creates a new notification depending on makeHeadsUpNotification.
        public Notification CreateNotification(Context context, Intent intent)
        {
            // indicate that this sms comes from server
            intent.PutExtra ("source", "server");

            // Parse bundle extras
            string contactId = intent.GetStringExtra("normalizedPhone");
            string message = intent.GetStringExtra("message");

            // Getting contact infos
            var contact = Contact.GetContactByPhone (contactId, context);

            var builder = new Notification.Builder (context)
                .SetSmallIcon (Resource.Drawable.icon)
                .SetPriority ((int)NotificationPriority.Default)
                .SetCategory (Notification.CategoryMessage)
                .SetContentTitle (contact.DisplayName != "" ? contact.DisplayName : contactId)
                .SetContentText (message)
                .SetSound (RingtoneManager.GetDefaultUri (RingtoneType.Notification));

            var fullScreenPendingIntent = PendingIntent.GetActivity (context, 0,
                intent, PendingIntentFlags.CancelCurrent);
                builder.SetContentText (message)
                       .SetFullScreenIntent (fullScreenPendingIntent, true)
                       .SetContentIntent (fullScreenPendingIntent);

            return builder.Build ();
        }
        protected override void OnCreate(Bundle bundle)
        {
            var intentFilter = new IntentFilter();
            intentFilter.AddAction(ConnectivityManager.ConnectivityAction);
            RegisterReceiver(new Connectivity(), intentFilter);

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            connectivity.Singleton.MessageEvents.Change += (object s, UIChangedEventArgs ea) =>
            {
                if (ea.ModuleName == "Notification")
                {
                    RunOnUiThread(() =>
                        {
                            var builder = new Notification.Builder(this)
                                    .SetAutoCancel(true)
                                    .SetContentTitle("Network state changed")
                                    .SetContentText(ea.Info)
                                    .SetDefaults(NotificationDefaults.Vibrate)
                                    .SetContentText(ea.Info);

                            var notificationManager = (NotificationManager)GetSystemService(NotificationService);
                            notificationManager.Notify(ButtonClickNotificationId, builder.Build());
                        });
                }
            };

            LoadApplication(new App());
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			var toggle_alarm_operation = new Intent (this, typeof(FindPhoneService));

			toggle_alarm_operation.SetAction(FindPhoneService.ACTION_TOGGLE_ALARM);
			var toggle_alarm_intent = PendingIntent.GetService (this, 0, toggle_alarm_operation, PendingIntentFlags.CancelCurrent);
			Android.App.Notification.Action alarm_action = new Android.App.Notification.Action (Resource.Drawable.alarm_action_icon, "", toggle_alarm_intent);
			var cancel_alarm_operation = new Intent (this, typeof(FindPhoneService));
			cancel_alarm_operation.SetAction (FindPhoneService.ACTION_CANCEL_ALARM);
			var cancel_alarm_intent = PendingIntent.GetService (this, 0, cancel_alarm_operation, PendingIntentFlags.CancelCurrent);
			var title = new SpannableString ("Find My Phone");
			title.SetSpan (new RelativeSizeSpan (0.85f), 0, title.Length(), SpanTypes.PointMark);
			notification = new Notification.Builder (this)
				.SetContentTitle (title)
				.SetContentText ("Tap to sound an alarm on phone")
				.SetSmallIcon (Resource.Drawable.ic_launcher)
				.SetVibrate (new long[]{ 0, 50 })
				.SetDeleteIntent (cancel_alarm_intent)
				.Extend (new Notification.WearableExtender ()
					.AddAction (alarm_action)
					.SetContentAction (0)
					.SetHintHideIcon (true))
				.SetLocalOnly (true)
				.SetPriority ((int)NotificationPriority.Max);
			((NotificationManager)GetSystemService (NotificationService))
				.Notify (FIND_PHONE_NOTIFICATION_ID, notification.Build ());

			Finish ();
		}
        public override void OnReceive(Context context, Intent intent)
        {
            string message = intent.GetStringExtra("message");
            string title = intent.GetStringExtra("title");

            Intent notIntent = new Intent(context, typeof(NotificationService));

            PendingIntent contentIntent = PendingIntent.GetActivity(context, 0, notIntent, PendingIntentFlags.CancelCurrent);
            NotificationManager manager = NotificationManager.FromContext(context);

            var bigTextStyle = new Notification.BigTextStyle()
                        .SetBigContentTitle(title)
                        .BigText(message);

            Notification.Builder builder = new Notification.Builder(context)
                .SetContentIntent(contentIntent)
                .SetSmallIcon(Resource.Drawable.icon)
                .SetContentTitle(title)
                .SetContentText(message)
                .SetStyle(bigTextStyle)
                .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
                .SetAutoCancel(true)
                .SetPriority((int)NotificationPriority.High)
                .SetVisibility(NotificationVisibility.Public)
                .SetDefaults(NotificationDefaults.Vibrate)
                .SetCategory(Notification.CategoryAlarm);

            if (!MainActivity.IsActive)
            {
                manager.Notify(0, builder.Build());
                StartWakefulService(context, notIntent);
            }
        }
		private void ShowLocalNotification (Context context, Intent intent)
		{
			var launch = new Intent (context, typeof (MainActivity));

			const int pendingIntentId = 0;
			var pendingIntent = 
				PendingIntent.GetActivity (context, 
					pendingIntentId, launch, PendingIntentFlags.UpdateCurrent);
					
			var msg = intent.Extras.GetString ("message");

			if (!String.IsNullOrEmpty (msg))
			{
				// Instantiate the builder and set notification elements:
				Notification.Builder builder = new Notification.Builder (this)
					.SetContentIntent (pendingIntent)
					.SetContentTitle ("New Notification!")
					.SetContentText (msg)
					.SetDefaults (NotificationDefaults.Sound);

				// Build the notification:
				Notification notification = builder.Build ();

				// Get the notification manager:
				NotificationManager notificationManager = GetSystemService (Context.NotificationService) as NotificationManager;

				// Publish the notification:
				const int notificationId = 0;
				notificationManager.Notify (notificationId, notification);
			}
		}
      public Notification Build(Builder b) {
        Notification.Builder builder = new Notification.Builder(b.Context);
        builder.SetContentTitle(b.ContentTitle)
          .SetContentText(b.ContentText)
          .SetTicker(b.Notification.TickerText)
          .SetSmallIcon(b.Notification.Icon, b.Notification.IconLevel)
          .SetContentIntent(b.ContentIntent)
          .SetDeleteIntent(b.Notification.DeleteIntent)
          .SetAutoCancel((b.Notification.Flags & NotificationFlags.AutoCancel) != 0)
          .SetLargeIcon(b.LargeIcon)
          .SetDefaults(b.Notification.Defaults);

        if (b.Style != null) {
          if (b.Style is BigTextStyle) {
            BigTextStyle staticStyle = b.Style as BigTextStyle;
            Notification.BigTextStyle style = new Notification.BigTextStyle(builder);
            style.SetBigContentTitle(staticStyle.BigContentTitle)
              .BigText(staticStyle.bigText);
            if (staticStyle.SummaryTextSet) {
              style.SetSummaryText(staticStyle.SummaryText);
            }
          }
        }

        return builder.Build();
      }
		private void SendNotification (Bundle data) {
			Intent intent;
			string type = data.GetString("type");

			intent = new Intent (this, typeof(MainActivity));
			if(type.Equals(PUSH_INVITE)) {
				ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId"));
				intent.SetAction(PUSH_INVITE);
			} else if(type.Equals(PUSH_EVENT_UPDATE)) {
				ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId"));
				intent.SetAction(PUSH_EVENT_UPDATE);
			} else if(type.Equals(PUSH_DELETE)) {
				//nothing else need to be done
				//MainActivity will refresh the events on start
			}

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

			var notificationBuilder = new Notification.Builder(this)
				.SetSmallIcon (Resource.Drawable.pushnotification_icon)
				.SetContentTitle (data.GetString("title"))
				.SetContentText (data.GetString ("message"))
				.SetVibrate(new long[] {600, 600})
				.SetAutoCancel (true)
				.SetContentIntent (pendingIntent);

			var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
			notificationManager.Notify (notificationId, notificationBuilder.Build());
			notificationId++;
		}
        protected override void OnMessage(Context context, Intent intent)
        {

            string message = string.Empty;

            // Extract the push notification message from the intent.
            if (intent.Extras.ContainsKey("message"))
            {
                message = intent.Extras.Get("message").ToString();
                var title = "Doctor Notification";

                // Create a notification manager to send the notification.
                var notificationManager =
                    GetSystemService(NotificationService) as NotificationManager;

                // Create a new intent to show the notification in the UI. 
                PendingIntent contentIntent =
                    PendingIntent.GetActivity(context, 0,
                    new Intent(this, typeof(MainActivity)), 0);

                // Create the notification using the builder.
                var builder = new Notification.Builder(context);
                builder.SetAutoCancel(true);
                builder.SetContentTitle(title);
                builder.SetContentText(message);
                builder.SetSmallIcon(Resource.Drawable.ic_launcher);
                builder.SetContentIntent(contentIntent);
                var notification = builder.Build();

                // Display the notification in the Notifications Area.
                notificationManager.Notify(1, notification);

                ShowPopUp(context, message);
            }
        }
Example #9
0
 public override void OnReceive(Context context, Intent intent)
 {
     var str1 = intent.GetStringExtra ("team1");
     var str2 = intent.GetStringExtra ("team2");
     var count1 = intent.GetStringExtra ("count");
     var iconId = intent.GetStringExtra ("icon");
     Console.WriteLine ("Servise Start");
     PowerManager pm = (PowerManager)context.GetSystemService(Context.PowerService);
     PowerManager.WakeLock w1 = pm.NewWakeLock (WakeLockFlags.Partial, "NotificationReceiver");
     w1.Acquire ();
     Notification.Builder builder = new Notification.Builder (context)
         .SetContentTitle (context.Resources.GetString(Resource.String.matchIsStarting))
         .SetContentText (str1+" VS. "+str2)
         .SetSmallIcon (Convert.ToInt32(iconId));
     // Build the notification:
     Notification notification = builder.Build();
     notification.Defaults = NotificationDefaults.All;
     // Get the notification manager:
     NotificationManager notificationManager = (NotificationManager)context.GetSystemService (Context.NotificationService);
     // Publish the notification:
     int notificationId = Convert.ToInt32(count1);
     notificationManager.Notify (notificationId, notification);
     w1.Release ();
     var tempd = DateTime.UtcNow;
     Console.WriteLine ("Alarm: " + tempd);
 }
        private void ExibirInboxNotificacao()
        {
            Notification.Builder builder = new Notification.Builder(this)
                .SetContentTitle ("Sample Notification")
                .SetContentText ("Hello World! This is my first action notification!")
                .SetDefaults (NotificationDefaults.Sound)
                .SetSmallIcon (Resource.Drawable.Icon);

            // Instantiate the Inbox style:
            Notification.InboxStyle inboxStyle = new Notification.InboxStyle();

            // Set the title and text of the notification:
            builder.SetContentTitle ("5 new messages");
            builder.SetContentText ("*****@*****.**");

            // Generate a message summary for the body of the notification:
            inboxStyle.AddLine ("Cheeta: Bananas on sale");
            inboxStyle.AddLine ("George: Curious about your blog post");
            inboxStyle.AddLine ("Nikko: Need a ride to Evolve?");
            inboxStyle.SetSummaryText ("+2 more");

            // Plug this style into the builder:
            builder.SetStyle (inboxStyle);

            Notification notification = builder.Build();

            NotificationManager notificationManager =
                GetSystemService (Context.NotificationService) as NotificationManager;

            const int notificationId = 0;
            notificationManager.Notify (notificationId, notification);
        }
		public void ShowNotification(string title, string messageTitle, string messege, bool handleClickNeeded )
		{
			try
			{
				// Set up an intent so that tapping the notifications returns to this app:
				Intent intent = new Intent ( Application.Context , typeof(  NotificationClick ));
				//intent.RemoveExtra ("MyData");
				intent.PutExtra ("Message", messege);
				intent.PutExtra ("Title", title);

				string chatMsg = messege;
				string chatTouserID = "";

				if( title == "chat" )
				{
					string[] delimiters = { "&&" };
					string[] clasIDArray = messege.Split(delimiters, StringSplitOptions.None);
					chatMsg = clasIDArray [0];
					chatTouserID = clasIDArray [1];
				}



				// Create a PendingIntent; we're only using one PendingIntent (ID = 0):
				const int pendingIntentId = 0;
				PendingIntent pendingIntent = 
					PendingIntent.GetActivity ( MainActivity.GetMainActivity() , pendingIntentId, intent, PendingIntentFlags.OneShot);

				// Instantiate the builder and set notification elements:
				Notification.Builder builder = new Notification.Builder(MainActivity.GetMainActivity())
					.SetContentTitle(title)
					.SetContentText(chatMsg)
					.SetDefaults(NotificationDefaults.Sound)
					.SetAutoCancel( true )
					.SetSmallIcon(Resource.Drawable.app_icon);

				builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate);

				if( handleClickNeeded )
					builder.SetContentIntent( pendingIntent );

				// Build the notification: 
				Notification notification = builder.Build();

				// Get the notification manager:
				NotificationManager notificationManager = (NotificationManager)MainActivity.GetMainActivity().GetSystemService(Context.NotificationService);

				// Publish the notification:
				const int notificationId = 0;
				notificationManager.Notify(notificationId, notification);
			} 
			catch (Exception ex)
			{
				string err = ex.Message;
			}

		}
    void DispatchNotificationThatServiceIsRunning()
    {
        Notification.Builder notificationBuilder = new Notification.Builder(this)
                                                   .SetSmallIcon(Resource.Drawable.btn_bookoflifeMainMenu)
                                                   .SetContentTitle(Resources.GetString(Resource.String.app_name))
                                                   .SetContentText("TESTING");

        var notificationManager = (NotificationManager)GetSystemService(NotificationService);

        notificationManager.Notify(NOTIFICATION_ID, notificationBuilder.Build());
    }
		// Creates a new notification with a different visibility level.
		public Notification CreateNotification(NotificationVisibility visibility)
		{
			var builder = new Notification.Builder (Activity)
				.SetContentTitle ("Notification for Visibility metadata");

			builder.SetVisibility (visibility);
			builder.SetContentText (string.Format ("Visibility : {0}", 
				NotificationVisibilities.GetDescription(visibility)));
			builder.SetSmallIcon (NotificationVisibilities.GetNotificationIconId (visibility));
			return builder.Build ();
		}
      private Notification createNativeNotification(int badgeNumber, string title)
      {
          var builder = new Notification.Builder(Application.Context)
              .SetContentTitle(title)
              .SetTicker(title)
              .SetNumber(badgeNumber)
              .SetSmallIcon(Resource.Drawable.IcDialogEmail);

          var nativeNotification = builder.Build();
          return nativeNotification;
      }
Example #15
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            int   TimerWait = 60000;
            Timer _timer;
            int   notificationCount             = 0;
            List <FeedingTime> usedFeedingtimes = new List <FeedingTime>();

            Thread t = new Thread(() => {
                _timer = new Timer(o => {
                    FeedingTime timeToCheck;
                    DateTime now = DateTime.Now;
                    foreach (Animal a in AttractionDataBase.animalsToWatch)
                    {
                        if (a.HasFeedingTime && a.IsInSeason)
                        {
                            timeToCheck = a.NextFeeding;
                            Console.WriteLine(a.Name + " - " + a.NextFeeding + " : " + timeToCheck.TimeOfDay.AddMinutes(-5));

                            if (now.Hour == timeToCheck.TimeOfDay.AddMinutes(-5).Hour&&
                                now.Minute == timeToCheck.TimeOfDay.AddMinutes(-5).Minute)
                            {
                                System.IO.Stream ims = Assets.Open("img/AnimalHeaders/" + a.Name + "Header.png");
                                // load image as Drawable
                                Bitmap bitmap = BitmapFactory.DecodeStream(ims);
                                ims.Close();

                                Notification.Builder builder = new Notification.Builder(this)
                                                               .SetContentTitle("Fodring hos " + a.Name)
                                                               .SetContentText("om " + lookAheadTime + " minutter.")
                                                               .SetSmallIcon(Resource.Drawable.logo);
                                builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate);

                                Notification notification = builder.Build();

                                NotificationManager notificationManager =
                                    GetSystemService(Context.NotificationService) as NotificationManager;

                                notificationManager.Notify(notificationCount++, notification);
                            }
                        }
                    }

                    Console.WriteLine(DateTime.Now.Minute);
                },
                                   null, 0, TimerWait);
            });

            if (t.IsAlive == false)
            {
                t.Start();
            }

            return(StartCommandResult.NotSticky);
        }
Example #16
0
        void SendNotification(RemoteMessage messageBody)
        {
            var intent = new Intent(this, typeof(MainActivity));

            intent.AddFlags(ActivityFlags.ClearTop);
            var pendingIntent       = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
            var notificationBuilder = new Notification.Builder(this).SetSmallIcon(Resource.Drawable.icono).SetContentTitle(messageBody.GetNotification().Title).SetContentText(messageBody.GetNotification().Body).SetAutoCancel(true).SetContentIntent(pendingIntent).SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)).SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }).SetLights(Color.Red, 3000, 3000);
            var notificationManager = NotificationManager.FromContext(this);

            notificationManager.Notify(0, notificationBuilder.Build());
        }
        void DispatchNotificationThatServiceIsRunning()
        {
            Notification.Builder notificationBuilder = new Notification.Builder(this)
                                                       .SetSmallIcon(Resource.Drawable.notification_template_icon_bg)
                                                       .SetContentTitle("LocationTest")
                                                       .SetContentText("TimeService is running");

            var notificationManager = (NotificationManager)GetSystemService(NotificationService);

            notificationManager.Notify(NOTIFICATION_ID, notificationBuilder.Build());
        }
        private Notification createNativeNotification(LocalNotification notification)
        {
            var builder = new Notification.Builder(Application.Context)
                .SetContentTitle(notification.Title)
                .SetContentText(notification.Text)
//                .SetSmallIcon(Resource.Drawable.IcDialogEmail);
                .SetSmallIcon(Application.Context.ApplicationInfo.Icon);

            var nativeNotification = builder.Build();
            return nativeNotification;
        }
Example #19
0
        void DispatchNotificationThatServiceIsRunning()
        {
            Notification.Builder notificationBuilder = new Notification.Builder(this)
                                                       .SetSmallIcon(Resource.Drawable.ic_stat_name)
                                                       .SetContentTitle(Resources.GetString(Resource.String.app_name))
                                                       .SetContentText(Resources.GetString(Resource.String.notification_text));

            var notificationManager = (NotificationManager)GetSystemService(NotificationService);

            notificationManager.Notify(NOTIFICATION_ID, notificationBuilder.Build());
        }
Example #20
0
        internal static void Notify(Region region = null, [CallerMemberName] string title = "Unknown")
        {
            Notification.Builder builder = new Notification.Builder(Forms.Context)
                                           .SetContentTitle(title)
                                           .SetContentText(region != null ? $"{region.Id1}" : "Region unknown")
                                           .SetSmallIcon(Resource.Drawable.icon);
            Notification        notification        = builder.Build();
            NotificationManager notificationManager = Forms.Context.GetSystemService(Context.NotificationService) as NotificationManager;
            const int           notificationId      = 11;

            notificationManager.Notify(notificationId, notification);
        }
        private Notification createNativeNotification(int badgeNumber, string title)
        {
            var builder = new Notification.Builder(Application.Context)
                          .SetContentTitle(title)
                          .SetTicker(title)
                          .SetNumber(badgeNumber);
            //.SetSmallIcon(Resource.Drawable.IcDialogEmail);

            var nativeNotification = builder.Build();

            return(nativeNotification);
        }
        public void Notify(string title, string message)
        {
            Intent startupIntent = new Intent(Android.App.Application.Context, typeof(MainActivity));

            startupIntent.PutExtra("title", title.ToString());
            startupIntent.PutExtra("message", message.ToString());


            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(Android.App.Application.Context);

            stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));

            stackBuilder.AddNextIntent(startupIntent);

            const int     pendingIntentId = 0;
            PendingIntent pendingIntent   =
                stackBuilder.GetPendingIntent(pendingIntentId, PendingIntentFlags.OneShot);


            Notification.Builder builder = new Notification.Builder(Android.App.Application.Context)
                                           .SetContentTitle(title)
                                           .SetContentText(message)
                                           .SetContentIntent(pendingIntent)
                                           .SetSmallIcon(Resource.Drawable.icon);
            // Build the notification:
            Notification notification = builder.Build();

            notification.Vibrate = new long[] { 150, 300, 150, 600 };
            notification.Flags   = NotificationFlags.AutoCancel;

            try
            {
                Android.Net.Uri song = RingtoneManager.GetDefaultUri(RingtoneType.Notification);
                var             play = RingtoneManager.GetRingtone(Android.App.Application.Context, song);
                play.Play();
            }
            catch (Exception ex)
            {
            }



            // Get the notification manager:
            NotificationManager notificationManager =
                Android.App.Application.Context.GetSystemService(Context.NotificationService) as NotificationManager;



            // Publish the notification:
            const int notificationId = 0;

            notificationManager.Notify(notificationId, notification);
        }
Example #23
0
        void createNotification(string title, string desc)
        {
            var builder = new Notification.Builder(Application.Context)
                          .SetContentTitle(title)
                          .SetContentText(desc)
                          .SetSmallIcon(Android.Resource.Drawable.SymActionEmail);
            var notification = builder.Build();

            var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;

            notificationManager.Notify(1, notification);
        }
    private void SendNotification(string message)
    {
        var builder = new Notification.Builder(this)
                      .SetContentTitle("Title")
                      .SetContentText(message)
                      .SetSmallIcon(Resource.Drawable.notification_test)
                      .SetVisibility(NotificationVisibility.Public);
        var notification        = builder.Build();
        var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;

        notificationManager.Notify(0, notification);
    }
Example #25
0
        private void CheckServerNotifications(Context pContext, string sClan, string sName)
        {
            XElement pResponse = null;
            //try
            //{
            string sPrevClan = Master.GetActiveClan();
            string sPrevUser = Master.GetActiveUserName();

            Master.SetActiveClan(sClan);
            Master.SetActiveUserName(sName);
            string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetServerURL() + "GetUnseenNotifications", Master.BuildCommonBody(), true);

            pResponse = Master.ReadResponse(sResponse);
            Master.SetActiveClan(sPrevClan);
            Master.SetActiveUserName(sPrevUser);
            //}
            //catch (Exception e) { return; }

            if (pResponse.Element("Data") != null && pResponse.Element("Data").Element("Notifications").Value != "")
            {
                List <XElement> pNotifications = pResponse.Element("Data").Element("Notifications").Elements("Notification").ToList();
                foreach (XElement pNotification in pNotifications)
                {
                    string sContent  = pNotification.Value;
                    string sGameID   = pNotification.Attribute("GameID").Value;
                    string sGameName = pNotification.Attribute("GameName").Value;

                    Notification.Builder pBuilder = new Notification.Builder(pContext);
                    pBuilder.SetContentTitle(sClan + " - " + sGameName);
                    pBuilder.SetContentText(sContent);
                    pBuilder.SetSmallIcon(Resource.Drawable.Icon);
                    pBuilder.SetVibrate(new long[] { 200, 50, 200, 50 });
                    pBuilder.SetVisibility(NotificationVisibility.Public);
                    pBuilder.SetPriority((int)NotificationPriority.Default);

                    Intent pIntent = null;
                    if (sGameID.Contains("Zendo"))
                    {
                        pIntent = new Intent(pContext, typeof(ZendoActivity));
                    }
                    pIntent.SetAction(sGameID);
                    pIntent.PutExtra("GameName", sGameName);

                    pBuilder.SetContentIntent(PendingIntent.GetActivity(pContext, 0, pIntent, 0));
                    pBuilder.SetStyle(new Notification.BigTextStyle().BigText(sContent));

                    Notification        pNotif   = pBuilder.Build();
                    NotificationManager pManager = (NotificationManager)pContext.GetSystemService(Context.NotificationService);
                    pManager.Notify((int)Java.Lang.JavaSystem.CurrentTimeMillis(), pNotif);                     // using time to make different ID every time, so doesn't replace old notification
                    //pManager.Notify(DateTime.Now.Millisecond, pNotif); // using time to make different ID every time, so doesn't replace old notification
                }
            }
        }
Example #26
0
        private void NotifyToAutofill(string uri, NotificationManager notificationManager)
        {
            if (notificationManager == null || string.IsNullOrWhiteSpace(uri))
            {
                return;
            }

            var now    = Java.Lang.JavaSystem.CurrentTimeMillis();
            var intent = new Intent(this, typeof(AccessibilityActivity));

            intent.PutExtra("uri", uri);
            intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent);

            var notificationContent = Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch ?
                                      AppResources.BitwardenAutofillServiceNotificationContent :
                                      AppResources.BitwardenAutofillServiceNotificationContentOld;

            var builder = new Notification.Builder(this);

            builder.SetSmallIcon(Resource.Drawable.shield)
            .SetContentTitle(AppResources.BitwardenAutofillService)
            .SetContentText(notificationContent)
            .SetTicker(notificationContent)
            .SetWhen(now)
            .SetContentIntent(pendingIntent);

            if (Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch)
            {
                builder.SetVisibility(NotificationVisibility.Secret)
                .SetColor(Android.Support.V4.Content.ContextCompat.GetColor(ApplicationContext,
                                                                            Resource.Color.primary));
            }
            if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                if (_notificationChannel == null)
                {
                    _notificationChannel = new NotificationChannel("bitwarden_autofill_service",
                                                                   AppResources.AutofillService, NotificationImportance.Low);
                    notificationManager.CreateNotificationChannel(_notificationChannel);
                }
                builder.SetChannelId(_notificationChannel.Id);
            }
            if (/*Build.VERSION.SdkInt <= BuildVersionCodes.N && */ _settingAutofillPersistNotification)
            {
                builder.SetPriority(-2);
            }

            _lastNotificationTime = now;
            _lastNotificationUri  = uri;
            notificationManager.Notify(AutoFillNotificationId, builder.Build());
            builder.Dispose();
        }
        public static void Send(this Notification.Builder builder)
        {
            var notification = builder.Build();
            //var notificationId = Convert.ToInt32 (DateTime.Now.Ticks); //meh?  how unique does this need to be?

            //we want to use the same thing here we passed as request id, above
            var notificationId = builder.GetHashCode();

            NotificationManagerCompat notificationManager = NotificationManagerCompat.From(Application.Context);

            notificationManager.Notify(notificationId, notification);
        }
Example #28
0
        private Notification createNativeNotification(LocalNotification notification)
        {
            var builder = new Notification.Builder(Application.Context)
                          .SetContentTitle(notification.Title)
                          .SetContentText(notification.Text)
//                .SetSmallIcon(Resource.Drawable.IcDialogEmail);
                          .SetSmallIcon(Application.Context.ApplicationInfo.Icon);

            var nativeNotification = builder.Build();

            return(nativeNotification);
        }
Example #29
0
        public override void OnReceive(Context context, Intent intent)
        {
            // set next alarm
            //var repetitionIntent = new Intent(context, typeof(AlarmReceiver));
            //var source = PendingIntent.GetBroadcast(context, 0, intent, 0);
            //var am = (AlarmManager)Android.App.Application.Context.GetSystemService(Context.AlarmService);
            //var calendar = DateTime.Parse(intent.GetStringExtra(Intent.ExtraText)).AddMinutes(1);

            //DateTime dtBasis = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            //am.SetExactAndAllowWhileIdle(AlarmType.RtcWakeup, (long)calendar.ToUniversalTime().Subtract(dtBasis).TotalMilliseconds, source);


            int notificationId = 001;
            // The channel ID of the notification.
            String id = "my_channel_01";

            // sound the alarm
            var alert   = RingtoneManager.GetDefaultUri(RingtoneType.Alarm);
            var _mediap = MediaPlayer.Create(context, alert);

            AudioManager audioM = (AudioManager)context.GetSystemService(Context.AudioService);

            if (audioM.GetStreamVolume(Stream.Alarm) != 0)
            {
                _mediap.Start();

                // wait 5 sec... then stop the player.
                new Handler().PostDelayed(() =>
                {
                    _mediap.Stop();
                }, 5000);//millisec.
            }

            NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);

            Intent        respondIntent        = new Intent(context, typeof(NotificationService));
            PendingIntent respontPendingIntent = PendingIntent.GetService(context, 0, respondIntent, 0);

            Notification.Action action = new Notification.Action(Resource.Drawable.generic_confirmation, "confirm", respontPendingIntent);

            Intent        snoozeIntent        = new Intent(context, typeof(SnoozeService));
            PendingIntent snoozePendingIntent = PendingIntent.GetService(context, 0, snoozeIntent, 0);

            Notification.Action snooze = new Notification.Action(Resource.Drawable.generic_confirmation, "snooze", snoozePendingIntent);
            var noti = new Notification.Builder(context)
                       .SetContentTitle("Title").SetContentText("content text")
                       .SetSmallIcon(Resource.Drawable.pills)
                       .AddAction(action)
                       .AddAction(snooze);


            notificationManager.Notify(notificationId, noti.Build());
        }
Example #30
0
        private static Notification GetNotification(Context ctx, int sessionId, NotificationOption not)
        {
            WorkshopDetail session = null;

            if (not.isWorkshop)
            {
                session = Services.Workshop.GetWorkshopFromBookingLocal(sessionId);
            }
            else
            {
                session = Services.Session.GetSession(sessionId);
            }

            var prefix = (not.isWorkshop) ? "" : "Session with ";

            Notification.Builder mBuilder =
                new Notification.Builder(ctx)
                .SetSmallIcon(Resource.Drawable.notificationIcon)
                .SetContentTitle(prefix + session.Title)
                .SetContentText(session.Time + " - " + session.DateHumanFriendly)
                .SetAutoCancel(true)
                .SetColor(ctx.Resources.GetColor(Resource.Color.primary))
                .SetDefaults(NotificationDefaults.All)
                .SetStyle(
                    new Notification.BigTextStyle().SetSummaryText(session.Title)
                    .BigText(session.Time + " - " + session.DateHumanFriendly + System.Environment.NewLine +
                             session.Room));
            try
            {
                Looper.Prepare();
            }
            catch (System.Exception ex) { }

            Intent resultIntent = new Intent(ctx, new ViewSessionActivity().Class);

            if (not.isWorkshop)
            {
                resultIntent = new Intent(ctx, new ViewWorkshopActivity().Class);
            }
            resultIntent.PutExtra("Id", sessionId);
            resultIntent.PutExtra("IsBooking", true);

            TaskStackBuilder stackBuilder = TaskStackBuilder.Create(ctx);

            stackBuilder.AddParentStack(new ViewWorkshopActivity().Class);
            stackBuilder.AddNextIntent(resultIntent);
            int           identifier          = (not.isWorkshop) ? 1 : 0;
            int           notificationId      = Integer.ParseInt(identifier + sessionId.ToString() + not.mins);
            PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(notificationId, PendingIntentFlags.UpdateCurrent);

            mBuilder.SetContentIntent(resultPendingIntent);
            return(mBuilder.Build());
        }
Example #31
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            DBHelper dbh;
            string   result = null;

            switch (item.ItemId)
            {
            case Resource.Id.menu_goalstatus:
                dbh = new DBHelper();
                string status    = txtStatus.Text;                  //goal status
                string newstatus = null;

                if (status.Equals("Completed"))
                {
                    newstatus = "Pending";
                }
                if (status.Equals("Pending"))
                {
                    newstatus = "Completed";
                }

                result = dbh.UpdateGoalStatus(selGoalId, newstatus);

                if (result.Equals("ok"))
                {
                    populateAcitvity(selGoalId);
                    if (newstatus.Equals("Completed"))
                    {
                        var nMgr = (NotificationManager)Activity.GetSystemService(Context.NotificationService);

                        //Details of notification in previous recipe
                        Notification.Builder builder = new Notification.Builder(Context)
                                                       .SetAutoCancel(true)
                                                       .SetContentTitle("Hooray! Goal Achieved")
                                                       .SetContentText(txtGoal.Text + " is marked as completed.")
                                                       .SetSmallIcon(Resource.Drawable.ic_trophy);

                        nMgr.Notify(0, builder.Build());
                    }

                    Toast.MakeText(view.Context, "Goal status updated!", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(view.Context, "Failed updating goal status!", ToastLength.Short).Show();
                }
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
Example #32
0
        public static void Notify(Context context, string message, string title = "")
        {
            Notification.Builder builder2 = new Notification.Builder(context)
                                            .SetContentTitle(title)
                                            .SetContentText(message)
                                            .SetLights(0xff9900, 1000, 500)
                                            .SetVibrate(new long[] { 0, 150, 50, 500 })
                                            .SetSmallIcon(Resource.Drawable.mess);
            Notification        notification2        = builder2.Build();
            NotificationManager notificationManager2 = context.GetSystemService(Context.NotificationService) as NotificationManager;

            notificationManager2.Notify(0, notification2);
        }
		public override void OnPeerDisconnected (INode p0)
		{
			Notification.Builder notificationBuilder = new Notification.Builder (this)
				.SetContentTitle ("Forgetting Something?")
				.SetContentText ("You may have left your phone behind.")
				.SetVibrate (new long[]{ 0, 200 })
				.SetSmallIcon (Resource.Drawable.ic_launcher)
				.SetLocalOnly (true)
				.SetPriority ((int)NotificationPriority.Max);
			Notification card = notificationBuilder.Build ();
			((NotificationManager)GetSystemService (NotificationService))
				.Notify (FORGOT_PHONE_NOTIFICATION_ID, card);
		}
        /// <summary>
        /// Show a local notification in the Notification Area and Drawer.
        /// </summary>
        /// <param name="title">Title of the notification</param>
        /// <param name="body">Body or description of the notification</param>
        public void Show(string title, string body)
        {
            var builder = new Notification.Builder(Application.Context);
            builder.SetContentTitle(title);
            builder.SetContentText(body);
            builder.SetSmallIcon(Resource.Drawable.Icon);

            var notification = builder.Build();

            var manager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager;

            manager.Notify(0, notification);
        }
        private void addNotification()
        {
            // create the pending intent and add to the notification
            var intent = this.PackageManager.GetLaunchIntentForPackage(this.PackageName); // opens app from background ( Can we use this auto open app with alert? )
                                                                                          // intent.AddFlags(ActivityFlags.ClearTop);
                                                                                          //Intent intent = new Intent(this, typeof(BackgroundService));
            PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent);
            var           lastLogin     = "******";

            // string lastLogin =  as string;
            if (Xamarin.Forms.Application.Current.Properties.Count > 0)
            {
                if (Xamarin.Forms.Application.Current.Properties[Constants.CURRENT_DATE] != null)
                {
                    lastLogin = "******" + Xamarin.Forms.Application.Current.Properties[Constants.CURRENT_DATE].ToString();
                }
            }
            string deviceModel = DeviceModal;

            Xamarin.Forms.Application.Current.Properties[Constants.DEVICE_MODEL] = deviceModel;

            // create the notification
            Notification.Builder m_notificationBuilder = new Notification.Builder(this)
                                                         .SetContentTitle("AssetChain")
                                                         .SetContentText(lastLogin)
                                                         .SetSmallIcon(Resource.Drawable.logo)
                                                         .SetContentIntent(pendingIntent);

            Notification notification = m_notificationBuilder.Build();

            notification.Flags = NotificationFlags.AutoCancel;

            // send the notification
            const int           NOTIFICATION_ID     = 101;
            NotificationManager notificationManager = this.GetSystemService(Context.NotificationService) as NotificationManager;

            StartForeground(NOTIFICATION_ID, notification); // locks notificaion in bar
            notificationManager.Notify(NOTIFICATION_ID, m_notificationBuilder.Build());
        }
Example #36
0
        private void BtnNotify_Click(object sender, EventArgs e)
        {
            //Intent intent = new Intent(this, typeof(MainActivity));
            //const int pendingIntentId = 0;
            //PendingIntent pendingIntent =
            //    PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.OneShot);

            Notification.Builder builder = new Notification.Builder(this);
            //builder.SetContentIntent(pendingIntent);
            builder.SetPriority((int)NotificationPriority.High);
            builder.SetContentTitle("์•Œ๋ ค๋“œ๋ฆฝ๋‹ˆ๋‹ค!!");
            builder.SetContentText("Hello World! This is my first notification!");
            builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate | NotificationDefaults.Lights);
            builder.SetSmallIcon(Resource.Drawable.Icon);
            Notification noti = builder.Build();

            // Build the notification:
            Notification        notification = builder.Build();
            NotificationManager manager      = GetSystemService(Context.NotificationService) as NotificationManager;

            manager.Notify(101, noti);
        }
Example #37
0
        /// <summary>
        /// ๅ‰ๅฐ้€š็Ÿฅ๏ผš้ฟๅ…่ขซๆ€
        /// </summary>
        /// <param name="text"></param>
        void ServerNotification(string text)
        {
            PendingIntent pendingIntent = PendingIntent.GetActivity(Application.Context, 0, _intent, 0);

            Notification.Builder builder = new Notification.Builder(Application.Context).SetContentIntent(pendingIntent);
            builder.SetAutoCancel(false).SetContentTitle("Alarmๅฎšๆ—ถไปปๅŠก").SetContentText(text);
            builder.SetSmallIcon(Resource.Drawable.notification_template_icon_bg);

            notification = builder.Build();
            //_nm.Notify(1,notification);
            StartForeground(99999, notification);
            SetForeground(true);
        }
Example #38
0
        private void SendNotification(string title, string text, int resourceIconId)
        {
            Notification.Builder notificationBuilder = new Notification.Builder(this);
            notificationBuilder.SetContentTitle(title);
            notificationBuilder.SetContentText(text);
            notificationBuilder.SetSmallIcon(resourceIconId);

            Notification notification = notificationBuilder.Build();

            NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

            notificationManager.Notify(++internalNotificationId, notification);
        }
        public void SentNotificationForReading(List <Customer> countะotifyReadingustomers)
        {
            if (countะotifyReadingustomers.Count > 0)
            {
                // Set up an intent so that tapping the notifications returns to this app:
                Intent intent = new Intent(this, typeof(MainActivity));

                // Create a PendingIntent;
                const int     pendingIntentId = 2;
                PendingIntent pendingIntent   =
                    PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.CancelCurrent);


                // Instantiate the Inbox style:
                Notification.InboxStyle inboxStyle = new Notification.InboxStyle();

                //  Instantiate the builder and set notification elements:
                Notification.Builder bulideer = new Notification.Builder(this);

                bulideer.SetSmallIcon(Resource.Drawable.vik);
                bulideer.SetContentIntent(pendingIntent);

                // Set the title and text of the notification:
                bulideer.SetContentTitle("ะ”ะตะฝ ะฝะฐ ะพั‚ั‡ะธั‚ะฐะฝะต");

                foreach (var cus in countะotifyReadingustomers)
                {
                    // Generate a message summary for the body of the notification:
                    string format = "dd.MM.yyyy";
                    string date   = cus.StartReportDate.ToString(format);

                    inboxStyle.AddLine($"ะะฑ. ะฝะพะผะตั€: {cus.Nomer.ToString()}, {date}");

                    bulideer.SetContentText($"ะะฑ. ะฝะพะผะตั€: {cus.Nomer.ToString()}, {date}");
                }

                // Plug this style into the builder:
                bulideer.SetStyle(inboxStyle);

                // Build the notification:
                Notification notification11 = bulideer.Build();

                // Get the notification manager:
                NotificationManager notificationManager1 =
                    GetSystemService(Context.NotificationService) as NotificationManager;

                // Publish the notification:
                const int notificationIdd = 2;
                notificationManager1.Notify(notificationIdd, notification11);
            }
        }
        private void WClient_UploadFileCompleted(object sender, System.Net.UploadFileCompletedEventArgs e)
        {
            timer.Stop();
            timer.Dispose();

            notificationManager.Cancel(notificationID);

            notificationID      = new Random().Next(10000, 99999);
            notificationBuilder = new Notification.Builder(ApplicationContext);
            notificationBuilder.SetOngoing(false)
            .SetSmallIcon(Resource.Drawable.icon);

            if (e.Cancelled == false && e.Error == null)
            {
                JsonResult result = JsonConvert.DeserializeObject <JsonResult>(System.Text.Encoding.UTF8.GetString(e.Result));

                if (result != null && result.Success == true)
                {
                    notificationBuilder.SetContentTitle("Upload complete");
                }
                else
                if (result.Success == false)
                {
                    notificationBuilder.SetContentTitle("Upload failed");
                    Intent        notificationIntent = new Intent(ApplicationContext, typeof(UploadErrorActivity));
                    PendingIntent contentIntent      = PendingIntent.GetActivity(ApplicationContext,
                                                                                 0, notificationIntent, PendingIntentFlags.UpdateCurrent);
                    notificationBuilder.SetContentIntent(contentIntent);
                    notificationBuilder.SetContentText(result.Message);
                    notificationBuilder.SetAutoCancel(true);
                }
            }
            else
            {
                notificationBuilder.SetContentTitle("Upload failed");
            }

            notification = notificationBuilder.Build();
            notificationManager.Notify(notificationID, notification);

            notificationID = 0;

            notificationBuilder.Dispose();
            notification.Dispose();
            notificationManager.Dispose();

            uploadedBytes   = 0;
            totalBytes      = 0;
            percentComplete = 0;
            wClient.Dispose();
        }
        private void SentNotificationForOverdue(List <Customer> countะotifyInvoiceOverdueCustomers)
        {
            if (countะotifyInvoiceOverdueCustomers.Count > 0)
            {
                string countะotifyInvoiceOverdueCustomersAsString = JsonConvert.SerializeObject(countะotifyInvoiceOverdueCustomers);

                // Set up an intent so that tapping the notifications returns to this app:
                Intent intent = new Intent(this, typeof(MainActivity));

                // Create a PendingIntent;
                const int     pendingIntentId = 0;
                PendingIntent pendingIntent   =
                    PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.OneShot);

                // Instantiate the Inbox style:
                Notification.InboxStyle inboxStyle = new Notification.InboxStyle();

                //  Instantiate the builder and set notification elements:
                Notification.Builder bulideer = new Notification.Builder(this)
                                                .SetContentIntent(pendingIntent)
                                                .SetSmallIcon(Resource.Drawable.vik);

                // Set the title and text of the notification:
                bulideer.SetContentTitle("ะŸั€ะพัั€ะพั‡ะฒะฐะฝะต");

                foreach (var item in countะotifyInvoiceOverdueCustomers)
                {
                    // Generate a message summary for the body of the notification:

                    string format = "dd.MM.yyyy";
                    string date   = item.EndPayDate.ToString(format);

                    inboxStyle.AddLine($"ะะฑ. ะฝะพะผะตั€: {item.Nomer.ToString()}, {date}");

                    bulideer.SetContentText($"ะะฑ. ะฝะพะผะตั€: {item.Nomer.ToString()}, {date}");
                }
                // Plug this style into the builder:
                bulideer.SetStyle(inboxStyle);

                // Build the notification:
                Notification notification11 = bulideer.Build();

                // Get the notification manager:
                NotificationManager notificationManager1 =
                    GetSystemService(Context.NotificationService) as NotificationManager;

                // Publish the notification:
                const int notificationIdd = 0;
                notificationManager1.Notify(notificationIdd, notification11);
            }
        }
        public void SendNotification(CorsoGiornaliero l)
        {
            if (!Settings.Notify)
            {
                return;
            }
            //			Logcat.Write("SEND NOTIFICATION");

            Logcat.Write("Creazione Notifica");
            Logcat.WriteDB(_db, "Creazione notifica");
            Logcat.WriteDB(_db, l.Note.ToUpper() + l.Insegnamento + " - " + l.Date.ToShortDateString() + " - " + l.Ora);

            // Set up an intent so that tapping the notifications returns to this app:
            var context = Android.App.Application.Context;
            //var context = Forms.Context;

            Intent intent = new Intent(context, typeof(MainActivity));

            Logcat.WriteDB(_db, "Intent created");
            // Create a PendingIntent; we're only using one PendingIntent (ID = 0):
            const int     pendingIntentId = 0;
            PendingIntent pendingIntent   = PendingIntent.GetActivity(context, pendingIntentId, intent, PendingIntentFlags.UpdateCurrent);

            Logcat.WriteDB(_db, "PendingIntent created");
            Notification.Builder builder = new Notification.Builder(context)
                                           .SetContentIntent(pendingIntent)
                                           .SetContentTitle(l.Note.ToUpper())
                                           .SetContentText(l.Insegnamento + " - " + l.Date.ToShortDateString() + " - " + l.Ora)
                                           .SetSmallIcon(Resource.Drawable.ic_notification_school)
                                           .SetAutoCancel(true);
            //builder.SetStyle(new Notification.BigTextStyle().BigText(longMess));

            Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
            inboxStyle.AddLine(l.Insegnamento);
            inboxStyle.AddLine(l.Date.DayOfWeek + ", " + l.Date.ToShortDateString());
            inboxStyle.AddLine(l.AulaOra);
            inboxStyle.AddLine(l.Docente);
            builder.SetStyle(inboxStyle);

            // Build the notification:
            Notification notification = builder.Build();

            // Get the notification manager:
            NotificationManager notificationManager = context.GetSystemService(Context.NotificationService) as NotificationManager;

            // Publish the notification:
            // const int notificationId = 1;
            var rnd = new System.Random();

            notificationManager.Notify(rnd.Next(), notification);
        }
Example #43
0
        protected override void OnMessage(Context context, Intent intent)
        {
            Log.Info(MyBroadcastReceiver.TAG, "GCM Message Received!");



            var msg = new StringBuilder();

            if (intent != null && intent.Extras != null)
            {
                foreach (var key in intent.Extras.KeySet())
                {
                    msg.AppendLine(key + "=" + intent.Extras.Get(key).ToString());
                }
            }

            string messageText = intent.Extras.GetString("message");

            if (!string.IsNullOrEmpty(messageText))
            {
                Intent startupIntent = new Intent(this, typeof(SplashActivity));

                TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);

                stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(SplashActivity)));

                stackBuilder.AddNextIntent(startupIntent);

                const int     pendingIntentId = 0;
                PendingIntent pendingIntent   =
                    stackBuilder.GetPendingIntent(pendingIntentId, PendingIntentFlags.OneShot);



                Notification.Builder builder = new Notification.Builder(context).SetContentTitle("India Tech Community")
                                               .SetContentText(messageText)
                                               .SetDefaults(NotificationDefaults.Sound)
                                               .SetSmallIcon(Resource.Drawable.NotificationIcon)
                                               .SetContentIntent(pendingIntent)
                                               .SetAutoCancel(true);

                // Build the notification:
                Notification notification = builder.Build();

                // Get the notification manager:
                NotificationManager notificationManager =
                    context.GetSystemService(Context.NotificationService) as NotificationManager;

                notificationManager.Notify(0, notification);
            }
        }
Example #44
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var    ValidateButton = FindViewById <Button>(Resource.Id.ValidateButton);
            var    ResultView     = FindViewById <TextView>(Resource.Id.ResultView);
            var    EmailText      = FindViewById <EditText>(Resource.Id.EmailText);
            var    PasswordText   = FindViewById <EditText>(Resource.Id.PasswordText);
            string EMail;
            string Password;
            string Device = Android.Provider.Settings.Secure.GetString(
                ContentResolver, Android.Provider.Settings.Secure.AndroidId);

            ValidateButton.Click += (sender, e) =>
            {
                EMail    = EmailText.Text;
                Password = PasswordText.Text;
                Validate();
            };

            async void Validate()
            {
                string Result;

                var ServiceClient = new SALLab07.ServiceClient();
                var SvcResult     = await ServiceClient.ValidateAsync(EMail, Password, Device);

                Result = $"{SvcResult.Status}\n{SvcResult.Fullname}\n{SvcResult.Token}";

                if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                {
                    var Builder = new Notification.Builder(this)
                                  .SetContentTitle("Validaciรณn de actividad")
                                  .SetContentText(Result)
                                  .SetSmallIcon(Resource.Drawable.Icon);
                    Builder.SetCategory(Notification.CategoryMessage);
                    var ObjectNotification = Builder.Build();
                    var Manager            = GetSystemService(
                        Android.Content.Context.NotificationService) as NotificationManager;
                    Manager.Notify(0, ObjectNotification);
                }
                else
                {
                    ResultView.Text = Result;
                }
            }
        }
        private void SentNoficationForNewInovoice(List <Customer> countNewะotifyNewInvoiceCustomers)
        {
            if (countNewะotifyNewInvoiceCustomers.Count > 0)
            {
                // Set up an intent so that tapping the notifications returns to this app:
                Intent intent = new Intent(this, typeof(MainActivity));

                // Create a PendingIntent;
                const int     pendingIntentId = 1;
                PendingIntent pendingIntent   =
                    PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.OneShot);


                // Instantiate the Inbox style:
                Notification.InboxStyle inboxStyle = new Notification.InboxStyle();

                //  Instantiate the builder and set notification elements:
                Notification.Builder bulideer = new Notification.Builder(this)
                                                .SetContentIntent(pendingIntent)
                                                .SetSmallIcon(Resource.Drawable.vik);

                // Set the title and text of the notification:
                bulideer.SetContentTitle("ะะพะฒะฐ ั„ะฐะบั‚ัƒั€ะฐ");
                //  bulideer.SetContentText("*****@*****.**");

                foreach (var item in countNewะotifyNewInvoiceCustomers)
                {
                    // Generate a message summary for the body of the notification:

                    string money = item.MoneyToPay.ToString("C", System.Globalization.CultureInfo.GetCultureInfo("bg-BG"));

                    inboxStyle.AddLine($"ะะฑ. ะฝะพะผะตั€: {item.Nomer.ToString()}, {money}");

                    bulideer.SetContentText($"ะะฑ. ะฝะพะผะตั€: {item.Nomer.ToString()}, {money}");
                }
                // Plug this style into the builder:
                bulideer.SetStyle(inboxStyle);

                // Build the notification:
                Notification notification11 = bulideer.Build();

                // Get the notification manager:
                NotificationManager notificationManager1 =
                    GetSystemService(Context.NotificationService) as NotificationManager;

                // Publish the notification:
                const int notificationIdd = 1;
                notificationManager1.Notify(notificationIdd, notification11);
            }
        }
Example #46
0
        void SendNotification(string message)
        {
            var intent = new Intent(this, typeof(MainActivity));
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);

            var notificationBuilder = new Notification.Builder(this)
                                                      .SetContentTitle(TITLE)
                                                      .SetContentText(message)
                                                      .SetSmallIcon(Resource.Drawable.icon)
                                                      .SetContentIntent(pendingIntent);

            var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
            notificationManager.Notify(0, notificationBuilder.Build());
        }
Example #47
0
        /// <summary>
        /// Show a local notification in the Notification Area and Drawer.
        /// </summary>
        /// <param name="title">Title of the notification</param>
        /// <param name="body">Body or description of the notification</param>
        public void Show(string title, string body)
        {
            var builder = new Notification.Builder(Application.Context);

            builder.SetContentTitle(title);
            builder.SetContentText(body);
            builder.SetSmallIcon(Resource.Drawable.Icon);

            var notification = builder.Build();

            var manager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager;

            manager.Notify(0, notification);
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			// Get our button from the layout resource,
			// and attach an event to it
			Button button = FindViewById<Button> (Resource.Id.myButton);
			Button button1 = FindViewById<Button> (Resource.Id.button1);

			// Instantiate the builder and set notification elements:
			builder = new Notification.Builder (this)
				.SetContentTitle ("Test")
				.SetContentText ("This is test")
				.SetSmallIcon (Resource.Drawable.Icon);

			// Build the notification:
			notification = builder.Build ();

			// Get the notification manager:
			notificationManger = GetSystemService (Context.NotificationService) as NotificationManager;

			const int notificationId = 0;

			button.Click += delegate {
				// Publish the notification:
				notificationManger.Notify (notificationId,notification);
				button.Text = string.Format ("{0} clicks!", count++);
			};

			button1.Click += delegate {
				builder = new Notification.Builder (this)
					.SetContentTitle ("Updated Test")
					.SetContentText ("This is updated test")
					.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate)
					.SetSmallIcon (Resource.Drawable.Icon);

				// Build the notification:
				notification = builder.Build ();

				// Publish the notification:
				notificationManger.Notify (notificationId,notification);

				button.Text = string.Format ("{0} clicks!", count++);
			};
		}
Example #49
0
        //Notifications:
        private void notifyUser(String title, String message)
        {
            Notification.Builder builder = new Notification.Builder (activity)
                .SetContentTitle (title)

                .SetSubText (message)
                .SetContentText ("You will not be notified of leaving a region.");

            builder.SetSmallIcon (Resource.Drawable.green_button);
            builder.SetSound (Android.Media.RingtoneManager.GetDefaultUri (Android.Media.RingtoneType.Notification));
            Notification notification = builder.Build();

            NotificationManager notificationManager = activity.GetSystemService (Context.NotificationService) as NotificationManager;
            const int notificationId = 0;
            notificationManager.Notify (notificationId, notification);
        }
		void BuildWearableOnlyNotification (string title, string content, bool withDismissal)
		{
			var builder = new Notification.Builder (this)
				.SetSmallIcon (Resource.Drawable.ic_launcher)
				.SetContentTitle (title)
				.SetContentText (content);

			if (withDismissal) {
				var dismissIntent = new Intent (Constants.ActionDismiss);
				dismissIntent.PutExtra (Constants.KeyNotificationId, Constants.BothId);
				PendingIntent pendingIntent = PendingIntent.GetService (this, 0, dismissIntent, PendingIntentFlags.UpdateCurrent);
				builder.SetDeleteIntent (pendingIntent);
			}

			((NotificationManager)GetSystemService (NotificationService)).Notify (Constants.WatchOnlyId, builder.Build ());
		}
        // Use Notification Builder to create and launch the notification:
        void SendNotification (string message)
        {
            var intent = new Intent (this, typeof(MainActivity));
            intent.AddFlags (ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);

            var notificationBuilder = new Notification.Builder (this)
                .SetSmallIcon (Resource.Drawable.ic_stat_ic_notification)
                .SetContentTitle ("GCM Message")
                .SetContentText (message)
                .SetAutoCancel (true)
                .SetContentIntent (pendingIntent);

            var notificationManager = (NotificationManager)GetSystemService (Context.NotificationService);
            notificationManager.Notify (0, notificationBuilder.Build ());
        }
        public void Notify(string title, string description, string soundLocation, int id)
        {
            Android.Net.Uri sound = Android.Net.Uri.Parse(soundLocation);

            Notification.Builder builder = new Notification.Builder (Application.Context)
                .SetContentTitle (title)
                .SetContentText (description)
                .SetSound(sound)
                //.SetLights
                .SetSmallIcon (Resource.Drawable.icon);

            Notification notification = builder.Build();
            NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager;

            const int notificationId = 0;
            notificationManager.Notify(notificationId, notification);
        }
        public static void ShowNotification(Context context, string contentTitle,
                string contentText)
        {
            // Intent
            Notification.Builder builder = new Notification.Builder(context)
                .SetContentTitle(contentTitle)
                .SetContentText(contentText)
                .SetDefaults(NotificationDefaults.Sound|NotificationDefaults.Vibrate)
                .SetSmallIcon(Resource.Drawable.Icon)
                .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification));

            // Get the notification manager:
            NotificationManager notificationManager =
                context.GetSystemService(Context.NotificationService) as NotificationManager;

            notificationManager.Notify(1001, builder.Build());
        }
        void SendNotification(string message)
        {
            var intent = new Intent(this, typeof(MainActivity));
            intent.AddFlags(ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
            var defaultSoundUri = RingtoneManager.GetDefaultUri(RingtoneType.Notification);
            var notificationBuilder = new Notification.Builder(this)
                .SetSmallIcon(Resource.Drawable.ic_plusone_small_off_client)
                .SetContentTitle("GCM Message")
                .SetContentText(message)
                .SetAutoCancel(true)
                .SetSound(defaultSoundUri)
                .SetContentIntent(pendingIntent);

            var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
            notificationManager.Notify(0, notificationBuilder.Build());
        }
Example #55
0
        void DisplaySubscribeReturnMessage(string result)
        {
            Console.WriteLine("SUBSCRIBE REGULAR CALLBACK: ");
            Console.WriteLine(result);

            if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(result.Trim()))
            {
                List<object> deserializedMessage = pubnub.JsonPluggableLibrary.DeserializeToListOfObject(result);
                if (deserializedMessage != null && deserializedMessage.Count > 0)
                {
                    object subscribedObject = (object)deserializedMessage[0];
                    if (subscribedObject != null)
                    {
                        //IF CUSTOM OBJECT IS EXCEPTED, YOU CAN CAST THIS OBJECT TO YOUR CUSTOM CLASS TYPE
                        string resultActualMessage = pubnub.JsonPluggableLibrary.SerializeToJsonString(subscribedObject);
                        string re = resultActualMessage.Replace('"', ' ');
                        string s1 = re.Substring(1, re.IndexOf(',') - 1);
                        string s2 = re.Substring((re.IndexOf(',') + 1));



                        Notification.Builder builder = new Notification.Builder(this)
                        .SetContentTitle(s1)
                        .SetContentText(s2)
                        .SetPriority(2)
                        .SetColor(2)
                        .SetVibrate(new long[1])
                        .SetSmallIcon(Resource.Drawable.Icon);

                        // Build the notification:
                        Notification notification = builder.Build();

                        // Get the notification manager:
                        NotificationManager notificationManager =
                            GetSystemService(Context.NotificationService) as NotificationManager;

                        // Publish the notification:
                        const int notificationId = 0;
                        notificationManager.Notify(notificationId, notification);


                    }
                }
            }
        }
Example #56
0
        void SendNotification(string message)
        {
            var postData = message.Split(';');
            var intent = new Intent(this, typeof(MainActivity));
            intent.SetData(Android.Net.Uri.Parse(postData[1]));
            intent.AddFlags(ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);

            var notificationBuilder = new Notification.Builder(this)
                .SetSmallIcon(Resource.Drawable.icon_notification)
                .SetContentTitle("C'รจ un nuovo articolo su SmartReport")
                .SetContentText(postData[0])
                .SetAutoCancel(true)
                .SetContentIntent(pendingIntent);

            var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
            notificationManager.Notify(0, notificationBuilder.Build());
        }
Example #57
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            txtView = (TextView)FindViewById(Resource.Id.tbNotificationInfo);
            //txtView = (TextView)FindViewById(Resource.Id.textView1);
            nReceiver = new NotificationReceiver();
            IntentFilter filter = new IntentFilter();
            filter.AddAction("com.dpwebdev.handsetfree.NOTIFICATION_LISTENER_EXAMPLE");
            RegisterReceiver(nReceiver, filter);

            // Get our button from the layout resource,
            // and attach an event to it
            Button createButton = FindViewById<Button>(Resource.Id.MyButton);
            Button catchButton = FindViewById<Button>(Resource.Id.catchNotification);

            createButton.Click += delegate
            {
                NotificationManager nManager = (NotificationManager)GetSystemService(NotificationListenerService.NotificationService);
                Notification.Builder ncomp = new Notification.Builder(this);
                ncomp.SetContentTitle("My Notification");
                ncomp.SetContentText("Notification Listener Service Example");
                ncomp.SetTicker("Notification Listener Service Example");
                ncomp.SetSmallIcon(Resource.Drawable.Icon);
                ncomp.SetAutoCancel(true);
                nManager.Notify(DateTime.Now.Millisecond, ncomp.Build());

                

            };

            catchButton.Click += delegate
            {
                
                Intent i = new Intent("com.dpwebdev.handsetfree.NOTIFICATION_LISTENER_SERVICE_EXAMPLE");
                i.PutExtra("command", "list");
                SendBroadcast(i);
            };

        }
        void SendNotification(string message)
        {
            var intent = new Intent(this, typeof(RecentEventsActivity));
            intent.AddFlags(ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);

            var notificationBuilder = new Notification.Builder(this)
                .SetSmallIcon(Resource.Drawable.ITWCIPLogo)
                .SetContentTitle("New Event")
                .SetContentText(message)
                .SetAutoCancel(true)
                .SetPriority(2)
                .SetVibrate(new long[] {1000, 1000})
                .SetSound(Settings.System.DefaultNotificationUri)
                .SetContentIntent(pendingIntent);

            var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
            notificationManager.Notify(0, notificationBuilder.Build());
        }
Example #59
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it

            // Set up an intent so that tapping the notifications returns to this app:
            /*Intent intent = new Intent (this, typeof(MainActivity));

                // Create a PendingIntent; we're only using one PendingIntent (ID = 0):
                const int pendingIntentId = 0;
                PendingIntent pendingIntent =
                    PendingIntent.GetActivity (this, pendingIntentId, intent, PendingIntentFlags.OneShot);
                */
            // Instantiate the builder and set notification elements, including pending intent:
            Notification.Builder builder = new Notification.Builder(this)
                //.SetContentIntent (pendingIntent)
                .SetContentTitle ("Sample Notification")
                .SetContentText ("Hello World! This is my first action notification!")
                .SetDefaults (NotificationDefaults.Sound)
                .SetSmallIcon (Resource.Drawable.Icon);

            // Build the notification:
            Notification notification = builder.Build();

            // Get the notification manager:
            NotificationManager notificationManager =
                GetSystemService (Context.NotificationService) as NotificationManager;

            // Publish the notification:
            const int notificationId = 0;
            notificationManager.Notify (notificationId, notification);

            Button button = FindViewById<Button> (Resource.Id.myButton);

            button.Click += delegate {

            };
        }
		// Creates a new notification depending on makeHeadsUpNotification.
		// If makeHeadsUpNotification is true, the notifications will be
		// Heads-Up Notifications.
		public Notification CreateNotification(bool makeHeadsUpNotification)
		{
			var builder = new Notification.Builder (Activity)
				.SetSmallIcon (Resource.Drawable.ic_launcher_notification)
				.SetPriority ((int) NotificationPriority.Default)
				.SetCategory (Notification.CategoryMessage)
				.SetContentTitle ("Sample Notification")
				.SetContentText ("This is a normal notification.");
			if (makeHeadsUpNotification) {
				var push = new Intent ();
				push.AddFlags (ActivityFlags.NewTask);
				push.SetClass (Activity, Java.Lang.Class.FromType (typeof(MainActivity)));
				var fullScreenPendingIntent = PendingIntent.GetActivity (Activity, 0,
					push, PendingIntentFlags.CancelCurrent);
				builder
					.SetContentText ("Heads-Up Notification on Android L or above.")
					.SetFullScreenIntent (fullScreenPendingIntent, true);
			}
			return builder.Build ();
		}