-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathPBWatch+Golf.h
204 lines (184 loc) · 6.25 KB
/
PBWatch+Golf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//
// PBWatch+Golf.h
// PebbleKit
//
// Created by Martijn The on 4/4/13.
// Copyright (c) 2013 Pebble Technology. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <PebbleKit-Static/PBDefines.h>
#import <PebbleKit-Static/PBWatch.h>
NS_ASSUME_NONNULL_BEGIN
@class UIImage;
/**
* The UUID of the Golf watch app.
*/
PB_EXTERN NSUUID *PBGolfUUID;
/**
* The key of the "Front" field.
*
* The accompanying value must be an `NSString` (max. ~5 characters).
*
* @see -[PBWatch golfAppUpdate:onSent:]
*/
PB_EXTERN NSNumber *PBGolfFrontKey;
/**
* The key of the "Mid" field.
*
* The accompanying value must be an `NSString` (max. ~5 characters).
*
* @see -[PBWatch golfAppUpdate:onSent:]
*/
PB_EXTERN NSNumber *PBGolfMidKey;
/**
* The key of the "Back" field.
*
* The accompanying value must be an `NSString` (max. ~5 characters).
*
* @see -[PBWatch golfAppUpdate:onSent:]
*/
PB_EXTERN NSNumber *PBGolfBackKey;
/**
* The key of the "Hole" field.
*
* The accompanying value must be an `NSString` (max. ~5 characters).
*
* @see -[PBWatch golfAppUpdate:onSent:]
*/
PB_EXTERN NSNumber *PBGolfHoleKey;
/**
* The key of the "Par" field.
*
* The accompanying value must be an `NSString` (max. ~5 characters).
*
* @see -[PBWatch golfAppUpdate:onSent:]
*/
PB_EXTERN NSNumber *PBGolfParKey;
/**
* The command IDs that can be sent back by the Golf watch app.
*
* @see -[PBWatch golfAppAddReceiveUpdateHandler:]
*/
typedef NS_ENUM(uint8_t, GolfAppCommand) {
GolfAppCommandPrevious = 0x01,
GolfAppCommandNext = 0x02,
GolfAppCommandSelect = 0x03,
};
@interface PBWatch (Golf)
/**
* Queries the watch whether Golf Messages are supported.
*
* Must be called from the main thread.
*
* @param 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.
*/
- (void)golfGetIsSupported:(void(^)(PBWatch *watch, BOOL isGolfSupported))fetchedBlock;
/**
* Send a command to launch the golf app on the watch that the receiver
* represents.
*
* Must be called from the main thread.
*
* @param 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.
*/
- (void)golfAppLaunch:(void(^ __nullable)(PBWatch *watch, NSError *__nullable error))onSent;
/**
* Send a command to kill the golf app on the watch that the receiver
* represents.
*
* Must be called from the main thread.
*
* @param 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.
*/
- (void)golfAppKill:(void(^ __nullable)(PBWatch *watch, NSError *__nullable error))onSent;
/**
* Sends an update to the golf app on the watch that the receiver represents.
* Must be called from the main thread.
*
* @param 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.
* @param 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.
*
* @see PBGolfFrontKey
* @see PBGolfMidKey
* @see PBGolfBackKey
* @see PBGolfHoleKey
* @see PBGolfParKey
*/
- (void)golfAppUpdate:(NSDictionary *)update onSent:(void(^ __nullable)(PBWatch *watch, NSError *__nullable error))onSent;
/**
* Add a receive handler for incoming Golf updates that are send by the Golf
* watch application.
*
* Must be called from the main thread.
*
* @param 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 An opaque handle object representing the installed receive handler,
* that can be used in -golfAppRemoveUpdateHandler:
*
* @see GolfAppCommand
* @see -golfAppRemoveUpdateHandler:
*/
- (id)golfAppAddReceiveUpdateHandler:(BOOL(^)(PBWatch *watch, GolfAppCommand command))onReceive;
/**
* Removes a receive handler that was previously installed using
* -golfAppAddReceiveUpdateHandler:
*
* Must be called from the main thread.
*
* @param opaqueHandle The handle object as returned by
* -golfAppAddReceiveUpdateHandler:
*
* @see -golfAppAddReceiveUpdateHandler:
*/
- (void)golfAppRemoveUpdateHandler:(id)opaqueHandle;
/**
* Assigns a custom title and icon to the golf app on the watch.
*
* 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.
*
* @param title The custom title (max. 20 bytes of UTF-8 string)
* @param icon The custom icon (max. 32x32 pixels, black/white only)
* @param 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.
*/
- (void)golfSetTitle:(NSString *)title icon:(UIImage *)icon onSent:(void(^ __nullable)(PBWatch *watch, NSError *__nullable error))onSent;
@end
NS_ASSUME_NONNULL_END