iOS 10 Notification App Extensions

Post on 18-Feb-2017

138 views 3 download

Transcript of iOS 10 Notification App Extensions

NOTIFICATION APP EXTENSIONSCocoaHeads Stockholm 16-09-07

ABOUT ME

• Previously developed music games in Japan • Joined Propellerhead 2013 • Worked on ReBirth, Thor, Figure, Take • Manager of Mobile Group at Allihoopa (PH spinoff) • Amateur photographer and musician • 💓 creative tools

NOTIFICATION APP EXTENSIONS

➤ Make your noIficaIons stand out ➤ adding assets that don’t fit in a push payload ➤ custom UI to make the noIficaIon stand out ➤ basic user interacIon

APP EXTENSIONS

➤ Added in iOS 8 ➤ Separate executable, separate process ➤ Limited lifecycle and resources ➤ Examples

➤ Keyboard ➤ Share extension ➤ Today extension (widget) ➤ Photo processing

NOTIFICATION EXTENSIONS

➤ Added in iOS 10 ➤ Service: extending the payload ➤ Content: custom UI

STEPS

1. Modify your payload

2. Register for user noIficaIons in the app

3. Create a service app extension

4. Process extended content

5. Create a content app extension

6. Processing acIons

7. Debugging

8. Gotchas and Ips

1. MODIFYING THE PAYLOAD

➤ Add “mutable-content” key and set to 1 ➤ Set a category idenIfier indicaIng which extension to use

2. REGISTER FOR USER NOTIFICATIONS

➤ Register UNNoIficaIonCategory to define custom noIficaIons

➤ Register an UNUserNoIficaIonCenter delegate for acIons

3. CREATE A SERVICE APP EXTENSION

➤ One per bundle ➤ Will process any noIficaIon with mutable-content

4. PROCESS EXTENDED CONTENT

➤ Download abachments one at a Ime to temp storage ➤ Create an UNNoIficaIonAbachment for each ➤ Memory and Ime are limited!

5. CREATE A CONTENT APP EXTENSION

➤ Triggered from 3D touch ➤ Can stream video or audio ➤ Add your noIficaIon category to the extension Info.plist

5. CREATE A CONTENT APP EXTENSION

➤ Open abachments and stream online media ➤ File accesses from the service ext. need security access

STREAMING MEDIA FROM AN APP EXTENSION

➤ AVPlayer makes this easy ➤ Layout can be tricky

6. PROCESSING ACTIONS

➤ Meanwhile, back in the app… ➤ UNNoIficaIonAcIonOpIonForeground to trigger app moving

to foreground

DEBUGGING

➤ Extensions are embedded in the parent .app ➤ Debugging requires running the target via another host app

GOTCHAS AND TIPS

➤ Make sure your app extension is actually named .appex ➤ App being in background means no (massive) view controllers ➤ Memory and Ime are really Ight in extensions ➤ Device log can be infinitely more useful than console ➤ Xcode 8 no longer moves provisioning profile enItlements into

embedded enItlements during packaging

THANK YOU FOR LISTENING

Contact me anyIme:

➤ @gamedeventura

➤ perfeciorwarding.tumblr.com

➤ david@allihoopa.com

Allihoopa is hiring!