Some questions about Apple Watch - ios

I'm started to working with Apple Watch today.
I'm searched on internet about Apple Watch & watchOS 2, but have some stuck while understand all of them (please for give me for bad English, thanks):
1. Can Apple Watch detect shake motion of user when they're shaking their hand? (I mean like shake to change song when play music, shake to change picture?). In iOS I'm using the function motionBegan, motionEnd to detect it. But don't know how to detect this event on apple watch, seem like Apple doesn't mention it on their document. Can you show me how to detect shake event of user?
2. In example, I have an application running on iOS version. How can I create one more version for Apple Watch that can communicate with my iPhone app?
3. Apple say from watchOS 2, the app can run natively without the iphone. But when I'm created a demo app, I'm still need iphone to build & run. Is there anyway to build & run my app in my watch without the phone?
4. I was created an demo app on watchOS 2, which have an button. Now I want whenever I'm pressed on this button the Siri will appear to recognize my voice. Is Apple let me to access Siri from my own app? If yes, how can I do it in my code?

1. You can access a subset of the CoreMotion API on the AppleWatch. But the use of this API is limited to when the AppleWatch app is active. So if the user has your app active on their wrist they could shake and you could get CoreMotion data to detect what you need. Check out the available APIs on CoreMotion here.
2. Don't really understand the question try to clarify a bit. If you are looking for how to send messages between the iOS and watchOS app check out my post here Send messages between iOS and WatchOS with WatchConnectivity in watchOS2
3. Yes AppleWatch apps in WatchOS2 runs natively. But you still need an iOS app to get the AppleWatch app installed. Apple watch is mainly developed to act as a companion to your phone. So when you install an iOS app you get the choice to install the (if it exists) companion AppleWatch app.
4. Oficially, no. You can´t access the Siri API for now.

Related

Have anyone worked on migrating an iOS app with Watch OS1 to Watch OS2 or higher versions which share data between iPhone & Watch

Have anyone worked on migrating an iOS app with Watch OS1 to Watch OS2 or higher versions. I have used Coredata & Appgroups for sharing data between iPhone app and watch app. Now in the newer Watch OS 2(& above) Apple no longer supports Appgroups to share data across iPhone app & Apple Watch app. Could you please help me in this.
I need to use Coredata to share data between the targets without having Appgroups.
Implement two-way communication between your Apple Watch app and the paired iPhone app with the Watch Connectivity framework.
Apple provided the sample code here
for connectivity between apple watch app and iphone app using latest OS version.
Apple OverView
Most Apple Watch apps require an exchange of data with a paired iPhone app. This sample demonstrates how to use the Watch Connectivity APIs to:
Update application contexts
Send messages
Transfer user info and manage the outstanding transfers
Transfer files, view transfer progress, and manage the outstanding
transfers
Update current complications from iOS apps
Handle Watch Connectivity background tasks
On watchOS 1, the watch app was an app extension that actually ran on the paired phone and the watch simply acted as a remote display. This is why it was possible to share data using an app group, just as you can with any other extension.
From watchOS 2.0 onwards the watch app executes on the watch itself so the watch app and the companion app no longer share a file system.
In fact, where possible, users should be able to use the watch app even when the watch isn't near the paired phone. This means that you need to adopt an asynchronous data sharing approach between the watch and phone apps
You will need to use the Watch Connectivity Framework for your app.

Can an iOS app be added later to an Apple Watch only app?

Beginning with WatchOS 6 Apple makes it possible to ship Watch-only apps. While we can first ship an iOS app and later add a companion app for the Apple Watch, I'm wondering if the reverse is possible as well:
Can we ship an Apple Watch-only app, which is installed via WatchOS App Store directly on the watch and then later add an iOS app to it?
This is important to me as I don't want to put a barrier on front of this option. You may still find out after publishing your watch app that it will profit from having a companion app on the iPhone. Or you might find that your watch app will gain more publicity when its iOS companion app becomes visible in the iOS App Store as well.
Yes, this is simply a matter of going to the project at the top level of the project navigator, then adding a new iOS target to your Apple Watch project.

How to get a Nativescript app on Apple Watch and use Health Data?

I'm trying to set up a basic nativescript app on Apple Watch 3 which reads Heart Rate data. I realize that I would need WatchKit, but how do I set up the app, Sidekick only gives the option of iPhone or iPad.
Also, what's the Nativescript way of writing companion code for the iPhone which will receive this data from the phone?
Apple Watch Integration will be available in next {NS} release.
https://www.nativescript.org/roadmap-and-releases#releases

How can I make my Apple Watch app work without an iPhone?

When my iPhone is not available, my WatchKit app on the Apple Watch does not work (a red crossed-out iPhone symbol appears). How can I make my app work without the iPhone? How do I tell it to use data that is cached on my Apple Watch?
You don't, because this is not how Apple Watch apps work at the moment. Your watch app does not run on the watch, it runs on the iPhone but displays its UI on the watch. When the phone isn't nearby, there's no place to run the code.
Apple has said that stand-alone watch apps will be possible this summer. Probably they'll announce it at WWDC in June.

Understanding interaction between Apple Watch and iPhone device

I am a bit confused as when I run the Apple Watch extension App schema on the simulator I see only that the Apple Watch app gets lunched. However I am not sure what will happen with real hardware once we get our hands on the Apple Watch.
I'd like to understand the following:
Do I need to start the corresponding iPhone App on the phone before
starting the App on the Apple Watch?
If the answer to 1 is no then, can I
start an iPhone App from the App on the Apple Watch? If the answer to 2
is yes then how can I start the iPhone App in a way that is not in
the background? (I found handleWatchKitExtensionRequest can trigger
background tasks but I haven't found any documentation yet for
that - I also found the Handoff Api which allows you to resume a task on the device but I don't like that it requires an iCloud account and I am not sure how to structure an App/watch interaction without forcing the user to adopt iCloud).
Given that the Apple Watch App extension resides on the iPhone App
bundle does this mean that when you start the Apple Watch App it needs a
connection and proximity with the iPhone device? I assume that there will
be a bluetooth connection and that it won't be possible to start
some apps if the user and its watch are away from the Iphone (what's
the range?)
Many Thanks
No.
No.
Unless you are on a Wifi network recognized by both your Watch and your iPhone, they'll need to be relatively close to each other. Guessing at range is useless – a number of factors can impact the useable distance of BTLE.

Resources