pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish
Get Updates
Follow Us
Subscribe to the Newsletter

Migrating to Pebblekit iOS 3.0

  • 29 October 2015
  • Alex Lin
  • Freshly Baked
  • Comments

Starting with Pebble Time Round, we are moving towards communicating with Bluetooth Low-Energy only. This means there are some updates to PebbleKit iOS to support this. Here are the major changes and steps to take to support the new BLE connection.

What's New

  • Companion apps have dedicated, persistent communication channels
  • Start mobile apps from Pebble
  • 8K AppMessage buffers
  • Swift support

What do you need to do?

Import the new PebbleKit iOS 3.0 library into your project.

API Changes

NSUUIDs

You can now use NSUUID objects directly rather than passing appUUID as a NSData object.

PebbleKit 2.x

uuid_t myAppUUIDbytes;
NSUUID *myAppUUID = [[NSUUID alloc] initWithUUIDString:@"226834ae-786e-4302-a52f-6e7efc9f990b"];
[myAppUUID getUUIDBytes:myAppUUIDbytes];
[PBPebbleCentral defaultCentral].appUUID = [NSData dataWithBytes:myAppUUIDbytes length:16];

PebbleKit 3.0

NSUUID *myAppUUID = [[NSUUID alloc] initWithUUIDString:@"226834ae-786e-4302-a52f-6e7efc9f990b"];
[PBPebbleCentral defaultCentral].appUUID = myAppUUID;

Cold start PBPebbleCentral

You'll want to start PBPebbleCentral in a cold state now so users don't get a pop-up asking for Bluetooth permissions as soon as the app initializes. Call [central run] when it makes sense for the pop-up to show up. Add some custom text to the dialog with NSBluetoothPeripheralUsageDescription to your Info.plist file.

PebbleKit 2.x

// MyAppDelegate.m - Set up PBPebbleCentral and run if the user has already
// performed onboarding
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [PBPebbleCentral defaultCentral].delegate = self;
  [PBPebbleCentral defaultCentral].appUUID = myAppUUID;
  if ([MySettings sharedSettings].userDidPerformOnboarding) {
    [[PBPebbleCentral defaultCentral] run];
  }
}

PebbleKit 3.0

// MyOnboarding.m - Once the pop-up has been accepted, begin PBPebbleCentral
- (IBAction)didTapGrantBluetoothPermissionButton:(id)sender {
  [MySettings sharedSettings].userDidPerformOnboarding = YES;
  [[PBPebbleCentral defaultCentral] run]; // will trigger pop-up
}

Specify that your app is built with PebbleKit 3.0 in the Developer Portal

Go to edit the companion app listing in your developer portal page and check the box for "Was this iOS app compiled with PebbleKit iOS 3.0 or newer?" This way, users on Pebble Time Round will be able to see your app in the appstore.

Final thoughts

With a few quick steps, you can bring compatability for the BLE connection to your app. In the coming months, we'll be rolling out updates for users of Pebble and Pebble Time to take advantage of BLE-only connection as well. In the short term, if you intend to support Pebble Time Round, these steps are mandatory. For the complete details on migrating to PebbleKit 3.0, take a look at our migration guide. If you have any issues in migrating or have any questions concerning PebbleKit 3.0, feel free to contact us anytime!


You need JavaScript enabled to read and post comments.
Get Updates
Follow Us
Subscribe to the Newsletter

Overview

  • What do you need to do?
  • API Changes
  • NSUUIDs
  • Cold start PBPebbleCentral
  • Specify that your app is built with PebbleKit 3.0 in the Developer Portal
  • Final thoughts

Categories

  • All Posts
  • #makeawesomehappen
  • At the Pub
  • Beautiful Code
  • CloudPebble
  • Down the Rabbit Hole
  • Freshly Baked
  • Timeline

Authors

  • Thomas Sarlandie
  • Niharika Bedekar
  • Katharine Berry
  • Jon Barlow
  • Cherie Williams
  • Chris Lewis
  • Team Pebble
  • Katherine McAuliffe
  • Cat Haines
  • Alex Lin
  • Kirby Kohlmorgen
  • Brad Murray
  • Alexey Komissarouk
  • Ɓukasz Zalewski
  • Tom Maremaa
  • Ryan Case
  • Ryan Perry-Nguyen
  • Keegan Lillo
  • Meiguro

Subscribe to the Pebble Developers Newsletter