Inherits from NSObject
Declared in PBWatch.h

Overview

Represents a Pebble watch.

Other Methods

central

The central that is managing this watch.

@property (nonatomic, weak, readonly) PBPebbleCentral *central

Discussion

This property is KVO-compliant.

Declared In

PBWatch.h

– isNew

YES if the receiver it’s the first time that watch has been seen.

- (BOOL)isNew

Discussion

This property is KVO-compliant.

Declared In

PBWatch.h

connected

YES if the receiver is connected and NO if the receiver is disconnected.

@property (nonatomic, assign, readonly, getter=isConnected) BOOL connected

Discussion

This property is KVO-compliant.

Declared In

PBWatch.h

name

The human-friendly name of the receiver. This is the same name as the user will see in the iOS Bluetooth Settings.

@property (nonatomic, copy, readonly) NSString *name

Declared In

PBWatch.h

serialNumber

The serial number of the receiver.

@property (nonatomic, copy, readonly) NSString *serialNumber

Declared In

PBWatch.h

versionInfo

The versionInfo of the receiver.

@property (nonatomic, strong, readonly) PBVersionInfo *versionInfo

See Also

Declared In

PBWatch.h

delegate

The delegate of the watch that will be notified of disconnections and errors.

@property (nonatomic, weak) id<PBWatchDelegate> __nullable delegate

See Also

Declared In

PBWatch.h

userInfo

The userInfo property can be used to associate application specific data with the watch. Note that the application itself is responsible for persisting the information if neccessary.

@property (nonatomic, strong) id __nullable userInfo

Declared In

PBWatch.h

lastConnectedDate

The date when the watch was last known to be connected. This date will be updated automatically when the watch connects and disconnects. While the watch is being connected, this date will not be updated.

@property (nonatomic, strong, readonly) NSDate *lastConnectedDate

Declared In

PBWatch.h

– friendlyDescription

Developer-friendly debugging description of the watch.

- (NSString *)friendlyDescription

Return Value

developer-friendly summary of the receiver, including software and hardware version information, if available.

Declared In

PBWatch.h

– releaseSharedSession

Releases the shared session to the watch (if one exists). (Deprecated: Remove usages of this method. The implementation is empty.)

- (void)releaseSharedSession

Discussion

Depending on availability a per-app dedicated Bluetooth LE based session (CoreBluetooth.framework) will be used to talk to the watch. In other cases a Bluetooth Classic based session (ExternalAccessory.framework) will be used that is shared between all 3rd party iOS apps.

Once the user is done using the app/watch-integration, the shared sessions has to be released using this method so it can be used by other apps.

Declared In

PBWatch.h

Golf Methods

– golfGetIsSupported:

Queries the watch whether Golf Messages are supported.

- (void)golfGetIsSupported:(void ( ^ ) ( PBWatch *watch , BOOL isGolfSupported ))fetchedBlock

Parameters

fetchedBlock
The block that will be called when the inquiry has finished. The block will be called asynchronously on the queue that was originally used when calling this method. watch: The watch on which the query was performed. isGolfSupported: YES if Golf Messages are supported, NO if not.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Golf.h

– golfAppLaunch:

Send a command to launch the golf app on the watch that the receiver represents.

- (void)golfAppLaunch:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

onSent
The handler that will be called when the launch command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Golf.h

– golfAppKill:

Send a command to kill the golf app on the watch that the receiver represents.

- (void)golfAppKill:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

onSent
The handler that will be called when the kill command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Golf.h

– golfAppUpdate:onSent:

Sends an update to the golf app on the watch that the receiver represents. Must be called from the main thread.

- (void)golfAppUpdate:(NSDictionary *)update onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

update
The update to send. Use one or more keys from PBGolfFrontKey, PBGolfMidKey, PBGolfBackKey, PBGolfHoleKey, or PBGolfParKey. Note that the value for each key MUST be of NSString type.
onSent
The handler that will be called when the update has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Declared In

PBWatch+Golf.h

– golfAppAddReceiveUpdateHandler:

Add a receive handler for incoming Golf updates that are send by the Golf watch application.

- (id)golfAppAddReceiveUpdateHandler:(BOOL ( ^ ) ( PBWatch *watch , GolfAppCommand command ))onReceive

Parameters

onReceive
The block that will be called every time a new update message arrives. watch: The receiver of the update. command: The command as sent by the watch.

Return Value

An opaque handle object representing the installed receive handler, that can be used in golfAppRemoveUpdateHandler:

Discussion

Must be called from the main thread.

Declared In

PBWatch+Golf.h

– golfAppRemoveUpdateHandler:

Removes a receive handler that was previously installed using golfAppAddReceiveUpdateHandler:

- (void)golfAppRemoveUpdateHandler:(id)opaqueHandle

Parameters

opaqueHandle
The handle object as returned by golfAppAddReceiveUpdateHandler:

Discussion

Must be called from the main thread.

Declared In

PBWatch+Golf.h

– golfSetTitle:icon:onSent:

Assigns a custom title and icon to the golf app on the watch.

- (void)golfSetTitle:(NSString *)title icon:(UIImage *)icon onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

title
The custom title (max. 20 bytes of UTF-8 string)
icon
The custom icon (max. 32x32 pixels, black/white only)
onSent
The handler that will be called when the title and icon have been set or timed out. watch: the recipient of the title and icon. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

It is recommended to perform this as the first call after golfGetIsSupported: to avoid changing the title and icon while it is being displayed in the menu as to avoid confusion.

Declared In

PBWatch+Golf.h

Ping Methods

– pingWithCookie:onPong:onTimeout:

Sends a ping to the watch.

- (void)pingWithCookie:(uint32_t)cookie onPong:(void ( ^ __nullable ) ( PBWatch *watch , uint32_t cookie ))onPong onTimeout:(void ( ^ __nullable ) ( PBWatch *watch , uint32_t cookie ))onTimeout

Parameters

cookie
A number identifying the ping.
onPong
The block handler that will be called when the “pong” reply from the watch has been received.
onTimeout
The block handler that will be called when the watch failed to reply in time.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Ping.h

SportsDeprecated Methods

– sportsAppSetLabel:onSent:

Send a command to the sports app on the watch that the receiver represents, to set the preferred data label (either PACE or SPEED) and corresponding units. (Deprecated: Prefer using [PBSportsUpdate pace] or [PBSportsUpdate speed].)

- (void)sportsAppSetLabel:(BOOL)isPace onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

isPace
YES to request the pace label or NO to request the speed label.
onSent
The handler that will be called when the unit command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

– sportsAppSetMetric:onSent:

Send a command to the sports app on the watch that the receiver represents, to set the preferred unit system, either metric or imperial. (Deprecated: Prefer using [PBWatch(Sports) sportsAppSetUnitSystem:onSent:])

- (void)sportsAppSetMetric:(BOOL)isMetric onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

isMetric
YES to request metric units or NO to request imperial units.
onSent
The handler that will be called when the unit command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

AppMessages Methods

– appMessagesGetIsSupported:

Queries the watch whether AppMessages are supported.

- (void)appMessagesGetIsSupported:(void ( ^ ) ( PBWatch *watch , BOOL isAppMessagesSupported ))fetchedBlock

Parameters

fetchedBlock
The block that will be called when the inquiry has finished. The block will be called asynchronously on the queue that was originally used when calling this method. watch: The watch on which the query was performed. isAppMessagesSupported: YES if AppMessages are supported, NO if not.

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesPushUpdate:onSent:

Pushes an update to the watch application with UUID as set using [PBPebbleCentral setAppUUID:].

- (void)appMessagesPushUpdate:(NSDictionary<NSNumber*,id> *)dictionary onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSDictionary *update , NSError *__nullable error ))onSent

Parameters

dictionary
Contains the key/value pairs to update. The dictionary can only contain items with an NSNumber key and only contain NSString, NSNumber or NSData values. Use the methods in the NSNumber (stdint) category to create NSNumbers with specific types standard integer types.
onSent
The block that will be called when the message was accepted, rejected or timed out. watch: The watch to which the update was sent. update: The dictionary that was sent. error: If there was a problem, this will contain information about the underlying problem. See PBErrorCode for error codes.

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesPushUpdate:withUUID:onSent:

Pushes an update to the watch application with the specified UUID.

- (void)appMessagesPushUpdate:(NSDictionary<NSNumber*,id> *)dictionary withUUID:(NSUUID *)appUUID onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSDictionary *update , NSError *__nullable error ))onSent

Parameters

dictionary
Contains the key/value pairs to update. The dictionary can only contain items with an NSNumber key and only contain NSString, NSNumber or NSData values. Use the methods in the NSNumber (stdint) category to create NSNumbers with specific types standard integer types.
appUUID
The UUID of the watchapp to which the update should be sent.
onSent
The block that will be called when the message was accepted, rejected or timed out. watch: The watch to which the update was sent. update: The dictionary that was sent. error: If there was a problem, this will contain information about the underlying problem. See PBErrorCode for error codes.

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesAddReceiveUpdateHandler:

Add a receive handler for incoming updates that are send by the watch application with UUID as set using [PBPebbleCentral setAppUUID:].

- (id)appMessagesAddReceiveUpdateHandler:(BOOL ( ^ ) ( PBWatch *watch , NSDictionary<NSNumber*,id> *update ))onReceive

Parameters

onReceive
The block that will be called every time a new update message arrives. watch: The watch that has sent the update. update: The dictionary containing the values sent by the watch.

Return Value

An opaque handle object representing the installed receive handler, that can be used in appMessagesRemoveUpdateHandler:

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesAddReceiveUpdateHandler:withUUID:

Add a receive handler for incoming updates that are send by the watch application with the specified UUID.

- (id)appMessagesAddReceiveUpdateHandler:(BOOL ( ^ ) ( PBWatch *watch , NSDictionary<NSNumber*,id> *update ))onReceive withUUID:(NSUUID *)appUUID

Parameters

onReceive
The block that will be called every time a new update message arrives. You should always return YES so than an ACK is sent to the watch. watch: The watch that has sent the update. update: The dictionary containing the values sent by the watch.
appUUID
The UUID of the watchapp for which sent messages should be handled by the onReceive block.

Return Value

An opaque handle object representing the installed receive handler, that can be used in appMessagesRemoveUpdateHandler:

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesRemoveUpdateHandler:

Removes a receive handler that was previously installed using appMessagesAddReceiveUpdateHandler:

- (void)appMessagesRemoveUpdateHandler:(id)opaqueHandle

Parameters

opaqueHandle
The handle object as returned by appMessagesAddReceiveUpdateHandler:

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesLaunch:

Sends a command to launch the watch application with UUID as set using [PBPebbleCentral setAppUUID:]

- (void)appMessagesLaunch:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

onSent
The block that will be called after the launch command has been sent to the watch. watch: The watch to which the command was sent. error: If there was a problem, this will contain information about the underlying problem. See PBErrorCode for error codes.

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesLaunch:withUUID:

Sends a command to launch the watch application with the specified UUID.

- (void)appMessagesLaunch:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent withUUID:(NSUUID *)appUUID

Parameters

onSent
The block that will be called after the launch command has been sent to the watch. watch: The watch to which the command was sent. error: If there was a problem, this will contain information about the underlying problem. See PBErrorCode for error codes.
appUUID
The UUID of the watch application to launch.

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesKill:

Sends a command to kill the watch application with UUID as set using [PBPebbleCentral setAppUUID:].

- (void)appMessagesKill:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

onSent
The block that will be called after the kill command has been sent to the watch. watch: The watch to which the command was sent. error: If there was a problem, this will contain information about the underlying problem. See PBErrorCode for error codes.

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

– appMessagesKill:withUUID:

Sends a command to kill the watch application with the specified UUID.

- (void)appMessagesKill:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent withUUID:(NSUUID *)appUUID

Parameters

onSent
The block that will be called after the kill command has been sent to the watch. watch: The watch to which the command was sent. error: If there was a problem, this will contain information about the underlying problem. See PBErrorCode for error codes.
appUUID
The UUID of the watch application to launch.

Discussion

Must be called from the main thread.

Declared In

PBWatch+AppMessages.h

Legacy Methods

– closeSession:

Closes the communication session with the watch. (Deprecated: Use [PBWatch releaseSharedSession])

- (void)closeSession:(void ( ^ __nullable ) ( void ))onDone

Parameters

onDone
Callback block that will be called after the closing of the session has completed. If there is no open session, the onDone block will (also) be executed asynchronously on the calling queue.

Discussion

Since there is only one, shared session for all 3rd party iOS apps, an app should close the session after the user is done using the app/watch-integration, so it can be used by other apps.

The communication session is implicitely opened automatically when needed.

Declared In

PBWatch+Legacy.h

Sports Methods

– sportsGetIsSupported:

Queries the watch whether Sports Messages are supported.

- (void)sportsGetIsSupported:(void ( ^ ) ( PBWatch *watch , BOOL isSportsSupported ))fetchedBlock

Parameters

fetchedBlock
The block that will be called when the inquiry has finished. The block will be called asynchronously on the queue that was originally used when calling this method. watch: the recipient of the query. isSportsSupported: YES if Sports API is supported, NO otherwise.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

– sportsAppLaunch:

Send a command to launch the sports app on the watch that the receiver represents.

- (void)sportsAppLaunch:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

onSent
The handler that will be called when the launch command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread, and before sportsAppSetMetric:onSent: or sportsAppUpdate:onSent:.

Declared In

PBWatch+Sports.h

– sportsAppKill:

Send a command to kill the sports app on the watch that the receiver represents.

- (void)sportsAppKill:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

onSent
The handler that will be called when the kill command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

– sportsAppSetUnitSystem:onSent:

Send a command to the sports app on the watch that the receiver represents, to set the preferred unit system.

- (void)sportsAppSetUnitSystem:(PBUnitSystem)unitSystem onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

unitSystem
PBUnitSystemMetric to request metric units or PBUnitSystemImperial to request imperial units.
onSent
The handler that will be called when the unit command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

– sportsAppSetActivityState:onSent:

Send a command to the sports app on the watch that the receiver represents, to set the state of the sports activity. Currently only SportsAppActivityStateRunning and SportsAppActivityStatePaused are supported.

- (void)sportsAppSetActivityState:(SportsAppActivityState)state onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

state
The new sports activity state
onSent
The handler that will be called when the unit command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

– sportsAppUpdate:onSent:

Sends the update to the sports app on the watch that the receiver represents.

- (void)sportsAppUpdate:(NSDictionary *)update onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

update
The update to send.
onSent
The handler that will be called when the unit command has been sent or timed out (after 1.5 secs). watch: the recipient of the command. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

The valid keys and values for the dictionary are the following:

  • PBSportsTimeKey: the string representing the time. The value must be an NSString. The maximum number of characters is about 8.
  • PBSportsDistanceKey: the string representing the distance. The value must be an NSString. The maximum number of characters is about 5.
  • PBSportsDataKey: the string representing the pace or the speed. The value must be an NSString. The maximum number of characters is about 5.
  • PBSportsActivityStateKey: the state of the activity. The value must be an NSNumber created using +[NSNumber(stdint) pb_numberWithUint8:]. The value must be one of the values from the enum SportsAppActivityState.
  • PBSportsIsPaceKey: whether the value sent in PBSportsDataKey is the pace (use value 1) or the speed (use value 0). You don’t need to continously send this value. The value must be an NSNumber created using +[NSNumber(stdin) pb_numberWithUint8:].
  • PBSportsHeartBPMKey: the current heart rate in beats per minute. The value must be an NSNumber created using [NSNumber(stdin) pb_numberWithUint8:].
  • PBSportsCustomLabelKey: the string to show as a custom label. The value must be an NSString. The maximum number of characters is about 10. The string will be transformed into upper case before being sent to the watch.
  • PBSportsCustomValueKey: the string to show as a custom value. The value must be an NSString. The maximum number of characters is about 8.

Declared In

PBWatch+Sports.h

– sportsAppAddReceiveUpdateHandler:

Add a receive handler for incoming Sports updates that are send by the Sports watch application.

- (id)sportsAppAddReceiveUpdateHandler:(BOOL ( ^ ) ( PBWatch *watch , SportsAppActivityState state ))onReceive

Parameters

onReceive
The block that will be called every time a new update message arrives. watch: The watch that has sent the update. state: The new sports activity state as set by the watch.

Return Value

An opaque handle object representing the installed receive handler, that can be used in sportsAppRemoveUpdateHandler:.

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

– sportsAppRemoveUpdateHandler:

Removes a receive handler that was previously installed using sportsAppAddReceiveUpdateHandler:.

- (void)sportsAppRemoveUpdateHandler:(id)opaqueHandle

Parameters

opaqueHandle
The handle object as returned by sportsAppAddReceiveUpdateHandler:

Discussion

Must be called from the main thread.

Declared In

PBWatch+Sports.h

– sportsSetTitle:icon:onSent:

Assigns a custom title and icon to the sports app on the watch.

- (void)sportsSetTitle:(NSString *)title icon:(UIImage *)icon onSent:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent

Parameters

title
The custom title (max. 20 bytes of UTF-8 string)
icon
The custom icon (max. 32x32 pixels, black/white only). This image cannot be nil.
onSent
The handler that will be called when the title and icon have been set or timed out. watch: the recipient of the custom title and icon. error: nil if the operation was successful, or else an NSError with more information on why it failed.

Discussion

Must be called from the main thread.

It is recommended to perform this as the first call after sportsGetIsSupported: to avoid changing the title and icon while it is being displayed in the menu as to avoid confusion.

Declared In

PBWatch+Sports.h