Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rn-apple-healthkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ym
rn-apple-healthkit
Commits
72c1cad3
Commit
72c1cad3
authored
Apr 16, 2018
by
王品堯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
時間格式換成timestamp
parent
c85fc759
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
51 deletions
+12
-51
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+12
-51
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
72c1cad3
...
...
@@ -79,8 +79,8 @@
HKQuantity
*
quantity
=
sample
.
quantity
;
double
value
=
[
quantity
doubleValueForUnit
:
unit
];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601String
FromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601String
FromDate
:
sample
.
endDate
];
int
startDateTimestamp
=
[
RCTAppleHealthKit
buildTimestamp
FromDate
:
sample
.
startDate
];
int
endDateTimestamp
=
[
RCTAppleHealthKit
buildTimestamp
FromDate
:
sample
.
endDate
];
NSString
*
deviceName
=
sample
.
device
.
name
?
sample
.
device
.
name
:
@""
;
NSString
*
deviceManufacturer
=
sample
.
device
.
manufacturer
?
sample
.
device
.
manufacturer
:
@""
;
...
...
@@ -98,8 +98,8 @@
NSDictionary
*
elem
=
@{
@"value"
:
@
(
value
),
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
@"startDate"
:
@
(
startDateTimestamp
)
,
@"endDate"
:
@
(
endDateTimestamp
)
,
@"deviceName"
:
deviceName
,
@"deviceManufacturer"
:
deviceManufacturer
,
@"deviceHardware"
:
deviceHardwareVer
,
...
...
@@ -166,26 +166,11 @@
// HKCategoryType *catType = sample.categoryType;
NSInteger
val
=
sample
.
value
;
// HKQuantity *quantity = sample.quantity;
// double value = [quantity doubleValueForUnit:unit];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
int
startDateTimestamp
=
[
RCTAppleHealthKit
buildTimestampFromDate
:
sample
.
startDate
];
int
endDateTimestamp
=
[
RCTAppleHealthKit
buildTimestampFromDate
:
sample
.
endDate
];
NSString
*
valueString
=
[
NSString
stringWithFormat
:
@"%d"
,
val
];
// switch (val) {
// case HKCategoryValueSleepAnalysisInBed:
// valueString = @"INBED";
// break;
// case HKCategoryValueSleepAnalysisAsleep:
// valueString = @"ASLEEP";
// break;
// default:
// valueString = @"UNKNOWN";
// break;
// }
NSString
*
deviceName
=
sample
.
device
.
name
?
sample
.
device
.
name
:
@""
;
NSString
*
deviceManufacturer
=
sample
.
device
.
manufacturer
?
sample
.
device
.
manufacturer
:
@""
;
NSString
*
deviceHardwareVer
=
sample
.
device
.
hardwareVersion
?
sample
.
device
.
hardwareVersion
:
@""
;
...
...
@@ -202,8 +187,8 @@
NSDictionary
*
elem
=
@{
@"value"
:
valueString
,
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
@"startDate"
:
@
(
startDateTimestamp
)
,
@"endDate"
:
@
(
endDateTimestamp
)
,
@"deviceName"
:
deviceName
,
@"deviceManufacturer"
:
deviceManufacturer
,
@"deviceHardware"
:
deviceHardwareVer
,
...
...
@@ -222,22 +207,9 @@
}
};
// HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:quantityType
// predicate:predicate
// limit:lim
// sortDescriptors:@[timeSortDescriptor]
// resultsHandler:handlerBlock];
HKCategoryType
*
categoryType
=
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
];
// HKCategorySample *categorySample =
// [HKCategorySample categorySampleWithType:categoryType
// value:value
// startDate:startDate
// endDate:endDate];
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
categoryType
predicate:
predicate
limit:
lim
...
...
@@ -249,17 +221,6 @@
}
-
(
void
)
fetchCorrelationSamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
...
...
@@ -287,13 +248,13 @@
dispatch_async
(
dispatch_get_main_queue
(),
^
{
for
(
HKCorrelation
*
sample
in
results
)
{
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601String
FromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601String
FromDate
:
sample
.
endDate
];
int
startDateTimestamp
=
[
RCTAppleHealthKit
buildTimestamp
FromDate
:
sample
.
startDate
];
int
endDateTimestamp
=
[
RCTAppleHealthKit
buildTimestamp
FromDate
:
sample
.
endDate
];
NSDictionary
*
elem
=
@{
@"correlation"
:
sample
,
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
@"startDate"
:
@
(
startDateTimestamp
)
,
@"endDate"
:
@
(
endDateTimestamp
)
,
};
[
data
addObject
:
elem
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment