【问题标题】:Synchronise UILocalNotification to the Watch将 UILocalNotification 同步到 Watch
【发布时间】:2017-05-24 06:00:34
【问题描述】:

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

这是我的 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];

【问题讨论】:

    标签: objective-c xcode uilocalnotification apple-watch


    【解决方案1】:

    你不需要做任何事情来实现这一点。系统会自动决定在哪个设备上显示通知。 如果您的 iPhone 已锁定并且手表戴在手腕上,您应该会在手表上自动收到通知。还要确保在 iPhone 上的 Watch 应用中为您的应用打开通知,并且您的 Watch 未处于“请勿打扰”模式。

    【讨论】:

    • ok 那么如何在Iphone出现UIlocalNOtification时创建一个静态通知界面呢?谢谢
    • 您必须为您的应用添加通知扩展目标。看看this tutorial
    • 通知扩展?手表?教程看不懂
    • 您要电话...对于手表,您只需在 Interface Builder 中添加一个通知界面控制器即可。
    • ok,完美,如何在界面生成器中创建通知中心?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多