【发布时间】:2020-01-25 20:17:10
【问题描述】:
我的应用收到通知并显示本地User Notification。
当用户关闭此应用并点击此本地通知时。
我想处理打开这个本地通知的事件。
我尝试了以下链接:
Handle local notification tap Xamarin Forms iOS
但是方法 ReceivedLocalNotification() 似乎不起作用(我尝试显示警报,但没有显示警报。)
我尝试在方法 DidReceiveRemoteNotification()
中显示警报类似于Xamarin.iOS - Red & Green Notifications 示例,但我无法处理“应用程序关闭时用户单击本地通知”事件。
这是我的代码:
[Export("userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:")]
public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, System.Action completionHandler)
{
// Show Alert
var alert = new UIAlertView()
{
Title = "LocalNotification",
Message = $"Content: Method DidReceiveNotificationResponse()"
};
alert.AddButton("OK");
alert.Show();
if (response.IsDefaultAction)
{
Console.WriteLine("ACTION: Default");
}
if (response.IsDismissAction)
{
Console.WriteLine("ACTION: Dismiss");
}
else
{
Console.WriteLine($"ACTION: {response.ActionIdentifier}");
}
completionHandler();
}
请帮帮我!
如何处理“应用关闭时用户点击本地通知”事件? 我正在 ios 12.4 和 ios 13.0 上进行测试。
【问题讨论】:
标签: xamarin xamarin.forms xamarin.ios