Ios 目标C中的交互式通知
我想用两个按钮来实现交互式通知。我必须在哪里创建按钮及其操作 我已经这样做了,但是从哪里调用这个方法呢Ios 目标C中的交互式通知,ios,objective-c,xcode,push-notification,Ios,Objective C,Xcode,Push Notification,我想用两个按钮来实现交互式通知。我必须在哪里创建按钮及其操作 我已经这样做了,但是从哪里调用这个方法呢 - (void)registerForNotification { UIMutableUserNotificationAction *action1; action1 = [[UIMutableUserNotificationAction alloc] init]; [action1 setActivationMode:UIUserNotificationActivat
- (void)registerForNotification
{
UIMutableUserNotificationAction *action1;
action1 = [[UIMutableUserNotificationAction alloc] init];
[action1 setActivationMode:UIUserNotificationActivationModeBackground];
[action1 setTitle:@"Action 1"];
[action1 setIdentifier:NotificationActionOneIdent];
[action1 setDestructive:NO];
[action1 setAuthenticationRequired:NO];
UIMutableUserNotificationAction *action2;
action2 = [[UIMutableUserNotificationAction alloc] init];
[action2 setActivationMode:UIUserNotificationActivationModeBackground];
[action2 setTitle:@"Action 2"];
[action2 setIdentifier:NotificationActionTwoIdent];
[action2 setDestructive:NO];
[action2 setAuthenticationRequired:NO];
UIMutableUserNotificationCategory *actionCategory;
actionCategory = [[UIMutableUserNotificationCategory alloc] init];
[actionCategory setIdentifier:NotificationCategoryIdent];
[actionCategory setActions:@[action1, action2]
forContext:UIUserNotificationActionContextDefault];
NSSet *categories = [NSSet setWithObject:actionCategory];
UIUserNotificationType types = (UIUserNotificationTypeAlert|
UIUserNotificationTypeSound|
UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings;
settings = [UIUserNotificationSettings settingsForTypes:types
categories:categories];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}
处理通知
func application(application: UIApplication, handleActionWithIdentifier identifier: String?,
forLocalNotification notification: UILocalNotification, completionHandler: () -> Void) {
completionHandler()
}
处理通知
func application(application: UIApplication, handleActionWithIdentifier identifier: String?,
forLocalNotification notification: UILocalNotification, completionHandler: () -> Void) {
completionHandler()
}
在AppDelegate中的didFinishLaunchingWithOptions方法中调用此函数。你不需要做别的事。
要处理这些操作,请调用处理程序。在AppDelegate中的didFinishLaunchingWithOptions方法中调用此函数。你不需要做别的事。
要处理这些操作,请调用处理程序。如果要检查本地通知,请使用此命令
-(void)localnotificationGenrated
{
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.soundName = @"Default";
localNotification.alertBody = @"my notification;)";
localNotification.fireDate = [NSDate date];
localNotification.category = NotificationActionOneIdent;
localNotification.repeatInterval = kCFCalendarUnitMinute;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
如果需要推送通知,请使用类别创建有效负载
像这样
{"aps":{"alert":"Hello Testing","badge":1,"sound":"default","category":"your_category_key"}}
并调用您的方法
- (void)registerForNotification
在
如果您想检查本地通知,请使用此选项
-(void)localnotificationGenrated
{
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.soundName = @"Default";
localNotification.alertBody = @"my notification;)";
localNotification.fireDate = [NSDate date];
localNotification.category = NotificationActionOneIdent;
localNotification.repeatInterval = kCFCalendarUnitMinute;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
如果需要推送通知,请使用类别创建有效负载
像这样
{"aps":{"alert":"Hello Testing","badge":1,"sound":"default","category":"your_category_key"}}
并调用您的方法
- (void)registerForNotification
在