Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 解雇apple watch通知_Ios_Notifications_Watchkit_Apple Watch - Fatal编程技术网

Ios 解雇apple watch通知

Ios 解雇apple watch通知,ios,notifications,watchkit,apple-watch,Ios,Notifications,Watchkit,Apple Watch,我有一个todo应用程序,需要在预定的todo时间向手表显示通知。我该怎么做?我听说iOS本地通知会在手表中自动触发通知。可能吗?如果是,我需要添加额外的代码吗?WatchKit没有改变UILocalNotification的概念。唯一改变的是,iOS现在可以决定是否向iPhone或手表发送本地(或远程)通知。但是,没有编程方式来控制这些设备中的哪一个实际显示通知 要从WatchKit应用程序中计划UILocalNotification,需要使用类似于openParentApplication:

我有一个todo应用程序,需要在预定的todo时间向手表显示通知。我该怎么做?我听说iOS本地通知会在手表中自动触发通知。可能吗?如果是,我需要添加额外的代码吗?

WatchKit没有改变
UILocalNotification
的概念。唯一改变的是,iOS现在可以决定是否向iPhone或手表发送本地(或远程)通知。但是,没有编程方式来控制这些设备中的哪一个实际显示通知


要从WatchKit应用程序中计划
UILocalNotification
,需要使用类似于
openParentApplication:reply:
的类方法在
WKInterfaceController
上让iPhone应用程序执行实际的计划。这是因为WatchKit无权访问
UIApplication
,该类用于调度本地通知。

在watchOS 3中,您不再需要使用手机来调度通知

现在,您可以使用新框架直接在手表上安排本地通知。这些通知将仅出现在手表上并由手表处理

WWDC 2016课程介绍了如何使用不同类型的触发器触发todo通知,例如:

  • 时间间隔触发器

    // In 2 minutes from now
    UNTimeIntervalNotificationTrigger(timeInterval: 120, repeats: false)
    
    // Repeat every hour starting now
    UNTimeIntervalNotificationTrigger(timeInterval: 3600, repeats: true)
    
  • 日历触发器

    let dateComponents = DateComponents()
    // Configure dateComponents
    UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
    

本课程还介绍了如何处理手表上的可操作通知。

是的,你是对的@Naveen。“操作系统负责在其预定时间发送本地通知;应用程序不必运行即可实现此目的。”——。您需要为本地通知添加代码。从中更清楚地了解特定的待办事项。希望这能对你有所帮助。谢谢@Rajat。当iPhone应用程序触发本地通知时,我们为watch应用程序制作的通知场景是否会出现?是的,它将显示在watch上。感谢您提供的信息。这就解决了我的问题。如果我在iOS应用程序中设置了本地通知,通知是否会自动显示在手表上?只有在iOS决定在手表上显示时才会显示。请记住……您无法控制通知的显示位置。必须锁定设备才能在apple Watch中接收通知,或者,为了进行调试,您可以进入iPhone上的Watch companion应用程序并禁用常规/腕部检测。