Example #1
0
 public override Android.App.Notification BuildNotification(string alert, IDictionary <string, string> extras)
 {
     if (extras != null && RichPushManager.IsRichPushMessage(extras))
     {
         return(CreateInboxNotification(alert));
     }
     else
     {
         return(base.BuildNotification(alert, extras));
     }
 }
        private const long WIDGET_REFRESH_DELAY_MS = 5000;         //5 Seconds


        public override void OnReceive(Context context, Intent intent)
        {
            // Refresh the widget after a push comes in
            if (PushManager.ActionPushReceived == intent.Action)
            {
                RichPushWidgetUtils.RefreshWidget(context, WIDGET_REFRESH_DELAY_MS);
            }

            // Only takes action when a notification is opened
            if (PushManager.ActionNotificationOpened != intent.Action)
            {
                return;
            }

            // Ignore any non rich push notifications
            if (!RichPushManager.IsRichPushMessage(intent.Extras))
            {
                return;
            }

            string messageId = intent.GetStringExtra(EXTRA_MESSAGE_ID_KEY);

            Logger.Debug("Notified of a notification opened with id " + messageId);

            Intent messageIntent = null;

            // Set the activity to receive the intent
            if ("home" == intent.GetStringExtra(ACTIVITY_NAME_KEY))
            {
                messageIntent = new Intent(context, typeof(MainActivity));
            }
            else
            {
                // default to the Inbox
                messageIntent = new Intent(context, typeof(InboxActivity));
            }

            messageIntent.PutExtra(RichPushApplication.MESSAGE_ID_RECEIVED_KEY, messageId);
            messageIntent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop | ActivityFlags.NewTask);
            context.StartActivity(messageIntent);
        }