Transcript
Page 1: KKBOX WWDC17 Notification and Autolayout - Jefferey

This presentation is provided on a strictly private and confidential basis for information purposes only.

Notification, Auto Layout

presented by Jeffery Kao

2017/07/07

Page 2: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notifications

Page 3: KKBOX WWDC17 Notification and Autolayout - Jefferey

Notification

Short Look What is this notification about?

Long Look What extra information is helpful?

Quick Actions What actions are appropriate?

Page 4: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification

Short LookLong Look

Page 5: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification - Mail

Page 6: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification - Photos

Page 7: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification - Tips

Page 8: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification - Phone

Page 9: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification - Find Friends

Page 10: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification - Messages

Page 11: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rich Notification - KUNA APP

In our new iOS app you now have the ability to 3D touch (Force touch) notifications that arrive from Kuna – this will immediately display an animated image of what caused that notification.

You can then snooze alerts for two hours, or play a pre-recorded message. If you do not have 3D touch on your phone – you can still swipe left on the notification to view this new feature (iOS 10 only!)

Page 13: KKBOX WWDC17 Notification and Autolayout - Jefferey

Design - Recap

Clear description in the short looks

Provide extra context in beautifully designed long looks

Relevant quick actions

Page 14: KKBOX WWDC17 Notification and Autolayout - Jefferey

Best Practices and What’s New in User Notifications

Page 15: KKBOX WWDC17 Notification and Autolayout - Jefferey

API - Notification

Notification Type:

- Local Notification

- Remote Notification

Notification Extension:

- Notification Service Extension

- Notification Content Extension

Purpose:

- Location-based, time-based or reminder

- Silence Notification

Page 16: KKBOX WWDC17 Notification and Autolayout - Jefferey

Hidden Notification Content

Hidden Notification Content:

- Extended support all apps

- Global setting

- Settings per app

- API to customize notification content

init(identifier: String, actions: [UNNotificationAction],

intentIdentifiers: [String], hiddenPreviewsBodyPlaceholder:

String, options: UNNotificationCategoryOptions = [])

NEW

Page 17: KKBOX WWDC17 Notification and Autolayout - Jefferey

Hidden Notification Content

// hiddent notification contentlet commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "Comment" // 隱藏後仍然可以看到的body)

NEW

Page 18: KKBOX WWDC17 Notification and Autolayout - Jefferey

Hidden Notification Content

// hiddent notification contentlet commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "%u Comments" // 隱藏後仍然可以看到的body)

NEW

Page 19: KKBOX WWDC17 Notification and Autolayout - Jefferey

Hidden Notification Content

// how about using localization for plural noun?

let commentCategory = UNNotificationCategory(identifier: "comment-category",

actions: [],

intentIdentifiers: [],

hiddenPreviewsBodyPlaceholder: NSLocalizedString("COMMENT_KEY", comment: ""),

options:[.hiddenPreviewsShowTitle])

NEW

Page 20: KKBOX WWDC17 Notification and Autolayout - Jefferey

Hidden Notification Content

- Set “Show Preview” to “Never” or “Authenticated”

- Only show “Body placeholder”

NEW

Page 21: KKBOX WWDC17 Notification and Autolayout - Jefferey

Customizing Rich Notification

Page 22: KKBOX WWDC17 Notification and Autolayout - Jefferey

Customizing Rich Notification

- Content extension: init content size ratio

- Customized input view

- Media button in UNNotificationContentExtension

Page 23: KKBOX WWDC17 Notification and Autolayout - Jefferey

Size Classes and Core Components

Page 24: KKBOX WWDC17 Notification and Autolayout - Jefferey

Table

● Size Classes

● Dynamic Type

● UIKit Components

Page 25: KKBOX WWDC17 Notification and Autolayout - Jefferey

Multiple Screen Sizes

Page 26: KKBOX WWDC17 Notification and Autolayout - Jefferey

Multiple Screen Sizes

Page 27: KKBOX WWDC17 Notification and Autolayout - Jefferey

Multiple Screen Sizes

Compact Width

Compact Height

Page 28: KKBOX WWDC17 Notification and Autolayout - Jefferey

Layout with Different Screen and Font Size

Different Screen Size

Page 29: KKBOX WWDC17 Notification and Autolayout - Jefferey

Dynamic Type

Page 30: KKBOX WWDC17 Notification and Autolayout - Jefferey

Dynamic Type

● Making custom fonts dynamic

● Example: Etsy

Page 31: KKBOX WWDC17 Notification and Autolayout - Jefferey

UIKit Components

Page 32: KKBOX WWDC17 Notification and Autolayout - Jefferey

UIKit Components

Page 33: KKBOX WWDC17 Notification and Autolayout - Jefferey

Auto Layout Techniques in Interface Builder

Page 34: KKBOX WWDC17 Notification and Autolayout - Jefferey

Table

● Changing Layout At Runtime

● Tracking Touch

● Dynamic Type

● Safe Areas

● Rest of Topics

Page 35: KKBOX WWDC17 Notification and Autolayout - Jefferey

Changing Layout at Runtime

BOOL shouldShow = !self.edgeConstraint.active;

// Deactivate constraint first to avoid constraint conflict messageif (shouldShow) {

self.zeroHeightConstraint.active = NO;self.edgeConstraint.active = YES;

}else {

self.edgeConstraint.active = NO;self.zeroHeightConstraint.active = YES;

}

Page 36: KKBOX WWDC17 Notification and Autolayout - Jefferey

Tracking Touch

Familiar with CGTransform to track touch event

CGAffineTransform = translation + rotation + scale

Page 37: KKBOX WWDC17 Notification and Autolayout - Jefferey

Dynamic Type

- Interface Builder -> dynamic Type

- set Font size as UIFontTextStyleHeadline |

UIFontTextStyleBody …

- Dynamically change font size with a proper way:

- Xcode -> Open Developer Tool -> Accessibility Inspector

-> Font size

NEW

Page 38: KKBOX WWDC17 Notification and Autolayout - Jefferey

Safe Areas

Safe Areas (iOS11)- Property in UIView- TopLayout, BottomLayout is deprecated- Upgrade automatically with storyboards

NEW

Page 39: KKBOX WWDC17 Notification and Autolayout - Jefferey

Safe AreasNEW

Page 40: KKBOX WWDC17 Notification and Autolayout - Jefferey

Safe AreasNEW

Page 41: KKBOX WWDC17 Notification and Autolayout - Jefferey

Safe Areas

if #available(iOS 11, *) { let guide = view.safeAreaLayoutGuide NSLayoutConstraint.activate([ view.topAnchor.constraintEqualToSystemSpacingBelow(guide.topAnchor, multiplier: 1.0), guide.bottomAnchor.constraintEqualToSystemSpacingBelow(view.bottomAnchor, multiplier: 1.0)])} else { // older version

let standardSpacing: CGFloat = 8.0 NSLayoutConstraint.activate([

view.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor, constant: standardSpacing), bottomLayoutGuide.topAnchor.constraint(equalTo: view.bottomAnchor,constant: standardSpacing)])}

NEW

Page 42: KKBOX WWDC17 Notification and Autolayout - Jefferey

Rest of Topics

Proportional Positioning- use spacer view to help you locate your view

Stack View Adaptive Layout- hidden property by size class (XCode 9 support)

- Use distribution, alignment, and spacing

proportional positioning example

p.s. standard spacing = 8 which can be used in interface builder

Page 43: KKBOX WWDC17 Notification and Autolayout - Jefferey

RecapNotification:

- Some examples for building rich notification

- New API about hidden notification content

Sizing Class:

- Make use of `Dynamic Type` and be aware of device size

AutoLayout:

- Existing techniques (layout changing in runtime or track touch)

- Adapt with new APIs (Safe areas and propotional positioning)

- Stack view example

Page 44: KKBOX WWDC17 Notification and Autolayout - Jefferey

References

● Rich Notifications

○ https://developer.apple.com/videos/play/wwdc2017/817

● Best Practices and What’s New in User Notifications

○ https://developer.apple.com/videos/play/wwdc2017/708

● Size Classes and Core Components

○ https://developer.apple.com/videos/play/wwdc2017/812

● Auto Layout Techniques in Interface Builder

○ https://developer.apple.com/videos/play/wwdc2017/412

● Useful repo:

○ https://github.com/Sweefties/iOS10-NewAPI-UserNotifications-Example

○ https://useyourloaf.com/blog/safe-area-layout-guide/

Page 45: KKBOX WWDC17 Notification and Autolayout - Jefferey

This presentation is provided on a strictly private and confidential basis for information purposes only.

THANK YOU


Top Related