-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathPBWatch+AppMessages.h
196 lines (181 loc) · 8.09 KB
/
PBWatch+AppMessages.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
//
// PBWatch+AppMessages.h
// PebbleKit
//
// Created by Martijn The on 3/20/13.
// Copyright (c) 2013 Pebble Technology. All rights reserved.
//
#import <PebbleKit-Static/PBWatch.h>
NS_ASSUME_NONNULL_BEGIN
@interface PBWatch (AppMessages)
/**
* Queries the watch whether AppMessages 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.
* - `isAppMessagesSupported`: `YES` if AppMessages are
* supported, `NO` if not.
*/
- (void)appMessagesGetIsSupported:(void(^)(PBWatch *watch, BOOL isAppMessagesSupported))fetchedBlock __attribute__((deprecated("Method deprecated. Use `getVersionInfo:onTimeout:` and `versionInfo.appMessagesSupported` instead.")));
/**
* Pushes an update to the watch application with UUID as set using
* -[PBPebbleCentral setAppUUID:].
*
* Must be called from the main thread.
*
* @param 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.
* @param 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.
*/
- (void)appMessagesPushUpdate:(NSDictionary<NSNumber *, id> *)dictionary onSent:(void(^ __nullable)(PBWatch *watch, NSDictionary *update, NSError *__nullable error))onSent;
/**
* Pushes an update to the watch application with the specified UUID.
*
* Must be called from the main thread.
*
* @param 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.
* @param appUUID The UUID of the watchapp to which the update should be sent.
* @param 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.
*/
- (void)appMessagesPushUpdate:(NSDictionary<NSNumber *, id> *)dictionary withUUID:(NSUUID *)appUUID onSent:(void(^ __nullable)(PBWatch *watch, NSDictionary *update, NSError *__nullable error))onSent;
/**
* Add a receive handler for incoming updates that are send by the watch
* application with UUID as set using -[PBPebbleCentral setAppUUID:].
*
* Must be called from the main thread.
*
* @param 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 An opaque handle object representing the installed receive handler,
* that can be used in -appMessagesRemoveUpdateHandler:
*
* @see -appMessagesRemoveUpdateHandler:
*/
- (id)appMessagesAddReceiveUpdateHandler:(BOOL(^)(PBWatch *watch, NSDictionary<NSNumber*, id> *update))onReceive;
/**
* Add a receive handler for incoming updates that are send by the watch
* application with the specified UUID.
*
* Must be called from the main thread.
*
* @param 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.
* @param appUUID The UUID of the watchapp for which sent messages should be
* handled by the onReceive block.
*
* @return An opaque handle object representing the installed receive handler,
* that can be used in -appMessagesRemoveUpdateHandler:
*
* @see -appMessagesRemoveUpdateHandler:
*/
- (id)appMessagesAddReceiveUpdateHandler:(BOOL(^)(PBWatch *watch, NSDictionary<NSNumber*, id> *update))onReceive withUUID:(NSUUID *)appUUID;
/**
* Removes a receive handler that was previously installed using
* -appMessagesAddReceiveUpdateHandler:
*
* Must be called from the main thread.
*
* @param opaqueHandle The handle object as returned by
* -appMessagesAddReceiveUpdateHandler:
*
* @see -appMessagesAddReceiveUpdateHandler:
*/
- (void)appMessagesRemoveUpdateHandler:(id)opaqueHandle;
/**
* Sends a command to launch the watch application with UUID as set using
* -[PBPebbleCentral setAppUUID:]
*
* Must be called from the main thread.
*
* @param 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.
*/
- (void)appMessagesLaunch:(void(^ __nullable)(PBWatch *watch, NSError * __nullable error))onSent;
/**
* Sends a command to launch the watch application with the specified UUID.
*
* Must be called from the main thread.
*
* @param 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.
* @param appUUID The UUID of the watch application to launch.
*/
- (void)appMessagesLaunch:(void(^ __nullable)(PBWatch *watch, NSError * __nullable error))onSent withUUID:(NSUUID *)appUUID;
/**
* Sends a command to kill the watch application with UUID as set using
* -[PBPebbleCentral setAppUUID:].
*
* Must be called from the main thread.
*
* @param 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.
*/
- (void)appMessagesKill:(void(^ __nullable)(PBWatch *watch, NSError * __nullable error))onSent;
/**
* Sends a command to kill the watch application with the specified UUID.
*
* Must be called from the main thread.
*
* @param 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.
* @param appUUID The UUID of the watch application to launch.
*/
- (void)appMessagesKill:(void(^ __nullable)(PBWatch *watch, NSError * __nullable error))onSent withUUID:(NSUUID *)appUUID;
@end
NS_ASSUME_NONNULL_END