Ich habe viel Zeit damit verbracht, Benachrichtigungen zu testen und kann sie nicht auf meiner Apple Watch erscheinen lassen. Ich kann Benachrichtigungen von anderen Apps erhalten - meine Uhr ist gekoppelt, Do Not Disturbe ist deaktiviert. Lokale Push-Benachrichtigungen erscheinen auf meinem iPhone, aber nicht auf der Apple Watch. Der iPhone-Bildschirm ist gesperrt, wenn die Benachrichtigung eingeht.Lokale Push-Benachrichtigungen erscheinen nicht auf der Apple Watch
ich folgendes tue:
1. Erlaubnis Vorstellung
2. Scheduling Benachrichtigung
+ (void)requestPermission {
UIMutableUserNotificationAction *smallCupAction = [UIMutableUserNotificationAction new];
smallCupAction.title = NSLocalizedString(@"250 mL", @"Notification button");
smallCupAction.identifier = @"add small";
smallCupAction.activationMode = UIUserNotificationActivationModeBackground;
smallCupAction.authenticationRequired = NO;
UIMutableUserNotificationAction *mediumCupAction = [UIMutableUserNotificationAction new];
mediumCupAction.title = NSLocalizedString(@"350 mL", @"Notification button");
mediumCupAction.identifier = @"add medium";
mediumCupAction.activationMode = UIUserNotificationActivationModeBackground;
mediumCupAction.authenticationRequired = NO;
UIMutableUserNotificationAction *largeCupAction = [UIMutableUserNotificationAction new];
largeCupAction.title = NSLocalizedString(@"500 mL", @"Notification button");
largeCupAction.identifier = @"add large";
largeCupAction.activationMode = UIUserNotificationActivationModeBackground;
largeCupAction.authenticationRequired = NO;
UIMutableUserNotificationCategory *waterReminderCategoryDefault = [UIMutableUserNotificationCategory new];
[waterReminderCategoryDefault setActions:@[smallCupAction, mediumCupAction, largeCupAction] forContext:UIUserNotificationActionContextDefault];
waterReminderCategoryDefault.identifier = @"water reminder default";
NSSet *categories = [NSSet setWithObjects: waterReminderCategoryDefault, nil];
UIUserNotificationType types = (UIUserNotificationType) (UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert);
UIUserNotificationSettings *mySettings =
[UIUserNotificationSettings settingsForTypes:types categories:categories];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
}
+ (void)scheduleNotificationWithGender:(NSNumber *)gender date:(NSDate *)date {
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = date;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = // localized text
localNotif.alertAction = // localized text
localNotif.alertTitle = // localized text
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
localNotif.category = @"water reminder default";
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:gender, kGenderKey, nil];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
seine Arbeit auf iphone Sie? –
@balkaransingh ja –
Ist die App auf der Uhr installiert? Haben Sie eine Benutzeroberfläche für die Benachrichtigungen? – jrturton