Upgrade to Pro — share decks privately, control downloads, hide ads and more …

debug-remote-local-notification-on-watchos

 debug-remote-local-notification-on-watchos

potatotips #28

Shinichi Goto

April 20, 2016
Tweet

More Decks by Shinichi Goto

Other Decks in Programming

Transcript

  1. watchOS No+fica+on Components • Short-look • Long-look • Sta.c •

    Dynamic • Remote or Local • Ac.onable items • First view (kinds different from iOS)
  2. watchOS No+fica+on Components • Short-look • Long-look • Sta.c •

    Dynamic • Remote or Local • Ac.onable items • First view (kinds different from iOS)
  3. Debug No)fica)on • Remote no)fica)on • On simulator • On

    device • Local no)fica)on • On simulator • On device
  4. Remote No(fica(on • On simulator • Provided on Xcode !

    • Custom Build Scheme with No8fica8on Interface • Describe no8fica8on payload in json • breakpoint "
  5. MessagePayload.apns { "aps": { "alert": { "body": "Wantedly, Inc.͔Βϝοηʔδ͕ಧ͖·ͨ͠", "title":

    "৽ணϝοηʔδ" }, "category": "MESSAGE_CATEGORY", }, "message": { "id": 1, "body": "͜Μʹͪ͸ʂాதͰ͢ɻ\n͜ͷ౓͸WantedlyʹڵຯΛ࣋ͬͯ௖͍ͯ͋Γ͕ͱ͏͍͟͝·͢ɻ", "company_name": "Wantedly, Inc.", ... }, "WatchKit Simulator Actions": [ ... ] }
  6. Remote No(fica(on • On simulator • Provided on Xcode !

    • Custom Build Scheme with No:fica:on Interface • Describe no:fica:on payload in json • breakpoint " • On device • Just send it :)
  7. Local No(fica(on on Simulator • Want • Easily debug •

    Problem • Not provided on Xcode • Different from remote no=fica=on on simulator • Solu=on? • Use remote no=fica=on debugging instead?
  8. Solu%on? ## Debug override func didReceiveRemoteNotification( remoteNotification: [NSObject : AnyObject],

    withCompletion completionHandler: (WKUserNotificationInterfaceType) -> Void) {...} ## Production override func didReceiveLocalNotification( localNotification: UILocalNotification, withCompletion completionHandler: (WKUserNotificationInterfaceType) -> Void) {...}
  9. Problem ## Debug override func didReceiveRemoteNotification( remoteNotification: [NSObject : AnyObject],

    withCompletion completionHandler: (WKUserNotificationInterfaceType) -> Void) {...} ## Production override func didReceiveLocalNotification( localNotification: UILocalNotification, withCompletion completionHandler: (WKUserNotificationInterfaceType) -> Void) {...} ɹ remoteNotification != localNotification
  10. Sender UILocalNotification *notification = [UILocalNotification new]; notification.alertBody = [company.name stringByAppendingString:@"͕ۙ͘ʹ͋Γ·͢"];

    notification.alertTitle = @"ۙ͘ͷձࣾ"; notification.category = @"COMPANY_LOCATION"; notification.userInfo = [company toJSON];
  11. Local No(fica(on on Device • Problem • Hard to send

    (depending on applica5on) • Needs to send no5fica5on while iOS device is asleep • Solu5on • Basically same as debugging iOS local no5fica5on