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
55f64400
Commit
55f64400
authored
Jan 18, 2017
by
skleest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save mindfulness session
parent
906ba45b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
0 deletions
+71
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.h
+13
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.m
+47
-0
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
+4
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+6
-0
constants.js
constants.js
+1
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.h
0 → 100644
View file @
55f64400
//
// RCTAppleHealthKit+Methods_Mindfulness.h
// RCTAppleHealthKit
//
//
#import "RCTAppleHealthKit.h"
@interface
RCTAppleHealthKit
(
Methods_Mindfulness
)
-
(
void
)
mindfulness_saveMindfulSession
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
@end
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.m
0 → 100644
View file @
55f64400
//
// RCTAppleHealthKit+Methods_Mindfulness.m
// RCTAppleHealthKit
//
//
#import "RCTAppleHealthKit+Methods_Mindfulness.h"
#import "RCTAppleHealthKit+Queries.h"
#import "RCTAppleHealthKit+Utils.h"
@implementation
RCTAppleHealthKit
(
Methods_Sleep
)
-
(
void
)
mindfulness_saveMindfulSession
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
NSDate
*
startDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"startDate"
withDefault
:
nil
];
NSDate
*
endDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"endDate"
withDefault
:
[
NSDate
date
]];
if
(
startDate
==
nil
||
endDate
==
nil
){
callback
(@[
RCTMakeError
(
@"startDate and endDate are required in options"
,
nil
,
nil
)]);
return
;
}
// original
HKQuantity
*
quantity
=
[
HKQuantity
quantityWithUnit
:
unit
doubleValue
:
value
];
HKQuantityType
*
type
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierStepCount
];
HKQuantitySample
*
sample
=
[
HKQuantitySample
categorySampleWithType
:
type
quantity
:
quantity
startDate
:
startDate
endDate
:
endDate
];
// new
HKCategoryType
*
type
=
[
HKCategoryType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierMindfulSession
];
HKCategorySample
*
sample
=
[
HKCategorySample
categorySampleWithType
:
type
value
:
nil
startDate
:
startDate
endDate
:
endDate
];
[
self
.
healthStore
saveObject
:
sample
withCompletion
:
^
(
BOOL
success
,
NSError
*
error
)
{
if
(
!
success
)
{
NSLog
(
@"An error occured saving the mindful session sample %@. The error was: %@."
,
sample
,
error
);
callback
(@[
RCTMakeError
(
@"An error occured saving the step count sample"
,
error
,
nil
)]);
return
;
}
callback
(@[[
NSNull
null
],
@
(
value
)]);
}];
}
@end
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
View file @
55f64400
...
@@ -47,6 +47,8 @@
...
@@ -47,6 +47,8 @@
@"BloodGlucose"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBloodGlucose
],
@"BloodGlucose"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBloodGlucose
],
// Sleep
// Sleep
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
// Mindfulness
@"MindfulSession"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierMindfulSession
],
};
};
return
readPerms
;
return
readPerms
;
}
}
...
@@ -73,6 +75,8 @@
...
@@ -73,6 +75,8 @@
@"DietaryEnergy"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierDietaryEnergyConsumed
],
@"DietaryEnergy"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierDietaryEnergyConsumed
],
// Sleep
// Sleep
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
// Mindfulness
@"MindfulSession"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierMindfulSession
],
};
};
return
writePerms
;
return
writePerms
;
}
}
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
55f64400
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#import "RCTAppleHealthKit+Methods_Vitals.h"
#import "RCTAppleHealthKit+Methods_Vitals.h"
#import "RCTAppleHealthKit+Methods_Results.h"
#import "RCTAppleHealthKit+Methods_Results.h"
#import "RCTAppleHealthKit+Methods_Sleep.h"
#import "RCTAppleHealthKit+Methods_Sleep.h"
#import "RCTAppleHealthKit+Methods_Mindfulness.h"
#import "RCTBridge.h"
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
#import "RCTEventDispatcher.h"
...
@@ -164,6 +165,11 @@ RCT_EXPORT_METHOD(getInfo:(NSDictionary *)input callback:(RCTResponseSenderBlock
...
@@ -164,6 +165,11 @@ RCT_EXPORT_METHOD(getInfo:(NSDictionary *)input callback:(RCTResponseSenderBlock
[
self
getModuleInfo
:
input
callback
:
callback
];
[
self
getModuleInfo
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
saveMindfulSession
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
mindfulness_saveMindfulSession
:
input
callback
:
callback
];
}
-
(
void
)
isHealthKitAvailable
:(
RCTResponseSenderBlock
)
callback
-
(
void
)
isHealthKitAvailable
:(
RCTResponseSenderBlock
)
callback
{
{
...
...
constants.js
View file @
55f64400
...
@@ -26,6 +26,7 @@ const PERMISSIONS = {
...
@@ -26,6 +26,7 @@ const PERMISSIONS = {
RespiratoryRate
:
'
RespiratoryRate
'
,
RespiratoryRate
:
'
RespiratoryRate
'
,
BloodGlucose
:
'
BloodGlucose
'
,
BloodGlucose
:
'
BloodGlucose
'
,
SleepAnalysis
:
'
SleepAnalysis
'
,
SleepAnalysis
:
'
SleepAnalysis
'
,
MindfulSession
:
'
MindfulSession
'
,
};
};
...
...
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