2017-04-12 160 views
2

我們使用WatchOS 3.0提供的UNUserNotification框架創建本地通知,以便在預定義時刻通知用戶。但是,手錶沒有戴在手腕上時,通知不會顯示。當有人穿着它時,它確實很好。Apple Watch本地通知在手錶未穿着時不起作用

我們無法在任何文檔中找到此說明。這是正常的嗎?如果是,如何幫助用戶避免丟失一些notifs?

UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in 
      // Enable or disable features based on authorization. 
      if granted { 
       let content = UNMutableNotificationContent() 
       content.title = title 
       content.body = body 
       content.sound = UNNotificationSound.default() 
       content.userInfo = userInfo 
       let trigger = UNTimeIntervalNotificationTrigger.init(
        timeInterval: interval, 
        repeats: false) 

       let identifier = stringWithUUID() 
       let request = UNNotificationRequest.init(
        identifier: identifier, 
        content: content, 
        trigger: trigger 
       ) 
       UNUserNotificationCenter.current().add(request, withCompletionHandler: nil) 
       completion?(true, nil) 
      } 
      else { 
       completion?(false, error) 
      } 
     } 

回答

1

這是正常的,當你把它關閉你的手腕和通知到你的iPhone,而不是Apple關注自動鎖定。

+1

這裏描述:https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html#//apple_ref/doc/uid/TP40014969-CH18-SW1 – abjurato

+1

是的,根據本文檔,如果通知的來源是手錶擴展程序,它只會傳送到手錶。問題是,如果這種通知發生在用戶不戴手錶時,它會永遠丟失...... –

相關問題