@tryvital/vital-health-react-native 5.3.3 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.plugin.js +42 -10
- package/lib/commonjs/app.plugin.js +42 -10
- package/package.json +2 -2
package/app.plugin.js
CHANGED
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
withAppDelegate,
|
|
6
6
|
} = require('@expo/config-plugins');
|
|
7
7
|
const { withPlugins } = require('@expo/config-plugins');
|
|
8
|
-
const { addObjcImports, insertContentsInsideObjcFunctionBlock } = require('@expo/config-plugins/build/ios/codeMod');
|
|
8
|
+
const { addObjcImports, insertContentsInsideObjcFunctionBlock, addSwiftImports, insertContentsInsideSwiftFunctionBlock } = require('@expo/config-plugins/build/ios/codeMod');
|
|
9
9
|
|
|
10
10
|
const HEALTH_SHARE = 'Allow $(PRODUCT_NAME) to check health info';
|
|
11
11
|
|
|
@@ -48,15 +48,47 @@ const withHealthKit = (config, { healthSharePermission } = {}) => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
config = withAppDelegate(config, (config) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
const { modResults, sdkVersion = "0.1.0" } = config;
|
|
52
|
+
const { language } = modResults;
|
|
53
|
+
|
|
54
|
+
if (language !== "objc" && language !== "objcpp" && language !== "swift") {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Cannot modify the project AppDelegate as it's not in a supported language: ${language}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let source = config.modResults.contents;
|
|
61
|
+
|
|
62
|
+
if (language === "swift") {
|
|
63
|
+
source = addSwiftImports(source, ['VitalHealthKit']);
|
|
64
|
+
|
|
65
|
+
const autoConfig = "VitalHealthKitClient.automaticConfiguration()";
|
|
66
|
+
const hasAutoConfig = source.includes(autoConfig);
|
|
67
|
+
|
|
68
|
+
if (!hasAutoConfig) {
|
|
69
|
+
source = insertContentsInsideSwiftFunctionBlock(
|
|
70
|
+
source,
|
|
71
|
+
'application(_:didFinishLaunchingWithOptions:)',
|
|
72
|
+
autoConfig,
|
|
73
|
+
{ position: "head" },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
} else {
|
|
78
|
+
source = addObjcImports(source, ['"VitalHealthKitConfiguration.h"']);
|
|
79
|
+
|
|
80
|
+
const autoConfig = "[VitalHealthKitConfiguration automaticConfiguration];";
|
|
81
|
+
const hasAutoConfig = source.includes(autoConfig);
|
|
82
|
+
|
|
83
|
+
if (!hasAutoConfig) {
|
|
84
|
+
source = insertContentsInsideObjcFunctionBlock(
|
|
85
|
+
source,
|
|
86
|
+
'application didFinishLaunchingWithOptions:',
|
|
87
|
+
autoConfig,
|
|
88
|
+
{ position: "head" },
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
60
92
|
|
|
61
93
|
config.modResults.contents = source;
|
|
62
94
|
return config;
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
withAppDelegate,
|
|
6
6
|
} = require('@expo/config-plugins');
|
|
7
7
|
const { withPlugins } = require('@expo/config-plugins');
|
|
8
|
-
const { addObjcImports, insertContentsInsideObjcFunctionBlock } = require('@expo/config-plugins/build/ios/codeMod');
|
|
8
|
+
const { addObjcImports, insertContentsInsideObjcFunctionBlock, addSwiftImports, insertContentsInsideSwiftFunctionBlock } = require('@expo/config-plugins/build/ios/codeMod');
|
|
9
9
|
|
|
10
10
|
const HEALTH_SHARE = 'Allow $(PRODUCT_NAME) to check health info';
|
|
11
11
|
|
|
@@ -48,15 +48,47 @@ const withHealthKit = (config, { healthSharePermission } = {}) => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
config = withAppDelegate(config, (config) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
const { modResults, sdkVersion = "0.1.0" } = config;
|
|
52
|
+
const { language } = modResults;
|
|
53
|
+
|
|
54
|
+
if (language !== "objc" && language !== "objcpp" && language !== "swift") {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Cannot modify the project AppDelegate as it's not in a supported language: ${language}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let source = config.modResults.contents;
|
|
61
|
+
|
|
62
|
+
if (language === "swift") {
|
|
63
|
+
source = addSwiftImports(source, ['VitalHealthKit']);
|
|
64
|
+
|
|
65
|
+
const autoConfig = "VitalHealthKitClient.automaticConfiguration()";
|
|
66
|
+
const hasAutoConfig = source.includes(autoConfig);
|
|
67
|
+
|
|
68
|
+
if (!hasAutoConfig) {
|
|
69
|
+
source = insertContentsInsideSwiftFunctionBlock(
|
|
70
|
+
source,
|
|
71
|
+
'application(_:didFinishLaunchingWithOptions:)',
|
|
72
|
+
autoConfig,
|
|
73
|
+
{ position: "head" },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
} else {
|
|
78
|
+
source = addObjcImports(source, ['"VitalHealthKitConfiguration.h"']);
|
|
79
|
+
|
|
80
|
+
const autoConfig = "[VitalHealthKitConfiguration automaticConfiguration];";
|
|
81
|
+
const hasAutoConfig = source.includes(autoConfig);
|
|
82
|
+
|
|
83
|
+
if (!hasAutoConfig) {
|
|
84
|
+
source = insertContentsInsideObjcFunctionBlock(
|
|
85
|
+
source,
|
|
86
|
+
'application didFinishLaunchingWithOptions:',
|
|
87
|
+
autoConfig,
|
|
88
|
+
{ position: "head" },
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
60
92
|
|
|
61
93
|
config.modResults.contents = source;
|
|
62
94
|
return config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvital/vital-health-react-native",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"description": "Client to access iOS's HealthKit and Android HealthConnect",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"registry": "https://registry.npmjs.org/"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@tryvital/vital-core-react-native": "5.3.
|
|
53
|
+
"@tryvital/vital-core-react-native": "5.3.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "*",
|