将 UILocalNotification 同步到手表



在我的iPhone应用程序上,我创建了UILocalNotification。我想知道如何在Apple Watch上同步UILocalNotification。这意味着当通知出现在iPhone上时,使通知出现在手表上。

这是我的UILocalNotification(此通知在91秒内出现,我想出现在手机和手表中(:

        UILocalNotification *verif_exterieur_notification = [[UILocalNotification alloc]init];
    verif_exterieur_notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:91];
    verif_exterieur_notification.alertTitle = @"Vérifications extérieures:";
    verif_exterieur_notification.alertBody = @"Assurez vous d'avoir bien vérifié(e) l'éxterieur de votre avion avant de vous installer !";
    verif_exterieur_notification.timeZone = [NSTimeZone defaultTimeZone];
    verif_exterieur_notification.soundName = UILocalNotificationDefaultSoundName;
    [[UIApplication sharedApplication ]scheduleLocalNotification:verif_exterieur_notification];

您无需执行任何操作即可实现此目的。系统会自动决定在哪个设备上显示通知。如果您的 iPhone 已锁定,并且手表戴在手腕上,您应该会在手表上自动收到通知。此外,请确保在 iPhone 上的"手表"应用中为您的应用打开通知,并且您的手表未处于"勿扰模式"。

最新更新