public override void OnReceive(Context context, Intent intent) { IDictionary <string, object> parameters = new Dictionary <string, object>(); var extras = intent.Extras; if (extras != null && !extras.IsEmpty) { foreach (var key in extras.KeySet()) { parameters.Add(key, $"{extras.Get(key)}"); System.Diagnostics.Debug.WriteLine(key, $"{extras.Get(key)}"); } } var reply = RemoteInput.GetResultsFromIntent(intent)?.GetString("Result"); PushNotificationManager.RegisterAction(parameters, reply); NotificationManager manager = context.GetSystemService(Context.NotificationService) as NotificationManager; var notificationId = extras.GetInt(DefaultPushNotificationHandler.ActionNotificationIdKey, -1); if (notificationId != -1) { var notificationTag = extras.GetString(DefaultPushNotificationHandler.ActionNotificationTagKey, string.Empty); if (notificationTag == null) { manager.Cancel(notificationId); } else { manager.Cancel(notificationTag, notificationId); } } }
private string GetMessageText(Intent intent) { Bundle remoteInput = RemoteInput.GetResultsFromIntent(intent); if (remoteInput != null) { return(remoteInput.GetCharSequence(EXTRA_VOICE_REPLY)); } return(null); }
public PushNotificationResponse?FromIntent(Intent intent) { if (!intent.HasExtra(INTENT_KEY)) { return(null); } var notificationString = intent.GetStringExtra(INTENT_KEY); var notification = this.Services.Serializer.Deserialize <Shiny.Notifications.Notification>(notificationString); var action = intent.GetStringExtra(ShinyPushNotificationBroadcastReceiver.EntryIntentAction); var text = RemoteInput.GetResultsFromIntent(intent)?.GetString("Result"); var response = new PushNotificationResponse(notification, action, text); return(response); }
public async Task TryProcessIntent(Intent?intent) { if (intent == null || !this.delegates.Any()) { return; } if (intent.HasExtra(IntentNotificationKey)) { var notificationString = intent.GetStringExtra(IntentNotificationKey); var notification = this.serializer.Deserialize <Notification>(notificationString); var action = intent.GetStringExtra(IntentActionKey); var text = RemoteInput.GetResultsFromIntent(intent)?.GetString("Result"); var response = new NotificationResponse(notification, action, text); // the notification lives within the intent since it has already been removed from the repo await this.delegates.RunDelegates(x => x.OnEntry(response)); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.Settings); using (toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar)) { SetSupportActionBar(toolbar); SupportActionBar.SetDefaultDisplayHomeAsUpEnabled(true); } if (Build.VERSION.SdkInt > BuildVersionCodes.Kitkat) { Bundle remoteInput = RemoteInput.GetResultsFromIntent(Intent); if (remoteInput != null) { string response = remoteInput.GetCharSequence("test1"); Toast.MakeText(this, "The response is: " + response, ToastLength.Long).Show(); } } }
/// <summary> /// Get the message text from the intent. /// Note that you should call <see cref="Android.Support.V4.App.RemoteInput.GetResultsFromIntent(intent)"/> /// to process the RemoteInput. /// </summary> /// <returns>The message text.</returns> /// <param name="intent">Intent.</param> static string GetMessageText(Intent intent) { Bundle remoteInput = RemoteInput.GetResultsFromIntent(intent); return(remoteInput != null?remoteInput.GetCharSequence(MessagingService.EXTRA_VOICE_REPLY) : null); }