关于 Apple Watch 应用程序上的本地通知
About local notifications on Apple watch app
我已经在 ios 应用程序上安排了本地通知,并在 Apple Watch 的静态通知界面上测试了它们。但是,有一个小故障(也许不是?),即使手表应用程序仍在 运行 即在前台(iphone 应用程序在后台并且 iphone 已锁定)。此外,当手表应用程序处于活动状态时,iphone 应用程序处于后台,并且 iphone 未锁定,iphone 正在显示通知。这对我来说真的很奇怪。
我正在安排本地通知如下:
NSString *textToShow = nil;
NSSet *categories = nil;
textToShow = text;
UIMutableUserNotificationAction *notificationAction1 = [[UIMutableUserNotificationAction alloc] init];
notificationAction1.identifier = @"openWKApp";
notificationAction1.title = localStr(@"View");
notificationAction1.activationMode = UIUserNotificationActivationModeForeground;
notificationAction1.destructive = NO;
notificationAction1.authenticationRequired = NO;
UIMutableUserNotificationCategory *notificationCategory = [[UIMutableUserNotificationCategory alloc] init];
notificationCategory.identifier = @"openWKApp";
[notificationCategory setActions:@[notificationAction1] forContext:UIUserNotificationActionContextDefault];
[notificationCategory setActions:@[notificationAction1] forContext:UIUserNotificationActionContextMinimal];
categories = [NSSet setWithObjects:notificationCategory, nil];
UIUserNotificationType notificationType = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:notificationType categories:categories];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
localNotification.alertBody = @"Notification body";
localNotification.applicationIconBadgeNumber = 1;
localNotification.userInfo = info;
localNotification.category = @"openWKApp";
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
如果有人遇到同样的问题并修复或找到解决方法,请帮忙!
取消了 willActivate
的通知,并重新安排了 didDeactivate
的 watchkit。尽管如此,当 watchkit 应用程序 运行.
时收到通知真的很奇怪
我已经在 ios 应用程序上安排了本地通知,并在 Apple Watch 的静态通知界面上测试了它们。但是,有一个小故障(也许不是?),即使手表应用程序仍在 运行 即在前台(iphone 应用程序在后台并且 iphone 已锁定)。此外,当手表应用程序处于活动状态时,iphone 应用程序处于后台,并且 iphone 未锁定,iphone 正在显示通知。这对我来说真的很奇怪。
我正在安排本地通知如下:
NSString *textToShow = nil;
NSSet *categories = nil;
textToShow = text;
UIMutableUserNotificationAction *notificationAction1 = [[UIMutableUserNotificationAction alloc] init];
notificationAction1.identifier = @"openWKApp";
notificationAction1.title = localStr(@"View");
notificationAction1.activationMode = UIUserNotificationActivationModeForeground;
notificationAction1.destructive = NO;
notificationAction1.authenticationRequired = NO;
UIMutableUserNotificationCategory *notificationCategory = [[UIMutableUserNotificationCategory alloc] init];
notificationCategory.identifier = @"openWKApp";
[notificationCategory setActions:@[notificationAction1] forContext:UIUserNotificationActionContextDefault];
[notificationCategory setActions:@[notificationAction1] forContext:UIUserNotificationActionContextMinimal];
categories = [NSSet setWithObjects:notificationCategory, nil];
UIUserNotificationType notificationType = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:notificationType categories:categories];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
localNotification.alertBody = @"Notification body";
localNotification.applicationIconBadgeNumber = 1;
localNotification.userInfo = info;
localNotification.category = @"openWKApp";
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
如果有人遇到同样的问题并修复或找到解决方法,请帮忙!
取消了 willActivate
的通知,并重新安排了 didDeactivate
的 watchkit。尽管如此,当 watchkit 应用程序 运行.