Setting up HealthKit on Independent Apple Watch app - apple-watch

I am creating an independent Apple Watch app that is not linked to an iPhone app. How can I request access to HealthKit data directly from the Apple Watch without requesting the HealthKit data via an iPhone app.
Apple recently announced that developers could now create independent Apple Watch apps in WWDC 2019, but I'm not finding documentation on how to use HealthKit on independent apps. I started following the instructions on this page here
https://developer.apple.com/documentation/healthkit/setting_up_healthkit
but the problem that I'm running into is that I can't figure out how to set the necessary custom messages for NSHealthShareUsageDescription and NSHealthUpdateUsageDescription. Apples documentation says to do this through the Info.plist, but I can't find these options anywhere for the just the Apple Watch.
Can anyone show how to use HealthKit for an independent Apple Watch app?

In Xcode's project navigator on the left, your WatchKit extension group contains the Info.plist where you'll add your NSHealthShareUsageDescription and NSHealthUpdateUsageDescription messages. Add the HealthKit setup and authorization code from the article you linked in say, your extension delegate, and you're good to go.

Related

What plist Changes Are Needed to Enable Apple In App Purchases

I have my MAUI app submitted to the Apple app store, but they are requiring me to provide a way for Apple users to purchase a subscription to the service that our app uses (that we manage through our web site). In the Apple docs, it talks about configuring the app in Xcode to add the capability for in app purchases. I haven't seen the specific plist changes (info and or entitlements) that it is supposed to make to support this, so wondering if there is a method that we can use in Visual Studio to enable the in app purchases?
The documentation for doing it in Xcode is here: https://help.apple.com/xcode/mac/current/#/dev88ff319e7. There's not a lot to describe - it basically walks you through the Xcode UI, you press the plus sign button, select In App Purchases from the list of capabilities and click OK - that's pretty much it. I have not been able to find a plist file though to try and figure out what it did.

How to create a hotspot network in iOS app using Swift

I want to create a hotspot network in iOS app using swift. Also please suggest ony apple approved APIs. Thanks!
NEHotspotHelper is an official API to do exactly this kind of stuff. Though the API is not an 'Open to All' kind. It needs the entitlement 'com.apple.developer.networking.HotspotHelper' to be included in your app. To use this entitlement you need to ask for a permission from Apple to use this class with your app's bundle identifier with a clear reason for why you need it with some other details of your app. Use this link to apply for the entitlement. Once apple sends an approval mail to you, you are good to go!

Communicate data between WatchOS & Today Extension widget

Standard set up for Watch OS > 2.
WCSessionDelegate used to coordinte data between main application and Watch.
An App Group "group.***********.TodayExtensionWidget" used to coordinate data between main application and its Today Extension widget via UserDefaults(suiteName: "group.***********.TodayExtensionWidget")
When I make a change from the watch it communicates that change with the main application. Then the main application (once launched) communicates this on to the Today Extension.
What I would like to do is communicate the change in the watch app to the Today extension without needing to launch the main app first.
Is there a best practice to communicate between a watch app and a Today Extension widget?
At the moment there is no way to achieve this using any built-in frameworks. Since the introduction of watchOS2, WatchKit apps are considered to be independent apps and not just an extension of the iOS app, hence you cannot use AppGroups to share data between the two and especially cannot use it to share data between the WatchKit app and an iOS extension.
As you already experienced, WatchConnectivity cannot be used in a Today extension, so that is out of the picture as well.
Your only option is a suboptimal one, since you will need to upload your data to a server from your watchOS app and download it in your iOS Today extension. This of course generates unnecessary data usage, but with the current frameworks provided by Apple you cannot share the data offline.
However, if you wait until watchOS4 is released (or give the beta version a try), you might be able to leverage the CoreBluetooth framework, which is becoming available for WatchKit in watchOS4 to communicate between a WatchKit app and an iOS extension offline, using BLE. I am not 100% sure if CoreBluetooth can be used in iOS Extensions, but you should give this a try if you can use watchOS4 beta.

share data between iOS 10 Widget and Apple Watch

Let's say we have running widget on iPhone and app on Apple Watch at the same time. How to inform Apple Watch that we have made any changes to the model with widget?
App Groups are not longer supported by Apple Watch so we can't use MMWormhole nor Realm to share database...
Widget does not support Watch Connectivity and I end up with outdated model
How to handle this situation when the main app is closed?
iOS10, watchOS3, Swift 3
MMWormhole apparently also supports the WatchConnectivity framework of watchOS 2, so you should still be able to use it to send data.
Unfortunately, according to this Apple Developer Forum thread (and this SO question), it is simply not possible to use WatchConnectivity from a Today extension. It will always be necessary to pass any data added by the Today Widget back up to the host app, and then have the host app pass the data to the watch.

How to lock down user to Single App mode in iOS 6, Programmatically?

There are some question which are related to this,. but getting the exact answer:
Lock-down iPhone/iPod/iPad so it can only run one app
Recently iOS 6 is introduced with some business oriented features, two of theme are:
Guide Access
Supervised Access
These both deals with Accessibility Control features, Like allow user to restrict access to there device, only if they have full access to the device. In that way this is only useful to people, who owned the device like, a school use there device for exam, a restaurant for menus, for product display etc. All of them have access to the device to configure settings etc.
Now my question begins here, I am thinking of an App, which look down user to single app mode when user run the app and after signing out of the app the device start working as before in normal mode.
Through the time when app is active, user should not able to access any other function or button, this applies on all three device iPad, iPhone, iPod.
Also I found that this could be done by installing some Profiles etc, which looks wired and we can't ask user to do so.
So the simple idea is user will only install the App, as normally he does and we could lock him down to single app mode when he log into the app.
The SureLock iOS app does nothing but inform the user how to do it in your system preferences.
Doing it from the app itself is only possible, if you break the rules about private frameworks. And break it hard.
I am sorry to tell you that the way you present your idea, would never be approved for the AppStore.
The accepted answer to this question is no longer correct:
Starting with iOS 7, UIKit exposes the function UIAccessibilityRequestGuidedAccessSession as public API.
I don’t know, but can very well imagine that this function existed as private API dating back to iOS 6, where the guided access feature was introduced.
Note that for this method to have any effect, the device in question must be supervised using MDM, and the ID of the app you want to use this API must be included in the device management profile deployed to it.
Hi may be I am late but I have a good news for you.
Apple provide a new feature in IOS 7 and we can lock the user to single mode without user permission(Lock and unlock mode) here is the apple documentation link
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIAccessibilityRequestGuidedAccessSession
the other way is to install the profile config profile like is
http://ipadhire.co.nz/lockdown.mobileconfig
it lock the home button of IPhone and enable single mode
For this you have to do following..
access apple's private api's
access apple's private framework
Apple don't encourage accessing there private api's specially when it comes for App Store, if you accessed the private api's at the time of application review on App Store they will reject the app giving you a message of "accessing a private api".