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.
Related
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.
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.
I have an app that has been released on the app store with separate versions for iPhone and iPad. Now I wish to convert the app to a Universal version but I have an issue which I'm not sure can be resolved.
Both versions of the app use a different bundle identifier (for example com.mycompany.app.iphone and com.mycompany.app.ipad). I want the new (universal) version to overwrite either of the old versions when downloaded from the app store. To complicate matters further, core data stored for that app needs to be retained.
I'm not sure its possible and perhaps the protocol is to release the universal version under a new bundle identifier and have users start again but if a workaround is available it would be really helpful.
your options:
1: Update both your iPhone and iPad apps with this universal binary (with respective bundleIDs and app names)
2: Create a way to sync data between apps by creating a web service. one of the apps I have used extensively - Gas Cubby, does this for transferring data from its free app to paid app. You could implement it in a similar way
3: Nuke one of the apps, update the other app with the universal binary
Option 1 is the easiest. 2 will take longer. 3 is dirty.
(will update this answer with more options if I come across any)
As far as I know and from what I've read before, you can't change the bundle identifier of an app published in the app store.
Due to the sandboxing, accessing the data of your old app from the new app is also impossible.
There are several ways you could go about solving this issue, depending on which one suits you best. You could create a new universal app, and abandon the old ones hoping that the users change their preferences, or you could be pushing the same update to both applications, essentially, having the identical app under two different names. I'm not sure what are Apple's stances on the second option, but it will be a hassle either way. Good luck!
Is there any way to achieve the following things via my application's code on the iPhone:
API for locking/unlocking the ios 5.0 device
Wipe the device data as in below app
http://www.engadget.com/2010/06/18/apple-launches-find-my-iphone-app/
Language change of the device
Device sound change etc
All of the activities you list here are handled by private methods, and as such, are off limits to App Store developers (and there is no official API to access them). That said, anything is possible if you're willing to forego distribution in the App Store and able to dig into the undocumented features of the native and/or jail broken OS.
I would like to know my iPhone places using Xcode like this app.I know all the details related to my iPhones.Kindly help me how to do this.
The actual Find My iPhone implementation details are certainly private and/or using private Apple frameworks (especially as it's a feature that users have to explicitly turn on and off via Settings and there's no user-facing app), but you could use CoreLocation in an app that you create that runs in the background, reporting your location to some server that your own.
I also found an alternative app named iLostMyi, but this requires a jailbroken phone.