【发布时间】:2020-07-23 10:40:51
【问题描述】:
下面的方法展示了我如何创建通知。我将一个新项目附加到 UserInfo 字典中。
private UNNotificationRequest CreateNotification(Geofence geofence)
{
var content = new UNMutableNotificationContent();
content.Title = "title";
content.Subtitle = "subtitle";
content.Body = "This is the message body of the notification.";
content.Badge = 2;
content.UserInfo.Append(new KeyValuePair<NSObject, NSObject>((NSString)"id", (NSString)"bla"));
var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(1, false);
var request = UNNotificationRequest.FromIdentifier("test1", content, trigger);
return request;
}
问题如下:
public override void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
{
foreach (var item in response.Notification.Request.Content.UserInfo)
{
}
// Inform caller it has been handled
completionHandler();
}
UserInfo 字典始终为空。为什么会这样?我该如何解决?
【问题讨论】:
标签: xamarin.ios localnotification userinfo