Skip to content

Commit ff0d261

Browse files
authored
Merge pull request #56 from shilangyu/feat/check-availability
Add isAvailable method
2 parents 5954841 + 86c099f commit ff0d261

12 files changed

+119
-238
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.pub/
66

77
build/
8+
pubspec.lock

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
platform :ios, '9.0'
2+
platform :ios, '11.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Podfile.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ PODS:
44
- Flutter
55
- health_kit_reporter (2.1.0):
66
- Flutter
7-
- HealthKitReporter
8-
- HealthKitReporter (2.0.0)
7+
- HealthKitReporter (= 3.0.0)
8+
- HealthKitReporter (3.0.0)
99

1010
DEPENDENCIES:
1111
- Flutter (from `Flutter`)
@@ -25,11 +25,11 @@ EXTERNAL SOURCES:
2525
:path: ".symlinks/plugins/health_kit_reporter/ios"
2626

2727
SPEC CHECKSUMS:
28-
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
28+
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
2929
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
30-
health_kit_reporter: c42352ae9e6ba3035618f27aec723833487ceab3
31-
HealthKitReporter: 85bbd047c01cf75fe8958de380048363c31b48d8
30+
health_kit_reporter: cc8b2973fd907efbafc8cb48795fd4af59e00a4e
31+
HealthKitReporter: 3511fd29070917a255fa60df7f415c2007f74b73
3232

33-
PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa
33+
PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d
3434

35-
COCOAPODS: 1.11.2
35+
COCOAPODS: 1.12.0

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@
353353
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
354354
GCC_WARN_UNUSED_FUNCTION = YES;
355355
GCC_WARN_UNUSED_VARIABLE = YES;
356-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
356+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
357357
MTL_ENABLE_DEBUG_INFO = NO;
358358
SDKROOT = iphoneos;
359359
SUPPORTED_PLATFORMS = iphoneos;
@@ -445,7 +445,7 @@
445445
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
446446
GCC_WARN_UNUSED_FUNCTION = YES;
447447
GCC_WARN_UNUSED_VARIABLE = YES;
448-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
448+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
449449
MTL_ENABLE_DEBUG_INFO = YES;
450450
ONLY_ACTIVE_ARCH = YES;
451451
SDKROOT = iphoneos;
@@ -495,7 +495,7 @@
495495
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
496496
GCC_WARN_UNUSED_FUNCTION = YES;
497497
GCC_WARN_UNUSED_VARIABLE = YES;
498-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
498+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
499499
MTL_ENABLE_DEBUG_INFO = NO;
500500
SDKROOT = iphoneos;
501501
SUPPORTED_PLATFORMS = iphoneos;

example/pubspec.lock

Lines changed: 72 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,58 @@ packages:
55
dependency: transitive
66
description:
77
name: async
8-
url: "https://pub.dartlang.org"
8+
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
9+
url: "https://pub.dev"
910
source: hosted
10-
version: "2.8.2"
11+
version: "2.10.0"
1112
boolean_selector:
1213
dependency: transitive
1314
description:
1415
name: boolean_selector
15-
url: "https://pub.dartlang.org"
16+
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
17+
url: "https://pub.dev"
1618
source: hosted
17-
version: "2.1.0"
19+
version: "2.1.1"
1820
characters:
1921
dependency: transitive
2022
description:
2123
name: characters
22-
url: "https://pub.dartlang.org"
23-
source: hosted
24-
version: "1.2.0"
25-
charcode:
26-
dependency: transitive
27-
description:
28-
name: charcode
29-
url: "https://pub.dartlang.org"
24+
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
25+
url: "https://pub.dev"
3026
source: hosted
31-
version: "1.3.1"
27+
version: "1.2.1"
3228
clock:
3329
dependency: transitive
3430
description:
3531
name: clock
36-
url: "https://pub.dartlang.org"
32+
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
33+
url: "https://pub.dev"
3734
source: hosted
38-
version: "1.1.0"
35+
version: "1.1.1"
3936
collection:
4037
dependency: transitive
4138
description:
4239
name: collection
43-
url: "https://pub.dartlang.org"
40+
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
41+
url: "https://pub.dev"
4442
source: hosted
45-
version: "1.16.0"
43+
version: "1.17.0"
4644
cupertino_icons:
4745
dependency: "direct main"
4846
description:
4947
name: cupertino_icons
50-
url: "https://pub.dartlang.org"
48+
sha256: "1989d917fbe8e6b39806207df5a3fdd3d816cbd090fac2ce26fb45e9a71476e5"
49+
url: "https://pub.dev"
5150
source: hosted
5251
version: "1.0.4"
5352
fake_async:
5453
dependency: transitive
5554
description:
5655
name: fake_async
57-
url: "https://pub.dartlang.org"
56+
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
57+
url: "https://pub.dev"
5858
source: hosted
59-
version: "1.3.0"
59+
version: "1.3.1"
6060
flutter:
6161
dependency: "direct main"
6262
description: flutter
@@ -66,14 +66,16 @@ packages:
6666
dependency: "direct main"
6767
description:
6868
name: flutter_local_notifications
69-
url: "https://pub.dartlang.org"
69+
sha256: "861dd7a5c15606de973211095a7e18df5cafa7474e5bc196896da8e9d0eb39cd"
70+
url: "https://pub.dev"
7071
source: hosted
7172
version: "5.0.0+4"
7273
flutter_local_notifications_platform_interface:
7374
dependency: transitive
7475
description:
7576
name: flutter_local_notifications_platform_interface
76-
url: "https://pub.dartlang.org"
77+
sha256: "60a02e35c59420d8a4af29a722512adc3c544206adf0338e0dfa902b463bf8e8"
78+
url: "https://pub.dev"
7779
source: hosted
7880
version: "3.0.0"
7981
flutter_test:
@@ -88,46 +90,60 @@ packages:
8890
relative: true
8991
source: path
9092
version: "2.1.0"
93+
js:
94+
dependency: transitive
95+
description:
96+
name: js
97+
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
98+
url: "https://pub.dev"
99+
source: hosted
100+
version: "0.6.5"
91101
matcher:
92102
dependency: transitive
93103
description:
94104
name: matcher
95-
url: "https://pub.dartlang.org"
105+
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
106+
url: "https://pub.dev"
96107
source: hosted
97-
version: "0.12.11"
108+
version: "0.12.13"
98109
material_color_utilities:
99110
dependency: transitive
100111
description:
101112
name: material_color_utilities
102-
url: "https://pub.dartlang.org"
113+
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
114+
url: "https://pub.dev"
103115
source: hosted
104-
version: "0.1.4"
116+
version: "0.2.0"
105117
meta:
106118
dependency: transitive
107119
description:
108120
name: meta
109-
url: "https://pub.dartlang.org"
121+
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
122+
url: "https://pub.dev"
110123
source: hosted
111-
version: "1.7.0"
124+
version: "1.8.0"
112125
path:
113126
dependency: transitive
114127
description:
115128
name: path
116-
url: "https://pub.dartlang.org"
129+
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
130+
url: "https://pub.dev"
117131
source: hosted
118-
version: "1.8.1"
132+
version: "1.8.2"
119133
platform:
120134
dependency: transitive
121135
description:
122136
name: platform
123-
url: "https://pub.dartlang.org"
137+
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
138+
url: "https://pub.dev"
124139
source: hosted
125140
version: "3.1.0"
126141
plugin_platform_interface:
127142
dependency: transitive
128143
description:
129144
name: plugin_platform_interface
130-
url: "https://pub.dartlang.org"
145+
sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757"
146+
url: "https://pub.dev"
131147
source: hosted
132148
version: "2.1.2"
133149
sky_engine:
@@ -139,58 +155,66 @@ packages:
139155
dependency: transitive
140156
description:
141157
name: source_span
142-
url: "https://pub.dartlang.org"
158+
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
159+
url: "https://pub.dev"
143160
source: hosted
144-
version: "1.8.2"
161+
version: "1.9.1"
145162
stack_trace:
146163
dependency: transitive
147164
description:
148165
name: stack_trace
149-
url: "https://pub.dartlang.org"
166+
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
167+
url: "https://pub.dev"
150168
source: hosted
151-
version: "1.10.0"
169+
version: "1.11.0"
152170
stream_channel:
153171
dependency: transitive
154172
description:
155173
name: stream_channel
156-
url: "https://pub.dartlang.org"
174+
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
175+
url: "https://pub.dev"
157176
source: hosted
158-
version: "2.1.0"
177+
version: "2.1.1"
159178
string_scanner:
160179
dependency: transitive
161180
description:
162181
name: string_scanner
163-
url: "https://pub.dartlang.org"
182+
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
183+
url: "https://pub.dev"
164184
source: hosted
165-
version: "1.1.0"
185+
version: "1.2.0"
166186
term_glyph:
167187
dependency: transitive
168188
description:
169189
name: term_glyph
170-
url: "https://pub.dartlang.org"
190+
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
191+
url: "https://pub.dev"
171192
source: hosted
172-
version: "1.2.0"
193+
version: "1.2.1"
173194
test_api:
174195
dependency: transitive
175196
description:
176197
name: test_api
177-
url: "https://pub.dartlang.org"
198+
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
199+
url: "https://pub.dev"
178200
source: hosted
179-
version: "0.4.9"
201+
version: "0.4.16"
180202
timezone:
181203
dependency: transitive
182204
description:
183205
name: timezone
184-
url: "https://pub.dartlang.org"
206+
sha256: f60f389b14643ee90a3ab96ae414f77b0472e3817b5b4bf5cc9ce81ec0113f78
207+
url: "https://pub.dev"
185208
source: hosted
186209
version: "0.7.0"
187210
vector_math:
188211
dependency: transitive
189212
description:
190213
name: vector_math
191-
url: "https://pub.dartlang.org"
214+
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
215+
url: "https://pub.dev"
192216
source: hosted
193-
version: "2.1.2"
217+
version: "2.1.4"
194218
sdks:
195-
dart: ">=2.17.0-0 <3.0.0"
219+
dart: ">=2.18.0 <3.0.0"
196220
flutter: ">=1.20.0"

ios/Classes/EventChannel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum EventChannel: String, CaseIterable {
1212
case statisticsCollectionQuery = "health_kit_reporter_event_channel_statistics_collection_query"
1313
case activitySummaryQuery = "health_kit_reporter_event_channel_query_activity_summary"
1414
case anchoredObjectQuery = "health_kit_reporter_event_channel_anchored_object_query"
15-
15+
1616
func combinedWith(identifier: String) -> String {
1717
"\(self.rawValue)_\(identifier)"
1818
}

ios/Classes/Extensions+SwiftHealthKitReporterPlugin.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import HealthKitReporter
1111
// MARK: - MethodCall
1212
extension SwiftHealthKitReporterPlugin {
1313
private enum Method: String {
14+
case isAvailable
1415
case requestAuthorization
1516
case preferredUnits
1617
case characteristicsQuery
@@ -38,27 +39,36 @@ extension SwiftHealthKitReporterPlugin {
3839
}
3940

4041
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
41-
guard let reporter = self.reporter else {
42+
guard let method = Method(rawValue: call.method) else {
4243
result(
4344
FlutterError(
4445
code: className,
45-
message: "Reporter is nil",
46-
details: nil
46+
message: "Please check the method",
47+
details: "Provided method: \(call.method)"
4748
)
4849
)
4950
return
5051
}
51-
guard let method = Method(rawValue: call.method) else {
52+
53+
if method == .isAvailable {
54+
result(HealthKitReporter.isHealthDataAvailable)
55+
return
56+
}
57+
58+
guard let reporter = self.reporter else {
5259
result(
5360
FlutterError(
5461
code: className,
55-
message: "Please check the method",
56-
details: "Provided method: \(call.method)"
62+
message: "HealthKit is not available",
63+
details: nil
5764
)
5865
)
5966
return
6067
}
68+
6169
switch method {
70+
case .isAvailable:
71+
result(HealthKitReporter.isHealthDataAvailable)
6272
case .requestAuthorization:
6373
guard let arguments = call.arguments as? [String: [String]] else {
6474
throwNoArgumentsError(result: result)
@@ -1540,4 +1550,3 @@ extension SwiftHealthKitReporterPlugin {
15401550
)
15411551
}
15421552
}
1543-

ios/Classes/StreamHandlerProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public protocol StreamHandlerProtocol: FlutterStreamHandler & NSObjectProtocol {
1313
var plannedQueries: Set<Query> { get set }
1414

1515
func setQueries(arguments: [String: Any], events: @escaping FlutterEventSink) throws
16-
16+
1717
static func make(with reporter: HealthKitReporter) -> Self
1818
}

0 commit comments

Comments
 (0)