small medium large xlarge

Img_7226_pragsmall
01 Nov 2016, 12:11
memetcircus (5 posts)

I couldn’t find a way to add Glances to my Hello World project. I searched and learnt that Glances are no more exist. So I gave a try to Notification Interface Controller. I added Dynamic notification interface and create a custom class for that. And try to test it with new schema (duplicate), I chose Watch Interface Main to Dynamic or Static. In both I received error when I built

Square_pragsmall
01 Nov 2016, 15:15
Jeff Kelley (8 posts)

Hi Memet, what is the error you’re seeing?

Img_7226_pragsmall
02 Nov 2016, 08:35
memetcircus (5 posts)

Hi Jeff,

I uploaded the whole project to Github:

HelloWatch Project

The error message is: Error Launching HelloWatch Watchkit, SPErrorUnknownMessage. My classes are;

GlanceInterfaceController

import WatchKit
import Foundation
class GlanceInterfaceController: WKUserNotificationInterfaceController {

@IBOutlet var Label: WKInterfaceLabel!

override func awake(withContext context: Any?) {
    super.awake(withContext: context)
    
    // Configure interface objects here.
    
    Label.setText("Hello Watch")
    
    
}

override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
    
    Label.setText("Hello Watch")
}

override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    super.didDeactivate()   
} }

Scheme of HelloWatch WatchKit app - Glance

Watch Interface: Dynamic Notification

Interface Controller class

import WatchKit
import Foundation

class InterfaceController: WKInterfaceController {
@IBOutlet var label: WKInterfaceLabel!

override func awake(withContext context: Any?) {
    super.awake(withContext: context)
    
    // Configure interface objects here.
}

override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
}

override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    super.didDeactivate()
}

@IBAction func buttonPressed(){
    label.setText("Hello Watch")
}  }
Square_pragsmall
02 Nov 2016, 14:41
Jeff Kelley (8 posts)

I checked out your project and it looks like you’re missing a simulated push notification. In Xcode, select File -> New -> File, then under iOS, in the “Apple Watch” section, choose “Notification Simulation File.” With this file in your project, make sure it’s selected in your scheme, then try to run. You’ll then see your interface controller with the test notification data.

Img_7226_pragsmall
03 Nov 2016, 08:10
memetcircus (5 posts)

All done, I added Notification Simulation File, it works well but one should wait at least 10 seconds to receive the notification on simulator. Thanks

You must be logged in to comment