Slide 1

Slide 1 text

Debug Remote / Local No1fica1on on watchOS ɹ potato%ps-28 2016/4/20 @shingt

Slide 2

Slide 2 text

Wantedly

Slide 3

Slide 3 text

No#fica#ons

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Complicated (Compared to iOS)

Slide 8

Slide 8 text

Debugging

Slide 9

Slide 9 text

Debug No)fica)on • Remote no)fica)on • On simulator • On device • Local no)fica)on • On simulator • On device

Slide 10

Slide 10 text

Remote No(fica(on • On simulator • Provided on Xcode ! • Custom Build Scheme with No8fica8on Interface • Describe no8fica8on payload in json • breakpoint "

Slide 11

Slide 11 text

MessagePayload.apns { "aps": { "alert": { "body": "Wantedly, Inc.͔Βϝοηʔδ͕ಧ͖·ͨ͠", "title": "৽ணϝοηʔδ" }, "category": "MESSAGE_CATEGORY", }, "message": { "id": 1, "body": "͜Μʹͪ͸ʂాதͰ͢ɻ\n͜ͷ౓͸WantedlyʹڵຯΛ࣋ͬͯ௖͍ͯ͋Γ͕ͱ͏͍͟͝·͢ɻ", "company_name": "Wantedly, Inc.", ... }, "WatchKit Simulator Actions": [ ... ] }

Slide 12

Slide 12 text

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 :)

Slide 13

Slide 13 text

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?

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Sender UILocalNotification *notification = [UILocalNotification new]; notification.alertBody = [company.name stringByAppendingString:@"͕ۙ͘ʹ͋Γ·͢"]; notification.alertTitle = @"ۙ͘ͷձࣾ"; notification.category = @"COMPANY_LOCATION"; notification.userInfo = [company toJSON];

Slide 17

Slide 17 text

Prepare wrapper object

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

• Easy to debug • Assump1on: NotificationPayload works appropriately • Cannot test sender

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:... { ... [self methodForLocalNotification]; // For debug ... }

Slide 23

Slide 23 text

Run iOS app => Sleep => "Simulate Background Fetch"

Slide 24

Slide 24 text

Summary • Debugging No,fica,on • Remote...؆୯ • Local...γϛϡϨʔλͷ৔߹͸ͪΐͬͱ޻෉͢Δ ͱྑͦ͞͏

Slide 25

Slide 25 text

ऴΘΓ !