Access App Info From Watch - ios

Im a bit new to IOS and Swift. I generally use Cordova and let the "magic" behind the curtains unfold when building IOS apps. It seems, however, that developing for Apple Watch using watch kit isn't so "magical".
What I am trying to do is access authentication information via my watch, that was entered into my IOS app; then utilize that info to make API requests which I will parse and present in the apple watch. I don't want users to authenticate using the watch, hence there is some handshaking that needs to be done. Please help, not sure where to get started...

So, I used MMWormholeSession with Cordova in conjuction with WCSession. I had to do some modifications to the MMWormhole code, but all the puzzle pieces were in there.

Related

Share AsyncStorage from iOS react native app with Apple Watch

I'm developing the main app with react native and the Apple Watch with Swift.
The main app (react native) uses AsyncStorage to store some values, that then are used as params for a fetch that shows a list.
After running the simulator, I found manifest.json inside
~/Library/Developer/CoreSimulator/Devices/D10E869B-040B-446F-9B8B-754F111442EC/data/Containers/Data/Application/AC837AFE-312B-4861-906D-EC9EEE7D029B/Document
s/RCTAsyncLocalStorage_V1
with the data inside.
I need to access those values in the Apple Watch in Xcode to do the same job as the iOS app. How do I access that data?
Since Apple Watch apps run independently from iOS app since watchOS 2, there’s really no way to directly access the data stored locally on iPhone — you’ll need to maintain some form of communication between your iOS and watchOS apps.
The framework intended for this is called WatchConnectivity. I see two more-or-less suitable solutions for your case:
Using transferFile to transfer your file from an iOS device to an Apple Watch whenever it got updated. The viability of this option highly depends on how big your file is.
Or you can just use updateApplicationContext to pass an already serialized data instead of transferring a raw JSON file — again, highly depends on your specific needs.
Unfortunately, I don’t know how WatchConnectivity is supposed to work with ReactNative. If you want a deeper introduction to this framework — I highly recommend watching this amazing video from WWDC 2015.

watchOS Show App When Message Received [duplicate]

I know that an apple watch app can launch its parent application in the background to pass data back and forth but can it work the other way around? Can my iOS app launch the related watchOS app?
For a bit more insight, I'm trying to accomplish this so that I can monitor data periodically for the sake of notifications. The 70 seconds apple gives me to keep an app active and pulling data from healthKit isn't conducive to an app that provides alerts to users based on changes in behavior.
I apologize if this is a basic question. I'm new to watchOS development and haven't been able to find the answer to this anywhere. =/
No it cannot happen.
At the moment communication between the Watch and the Device is limited to the Watch App initialising communication with the iOS app and not the other way around.
This might help:
https://developer.apple.com/library//ios/documentation/General/Conceptual/WatchKitProgrammingGuide/SharingData.html#//apple_ref/doc/uid/TP40014969-CH29-SW1
Yes, you can. Try the startWatchApp(with:completion:) func in HealthStore. However, it can only be used in a workout app that enable the background mode of "workout processing".
Unfortunately I think I found the answer here How to programmatically open Apple Watch companion app from iOS app.
It doesn't look like it can be done. If anyone finds otherwise, let me know!

Detect which app is in foreground on iOS9 without jailbreak

I'm trying to log users individual app usage on iOS9.
I'd rather prefer that it wouldn't use jailbreak limited solutions, self explanatory. Doing the variation of this app on a jailbroken phone shouldn't be hard.
This will certainly not be released on the App Store as Apple wouldn't allow it.
I'm looking for any private API that can do this, any hidden iOS API's that can be used to do this. ANYTHING.
What I've already looked through:
how to determine which apps are background and which app is foreground on iOS by application id
How to know about app launched and details jailbreak iOS 7
Is there a private API to be able to detect what is current foreground app on iOS?
How to monitoring App running in the foreground in iOS8?use the PrivateFrameworks SpringBoardServices
which proved to be relatively helpful - we now can assume that there is some sort of additional access requirement, probably an entitlement, but we don't really know how it should look like
Can you find individual app usage duration using SpringBoard services framework or other private framework?
Find out active application or if on Springboard
Programmatically detect which iOS application is visible to user
However all of these proved to be unhelpful because Apple fixed this security flaw with iOS8 and the method to copy/access the currently front most app bundle identifier no longer works.
Question is: Is there someone who knows a workaround using different tools/exploits that do not require jailbreak?
Ideas:
inspecting the processes running on the device and devising an algorithm that would be able to recognize spikes that mean an app has been launched, which potentially could work, but it probably would be a major pain in the ass. Questions mentioning this solution:
Detect which app is currently running on iOS using sysctl,
Return a list of running background apps/processes in iOS
How to get Names of Background Running Apps
Find Background running apps in iphone
inspecting the phones traffic somehow?
not sure if there is some kernel stuff that I could do
Here is my Reddit version of this question if anyone wants to check it out. Also if it's of any value, here are the runtime headers for iOS9 and list of Apple's private API's.
Unfortunately, I was looking for a similar solution and have come to the conclusion that, at least at this point in time, there are no known methods that will allow you to determine app usage on iOS. Even the MDM providers such as Good, Airwatch, MobileIron, etc. don't seem to be able to do this. If anyone is able to come up with a solution, I'd love to see it.
For now, however, I think we would have seen a solution if someone had one that worked on the latest iOS.
sysctl is still open but they block certain combinations of selectors. I did this on iOS 7 and gave Apple Product Security the code. They won't patch iOS 7 but rely on App Review. iPhone 4 is wide open.

Using CoreLocation with Apple Watchkit

The apple iOS/Watch simulator works great with the default Core Location implementation.
However, does this really work with the device later on? Or do I need to build my implementation around a openParentApplication-pattern?
Thanks,
Since your watch extension runs on the phone, it has access to the same features as a normal iOS app and can use CoreLocation. However, it uses the CoreLocation permissions that were granted to your main app, so make sure your main app uses CoreLocation too so that the user will be asked to give your app permission to access those services.
WatchKit extensions have access to the same technologies found in iOS apps but because they are extensions, the use of some technologies may be restricted and the use of others is not recommended.
Apple recommends to avoid using technologies that request user permission, like Core Location.
Using the technology from your WatchKit extension could involve
displaying an unexpected prompt on the user’s iPhone the first time
you make the request. Worse, it could happen at a time when the iPhone
is in the user’s pocket and not visible.
The best solution for performing any long-running tasks is to let your
iOS app perform the task instead. For example, instead of starting
location services in your WatchKit extension, start it in your iOS
app. Your iOS app can gather the needed data and put it in a shared
app group so that your extension can access it later.

How can I get the information which app is foreground in iOS?

Can I get the information about which apps are on foreground, so that controlling the screen and get interaction from user.
I can do it on Android and I want to do it also in iOS.
This is for making an app that monitoring the usages of apps, not for the CPU usage.
Please tell me how could I manage this ?
On jailbroken devices, a quite straighforward solution is to use Ryan Petrich's AppList library.
I'm not sure if this is easy on a stock device, but you might get somewhere using the Mach/XNU API for retrieving process info and searching for a suspected app executable path/name.

Resources