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);
}
}
추신 : 여기 내 코드입니다 iOS 11 에뮬레이터를 사용하고 있습니다.