1

How can we get the data of Healthkit in .net MAUI application? We have this code to get healthdata.

But this code gives me error on HkHealthStore. So how we can access the healthstore in .net MAUI application.

Do we need to do the development only in IOS System or is it possible to do it in Windows system as well?

How can we start the Healthkit app in .net MAUI?

I am trying to make a .net MAUI app in which i can access the Healthkit framework. But there is no document or any suggestion over internet by which i can access the Healthkit framework.

I created a .net MAUI application and copy pasted the Healthdata.cs file but i am getting error on HKHealthStore.

The type or namespace name HKHealthStore could not be found (are you missing a using directive or an assembly reference)

2
  • What is the error you get? Commented Nov 20, 2023 at 10:08
  • The type or namespace name HKHealthStore could not be found(are you missing a using directive or an assembly reference) Commented Nov 20, 2023 at 10:27

1 Answer 1

1

I don't have enough information to determine the definitive error here, but I think I have a pretty good idea.

For Xamarin the projects were all separate so you would always have the dedicated iOS context (or Android, or Windows, etc.) for .NET MAUI, you probably have a single-project, where it's not always clear what the context is that you are in.

For a simple test you could try adding:

#if IOS
    var foo = HealthKit.HKHealthStore.IsHealthDataAvailable;
#endif

This should work. If this becomes greyed out immediately, the IDE/editor you are using is looking at a different context (or build target).

For Visual Studio go to the top-left of your text editor and switch it to iOS:

The target platform switcher drop-down box in Visual Studio 2022

Now the line referencing HealthKit should become active.

From here, you should figure out how you use this platform-specific code from within your shared code as HealthKit is specific to iOS and won't be available on other platforms.

For guidance on that, please check the official documentation here.

Sign up to request clarification or add additional context in comments.

3 Comments

Is it important to have the IOS developer account to run the .NetMaui-Healthkit app in windows system or we have some another way to run it . or we need to run it over IOS system using XCODE. How we can run .NetMaui-Healthkit app on windows sytem ?
To eventually publish your app to the App Store you will need a Mac. If you want to develop on Windows first, you can do that through a solution called Hot Restart. But you will still need a physical iOS device, a paid Apple Developer account and iTunes.
We are using Ios Simulators to run our .NetMaui-Healthcare project. Remotely connected Mac with .netMaui-Healthcare project in Visual Studio(Windows System)Mac is connected sucessfully But when we run the application then we get this error. Error: (Windows\Package.appxmanifest;" is an invalid value for the "AppxManifest" parameter of the "GeneratePackageAppxManifest" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem". Microsoft.Maui targets have been imported multiple times. Please check your project file and remove the duplicate import(s)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.