Skip to content

Package not finding NSHealthShareUsageDescription in app.json #346

@razzfox

Description

@razzfox

Hi! 👋

Firstly, thanks for your work on this project! 🙂

My app could not compile with the simple version of the plugin:

  "expo": {
    "plugins": ["@kingstinct/react-native-healthkit"]
  }
}

Only when I added the full version could it work:

  "expo": {
    "plugins": [
      ["@kingstinct/react-native-healthkit", {
        "NSHealthShareUsageDescription": "Your own custom usage description",
        "NSHealthUpdateUsageDescription": "Your own custom usage description",
        "background": true
      }]
    ]
  }
}

I normally have NSHealthShareUsageDescription in another part of my app.json config:

{
  expo {
    ios: {
      infoPlist: {
        NSHealthShareUsageDescription: 'Share activity data with $(PRODUCT_NAME)',
        NSHealthUpdateUsageDescription: 'Share activity data from $(PRODUCT_NAME)',
      }
    }
  }
}

And I use

Here is the diff that solved my problem:

diff --git a/node_modules/@kingstinct/react-native-healthkit/app.plugin.js b/node_modules/@kingstinct/react-native-healthkit/app.plugin.js
index e177bd7..37bb02c 100644
--- a/node_modules/@kingstinct/react-native-healthkit/app.plugin.js
+++ b/node_modules/@kingstinct/react-native-healthkit/app.plugin.js
@@ -59,12 +59,12 @@ const withInfoPlistPlugin = (
 ) =>
   withInfoPlist(config, (config) => {
     config.modResults.NSHealthShareUsageDescription =
-      typeof props.NSHealthShareUsageDescription === 'string'
+      typeof props?.NSHealthShareUsageDescription === 'string'
         ? props.NSHealthShareUsageDescription
         : `${config.name} wants to read your health data`
 
     config.modResults.NSHealthUpdateUsageDescription =
-      typeof props.NSHealthUpdateUsageDescription === 'string'
+      typeof props?.NSHealthUpdateUsageDescription === 'string'
         ? props.NSHealthUpdateUsageDescription
         : `${config.name} wants to update your health data`
 

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions