0
我需要在iOS中的本地通知中显示动作按钮。我收到通知,但没有任何操作按钮。你能指导我做错了什么吗? 这是我的代码:Xamarin形成iOS本地通知按钮
var category = new UIMutableUserNotificationCategory();
var okAction = new UIMutableUserNotificationAction
{
Identifier = "ok",
Destructive = false,
Title = "OK",
ActivationMode = UIUserNotificationActivationMode.Background,
AuthenticationRequired = false
};
var delayAction = new UIMutableUserNotificationAction
{
Identifier = "delay",
Destructive = false,
Title = "Отложить",
ActivationMode = UIUserNotificationActivationMode.Background,
AuthenticationRequired = false
};
var categoryIdentifier = "pills.category";
category.Identifier = categoryIdentifier;
category.SetActions(new UIUserNotificationAction[] { delayAction, okAction }, UIUserNotificationActionContext.Minimal);
category.SetActions(new UIUserNotificationAction[] { delayAction, okAction }, UIUserNotificationActionContext.Default);
var categories = new NSSet(new NSObject[] {category});
var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, categories
);
UIApplication.SharedApplication.RegisterUserNotificationSettings(notificationSettings);
var next = new TimeSpan(start.Ticks);
var count = Math.Round(24.0/interval.TotalHours);
for (int i = 0; i < count; i++)
{
var notification = new UILocalNotification
{
AlertAction = title,
AlertBody = text,
SoundName = UILocalNotification.DefaultSoundName,
ApplicationIconBadgeNumber = 0,
FireDate = NSDate.FromTimeIntervalSinceNow(next.TotalSeconds),
RepeatInterval = NSCalendarUnit.Day,
Category = categoryIdentifier
};
UIApplication.SharedApplication.ScheduleLocalNotification(notification);
next = next.Add(interval);
}
}
P.S.我正在使用iOS 11模拟器。