Advertisement
Guest User

Untitled

a guest
May 29th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. //
  2. // DynamicNotificationController.swift
  3. // NotificationDemo
  4. //
  5. // Created by Rommel Rico on 4/20/15.
  6. // Copyright (c) 2015 Rommel Rico. All rights reserved.
  7. //
  8.  
  9. import WatchKit
  10. import Foundation
  11.  
  12.  
  13. class DynamicNotificationController: WKUserNotificationInterfaceController {
  14.  
  15. @IBOutlet weak var testLabel: WKInterfaceLabel!
  16.  
  17. override init() {
  18. // Initialize variables here.
  19. super.init()
  20.  
  21. // Configure interface objects here.
  22. //testLabel.setText("You've been notified!")
  23. }
  24.  
  25. override func willActivate() {
  26. // This method is called when watch view controller is about to be visible to user
  27. super.willActivate()
  28. }
  29.  
  30. override func didDeactivate() {
  31. // This method is called when watch view controller is no longer visible
  32. super.didDeactivate()
  33. }
  34.  
  35.  
  36. override func didReceiveLocalNotification(localNotification: UILocalNotification, withCompletion completionHandler: ((WKUserNotificationInterfaceType) -> Void)) {
  37. //TODO
  38. }
  39.  
  40. override func didReceiveRemoteNotification(remoteNotification: [NSObject : AnyObject], withCompletion completionHandler: ((WKUserNotificationInterfaceType) -> Void)) {
  41. //Get the aps dictionary from the payload.
  42. let apsDictionary: NSDictionary = (remoteNotification["aps"] as? [NSObject: AnyObject])!
  43.  
  44. //Set the dynamic label
  45. testLabel.setText("You've been notified!")
  46.  
  47. //Tell WatchKit to display the custom interface
  48. completionHandler(WKUserNotificationInterfaceType.Custom)
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement