在我的应用中,我想同时支持 - Remote Notifications
和Local Notifications
。 Remote Notification
应该有两个操作,允许用户在通知中心与其进行交互。
目前我有这个代码来注册通知。我的问题是我是否需要单独注册本地通知注册,或者本注册过程中已包含本地通知。
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIMutableUserNotificationAction *actionCancel = [[UIMutableUserNotificationAction alloc] init];
[actionCancel setActivationMode:UIUserNotificationActivationModeBackground];
[actionCancel setTitle:@"Cancel"];
[actionCancel setIdentifier:NotificationActionOneIdent];
[actionCancel setDestructive:NO];
[actionCancel setAuthenticationRequired:NO];
UIMutableUserNotificationAction *actionOk = [[UIMutableUserNotificationAction alloc] init];
[actionOk setActivationMode:UIUserNotificationActivationModeBackground];
[actionOk setTitle:@"Ok"];
[actionOk setIdentifier:NotificationActionTwoIdent];
[actionOk setDestructive:NO];
[actionOk setAuthenticationRequired:NO];
UIMutableUserNotificationCategory *actionCategory = [[UIMutableUserNotificationCategory alloc] init];
[actionCategory setIdentifier:NotificationCategoryIdent];
[actionCategory setActions:@[actionCancel, actionOk]
forContext:UIUserNotificationActionContextDefault];
NSSet *categories = [NSSet setWithObject:actionCategory];
UIUserNotificationType types = (UIUserNotificationTypeAlert|
UIUserNotificationTypeSound|
UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings;
settings = [UIUserNotificationSettings settingsForTypes:types
categories:categories];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
答案 0 :(得分:0)
包含本地人,因此您的代码很好