-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathPBPebbleCentral.h
139 lines (109 loc) · 3.84 KB
/
PBPebbleCentral.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
//
// PBPebbleCentral.h
// PebbleSDK-iOS
//
// Created by Martijn Thé on 4/24/12.
// Copyright (c) 2012 Pebble Technology. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <PebbleKit-Static/PBDefines.h>
#import <PebbleKit-Static/PBLog+Public.h>
@class PBWatch;
@class PBDataLoggingService;
@protocol PBPebbleCentralDelegate;
NS_ASSUME_NONNULL_BEGIN
/**
PebbleCentral plays the central role for client iOS apps (e.g. RunKeeper).
*/
PB_EXTERN_CLASS @interface PBPebbleCentral : NSObject
/**
The watches that are currently connected. Do not cache the array because it can change over time.
*/
@property (nonatomic, readonly, copy) NSArray<PBWatch *> *connectedWatches;
/**
The watches that are stored in the user preferences of the application.
*/
@property (nonatomic, readonly, copy) NSArray<PBWatch *> *registeredWatches;
/**
The central's delegate.
*/
@property (nonatomic, readwrite, weak) id<PBPebbleCentralDelegate> __nullable delegate;
/**
* Identifier of the watch application this companion app communicates with.
*
* The identifier is used to make sure that app message and data logging
* communications arrive to the right companion watch app in the watch (and not
* to another app).
*
* For most app message methods there is are two variants: one that does not
* take an UUID parameter and one that does (for example,
* -appMessagesAddReceiveUpdateHandler: vs
* -appMessagesAddReceiveUpdateHandler:withUUID:). The methods that do not take
* an UUID, will use the UUID as set prior to this property.
*
* @note The UUID needs to be set before using either app message or data logging.
*/
@property (nonatomic, copy) NSUUID * __nullable appUUID;
/**
* The list of App-UUIDs this PebbleCentral wants to talk to.
* @see addAppUUID:
*/
@property (nonatomic, copy) NSSet<NSUUID *> *appUUIDs;
/**
* Registers a new App-UUID with appUUIDs.
*
* @param appUUID The app UUID to register.
*
* @see appUUIDs
*/
- (void)addAppUUID:(NSUUID *)appUUID;
/**
Registers and announces internal Bluetooth services. Might cause a dialog to allow this
app to talk to other devices.
*/
- (void)run;
/**
Determines if the Pebble iOS app is installed in the device.
@note Since iOS 9.0 you have to add “pebble” to `LSApplicationQueriesSchemes`
in your application `Info.plist` or this method will return `NO` all the
time.
@return `YES` if the Pebble iOS app is installed, `NO` if it is not installed.
*/
- (BOOL)isMobileAppInstalled;
/**
Redirects to Pebble in the App Store, so the user can install the app.
*/
- (void)installMobileApp;
/**
Wipes out the data associated with the registered watches, that is stored on the phone.
*/
- (void)unregisterAllWatches;
/**
Returns the most recently connected watch from the -registeredWatches array.
*/
- (PBWatch * __nullable)lastConnectedWatch;
/**
* Returns the DataLoggingService for a (previously registered) appUUID
*
* @param appUUID The app UUID to recover the data logging service.
*/
- (PBDataLoggingService *__nullable)dataLoggingServiceForAppUUID:(NSUUID *)appUUID;
@end
@protocol PBPebbleCentralDelegate <NSObject>
@optional
/**
@param central The Pebble Central responsible for calling the delegate method.
@param watch The PBWatch object representing the watch that was connected.
@param isNew YES if the watch has been connected for the first time since the app has been installed or NO if not.
*/
- (void)pebbleCentral:(PBPebbleCentral*)central watchDidConnect:(PBWatch*)watch isNew:(BOOL)isNew;
/**
@param central The Pebble Central responsible for calling the delegate method.
@param watch The PBWatch object representing the watch that was disconnected.
*/
- (void)pebbleCentral:(PBPebbleCentral*)central watchDidDisconnect:(PBWatch*)watch;
@end
@interface PBPebbleCentral (Unavailable)
- (instancetype)init UNAVAILABLE_ATTRIBUTE;
@end
NS_ASSUME_NONNULL_END