2016-07-22 4 views
0

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]; 
} 

Screenshot of iPhone Lock Screen with the notification. Notifications has 2 actions

+0

seine Arbeit auf iphone Sie? –

+0

@balkaransingh ja –

+0

Ist die App auf der Uhr installiert? Haben Sie eine Benutzeroberfläche für die Benachrichtigungen? – jrturton

Antwort

0

ich mein Problem gelöst durch Benachrichtigungen in der Uhr App ermöglicht:

  1. Öffnen Sie die Watch-App auf Ihrem iPhone, tippen Sie auf die Registerkarte Meine Überwachung und dann auf Nicht Informationen.
  2. Tippen Sie auf eine App.

Quelle: https://support.apple.com/en-us/HT204791