#pdr15 - pebblekit ios 3.0

36
2015 Pebble Developer Retreat PebbleKit iOS 3.0 Marcel Jackwerth, iOS Engineer

Upload: pebble-technology

Post on 12-Apr-2017

1.289 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: #PDR15 - PebbleKit iOS 3.0

2015 Pebble Developer Retreat

PebbleKit iOS 3.0

Marcel Jackwerth, iOS Engineer

Page 2: #PDR15 - PebbleKit iOS 3.0

Outline•Recap: What is PebbleKit? •What is new? • 8K App Messages • Support for Pebble Time Round • Isolated Sessions via Bluetooth Low Energy • Swift 2.0, Bitcode

•What are the breaking API changes? •How do I upgrade?

Page 3: #PDR15 - PebbleKit iOS 3.0

What is PebbleKit?And when should I use it?

Page 4: #PDR15 - PebbleKit iOS 3.0
Page 5: #PDR15 - PebbleKit iOS 3.0

What’s new?

8KApp Messages

with up to 8000 bytes in both directions

Bluetooth LE Connectivity

Page 6: #PDR15 - PebbleKit iOS 3.0

App Messages•Less data splitting needed → easier to work with•Less waiting on ACKs → reduced overhead, up to 5x faster

•Optimal size depends on your use-case

8K

Page 7: #PDR15 - PebbleKit iOS 3.0

Good: Check Capabilities 8K[watch getVersionInfo:^(PBWatch *watch, PBVersionInfo *info) { BOOL supports8k = (info.remoteProtocolCapabilitiesFlags & PBRemoteProtocolCapabilitiesFlagsAppMessage8kSupported) != 0;

if (supports8k) { // … }} onTimeout:nil];

Page 8: #PDR15 - PebbleKit iOS 3.0

Avoid: Maximum Sizes 8Kconst uint32_t inbound = app_message_inbox_size_maximum();const uint32_t outbound = app_message_outbox_size_maximum();app_message_open(inbound, outbound);

⚠This will reduce your heap size by 16,000 bytes if your watch app is compiled with the latest SDK and your companion app uses the new PebbleKit!

Page 9: #PDR15 - PebbleKit iOS 3.0

Best: Communicate Sizes 8Kconst uint32_t inbound = MIN(512, app_message_inbox_size_maximum());const uint32_t outbound = MIN(256, app_message_outbox_size_maximum());app_message_open(inbound, outbound);

DictionaryIterator *iter;app_message_outbox_open(&iter);Tuplet value = TupletInteger(KEY_INIT_INBOX_SIZE, inbound);dict_write_tuplet(iter, &value);app_message_outbox_send();

Page 10: #PDR15 - PebbleKit iOS 3.0

What’s new?

8KApp Messages

with up to 8000 bytes in both directions

Bluetooth LE Connectivity

Page 11: #PDR15 - PebbleKit iOS 3.0

Bluetooth Low Energy aka

Isolated App SessionCompatibility with Pebble Time Round

Page 12: #PDR15 - PebbleKit iOS 3.0

Shared App Session

Page 13: #PDR15 - PebbleKit iOS 3.0

Shared App Session

Pandora iOS App

Shared Session

Pandora Pebble App

Page 14: #PDR15 - PebbleKit iOS 3.0

Shared App Session

Pandora iOS App

Shared Session

Pandora Pebble App

Page 15: #PDR15 - PebbleKit iOS 3.0

Shared App Session

Pandora iOS App

runkeeper iOS App

Shared Session

Pandora Pebble App

runkeeper Pebble App

Page 16: #PDR15 - PebbleKit iOS 3.0

Shared App Session

Pandora iOS App

runkeeper iOS App

Shared Session

Pandora Pebble App

runkeeper Pebble App

Page 17: #PDR15 - PebbleKit iOS 3.0

Shared App Session

Pandora iOS App

runkeeper iOS App

Shared Session

Pandora Pebble App

runkeeper Pebble App

Page 18: #PDR15 - PebbleKit iOS 3.0

Isolated App Sessions

Pandora iOS App

Pandora Pebble App

Page 19: #PDR15 - PebbleKit iOS 3.0

Isolated App Sessions

Pandora iOS App

Pandora Pebble App f01d…

Page 20: #PDR15 - PebbleKit iOS 3.0

Isolated App Sessions

Pandora iOS App

runkeeper iOS App

Pandora Pebble App f01d…

runkeeper Pebble App b13a…

Page 21: #PDR15 - PebbleKit iOS 3.0

Launch App from Watch

Pandora Pebble App

Requires UIBackgroundModes to contain “bluetooth-peripheral” and “bluetooth-central”

Page 22: #PDR15 - PebbleKit iOS 3.0

Launch App from Watch

Pandora Pebble App f01d…

Requires UIBackgroundModes to contain “bluetooth-peripheral” and “bluetooth-central”

Page 23: #PDR15 - PebbleKit iOS 3.0

Launch App from Watch

Pandora iOS App

Pandora Pebble App f01d…

Requires UIBackgroundModes to contain “bluetooth-peripheral” and “bluetooth-central”

Page 24: #PDR15 - PebbleKit iOS 3.0

Breaking API Changes•App UUIDs are now of type NSUUID (was: NSData) •PebbleCentral starts in a cold state •You have to run it so that it scans for watches •lastConnectedWatch will not contain a connected Pebble before nor immediately after you called run (was possible before) - wait for pebbleCentral:watchDidConnect: after you called run.

Page 25: #PDR15 - PebbleKit iOS 3.0

Breaking API Changes

central.delegate = self; uuid_t appUUIDBytes; NSUUID *appUUID = [[NSUUID alloc] initWithUUIDString:”f00d…”]; [appUUID getUUIDBytes:appUUIDBytes]; central.appUUID = appUUIDBytes;

Before

Page 26: #PDR15 - PebbleKit iOS 3.0

Breaking API Changes

After

central.delegate = self;

NSUUID *appUUID = [[NSUUID alloc] initWithUUIDString:”f00d…”];

central.appUUID = appUUID;

[central run];

Page 27: #PDR15 - PebbleKit iOS 3.0

Bad: Run, Configure, Manual Check

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[[PBPebbleCentral defaultCentral] run]; [PBPebbleCentral defaultCentral].appUUID = [NSUUID …]; PBWatch *watch = [PBPebbleCentral defaultCentral].lastConnectedWatch; if (watch.isConnected) { … } return YES; }

Page 28: #PDR15 - PebbleKit iOS 3.0

Good: Configure, Run, React

- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[PBPebbleCentral defaultCentral].delegate = self; [PBPebbleCentral defaultCentral].appUUID = [NSUUID …]; [[PBPebbleCentral defaultCentral] run]; }

- (void)pebbleCentral:(PBPebbleCentral *)central watchDidConnect:(PBWatch *)watch { … }

Page 29: #PDR15 - PebbleKit iOS 3.0

•Nullability Annotations•Generics

Swift 2.0

Page 30: #PDR15 - PebbleKit iOS 3.0

•Xcode 7.0.1 started to claim that it isn’t (when using CocoaPods and building an Archive)• If you run into any issues we recommend that you disable it with ENABLE_BITCODE=NO

Bitcode included

$

Page 31: #PDR15 - PebbleKit iOS 3.0

Still necessary to be compatible with Pebble and Pebble Steel

MFi

Page 32: #PDR15 - PebbleKit iOS 3.0

How to Update

pod “PebbleKit”, “~> 3.0.0”

Or just replace the PebbleKit.framework with its new version manually, available here:

https://github.com/pebble/pebble-ios-sdk/releases

Podfile

Page 33: #PDR15 - PebbleKit iOS 3.0

CHMultiDictionary CHMutableDictionary DDASLLogger DDFileLogger DDLog DDTTYLogger NSJSONSerialization+ObjectWithNString NSJSONSerialization+PBJSONHelpers NSString+HexData UIDevice-Hardware

You can remove it from your project if you don’t use any of the classes or methods that it contained:

PebbleVendor.framework

Page 34: #PDR15 - PebbleKit iOS 3.0

Recap•Why? •8K App Messages, Better Background Experience •Support Pebble Time Round and be ready when other Pebble models switch to Bluetooth Low Energy

•How? •Get the new PebbleKit.framework •Set appUUID, then [central run]

Page 35: #PDR15 - PebbleKit iOS 3.0

Questions?

Page 36: #PDR15 - PebbleKit iOS 3.0

Licenses & Attribution• Isolation Icon by Griffin Mullins

%