How to trigger haptic alert when inactive watch receives local notification
<p>I am working on a timer app for the Apple Watch.</p>

<p>At a specific time (end of timer) the iPhone fires a scheduled <code>UILocalNotification</code> which on the inactive Apple Watch should trigger a haptic alert to tell the user that the timer has ended. </p>

<p><em>I've done this since timers don't continue to run on Apple Watch once the watch is inactive.</em></p>

<p>The problem I am facing is:</p>

<p>a) the notification is sometimes shown on the iPhone rather than on the apple watch (based on other posts, I fear that this cannot be changed...)</p>

<p>b) no haptic alert is given on the watch (purely display of notification and this only at next time when the user is activating the watch, not at the time when the notification is actually triggered)</p>

<pre><code>func sendAwakeNotification(nextTime:NSDate) {
    print("AppDelegate: - sendAwakeNotification")

    dispatch_async(dispatch_get_main_queue()) { () -&gt; Void in

        let localNotification = UILocalNotification()
        localNotification.fireDate = nextTime
        localNotification.timeZone = NSTimeZone.defaultTimeZone()
        localNotification.alertBody = "Finished Step"
        localNotification.alertTitle = "Alert"

        localNotification.soundName = UILocalNotificationDefaultSoundName

        localNotification.category = "myTimer"
        let userInfo: [NSObject : AnyObject] = [
            "notification_id" : "myTimerNotification"
        ]
        localNotification.userInfo = userInfo

        UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

    }
}
</code></pre>

<p>The code in Notification</p>

<pre><code>override func didReceiveLocalNotification(localNotification: UILocalNotification, withCompletion completionHandler: ((WKUserNotificationInterfaceType) -&gt; Void)) {

    print("received notification")

    dispatch_async(dispatch_get_main_queue()) { () -&gt; Void in
        let notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.postNotificationName(NotificationAlertFromPhone, object: nil)
    }

    completionHandler(.Custom)
}
</code></pre>

<p>I've tried to trigger a haptic alert directly in NotificationController <code>(WKInterfaceDevice.currentDevice().playHaptic(WKHapticType.Notification))</code>, but it did not work. I therefore reverted to send notification which should be received by ExtensionDelegate to trigger the haptic. </p>

<p>Here is the code in ExtensionDelegate:</p>

<pre><code>private func setupNotificationCenter() {
    print("ExtensionDelegate:  - setupNotificationCenter")

    notificationCenter.addObserverForName(NotificationAlertFromPhone, object: nil, queue: nil) { (notification:NSNotification) -&gt; Void in
        WKInterfaceDevice.currentDevice().playHaptic(WKHapticType.Notification)
    }
}
</code></pre>