How to implement Socket connection in Watch OS 3.0 - ios

In one of my application we are implementing live stock market update using socket connection and we have implemented it using in iOS app using Socket.io. But we also developing same app in Watch OS 3.0.
But compiler not able to deal with classes of Core Network prefixed with CFas like (CFHTTPMessage) with error of type CFHTTPMessage undeclared type.
So can any one implemented socket connection on Watch OS 3.0 ?
Is there any other way to accomplish same functionality on Watch OS ?
Is it fine to implement socket connection on Watch independently or we are going wrong way?
I have came across one watch app(Stock Tracker : Real Time Stock) with stock update which working independently without iOS App in background.
Thanks

Apple watch cannot do any network requests itself, everything is done via IPhone using Watch Connectivity framework to send and receive data: https://developer.apple.com/reference/watchconnectivity
Apple watch is quite limited for now, as far as I know even though it was a wifi capabilities, they are not for developers. Those things are battery draining and as it's the major problem for Watch persistent connections (like sockets) are restricted.

Related

Fast AppleWatch Data Sending

Does anyone know of a faster way of getting data from the Apple Watch that is faster than the Watch Connectivity framework? I'm trying to access the gyroscope and accelerometer data in real time (or as close to real time as I can get) and the Watch Connectivity seems to be operating very slowly. The console in Xcode is able to receive data very fast from the watch. Is Apple using another type of communication that hasn't been opened up to developers?
I'm working in an academic proof-of-concept environment so it doesn't have to be elegant. I've tried some libraries like ilibmobiledevice and node-ios-device that pipe device syslogs into Terminal, but neither seem to be able to support AppleWatch. I've also looked at some UDP options but that looks to be shut down on the AppleWatch as well...
So far, I've found that the only viable solution "should" be the MultipeerConnectivity framework used on macOS, iOS, and tvOS to communicate over WiFi.
Unfortunately, it seems that the reason Apple don't implement this for watchOS is because it is too demanding on the Watch battery, hence why WatchConnectivity and low-level Bluetooth is the only option. Apple have weighed power consumption against transfer rate and clearly decided that MultipeerConnectivity isn't possible.

iOS refresh bluetooth characteristics

I have created an iOS app that interacts with a bootloader on some custom hardware/firmware to update the application on the hardware. In order to accomplish this, the hardware/firmware has a bootloader application and a regular application. First, I connect my iOS app to the bootloader application and update the regular application. At which point the regular application starts to run and I would like to connect to it with my iOS app.
If I search for peripherals with an Android application it correctly sees my hardware broadcasting as the bootloader application and then switch to broadcasting as the regular application after the update has been completed. However, for some reason, the equivalent iOS app only sees it being broadcast as the bootloader application. I have found that if I restart the iOS device or if I turn the iOS device's bluetooth off and back on after a few seconds it will finally recognize that the regular application is broadcasting.
It seems as though the iOS device is caching the peripheral information. Does anyone know if there is a way to clear the cache or refresh to get the current/valid status of the device?
I have exactly the same issue here, unfortunately this is indeed due to iOS. There are a lot of other threads about this topic but after looking for a while I would recommend this answer :
https://stackoverflow.com/a/25930825
Best of luck, I haven't finished yet and this won't be easy...

Bluetooth Communication between OSX and iOS

I'm working on an application that does does lots of iOS <--> OSX communication. For the most part I have this solved.
I'm using CocoaPort to do the communication. Over Wifi this worked nicely and was plenty fast.
I'm using Bonjour to find my server. This required publishing the service with a modded DNSSDObjects-style net service on iOS. Apparently services published over Bluetooth on OSX cannot be seen by iOS, but the other way round works nicely, except that you need to keep the devices paired and connected.
Now my question is, how can I improve the speed of the Bluetooth connection? I'm getting maybe 100kb/s max and that seems to just stop after about 1 minute even though the connection is still open.
I think I need to use the AMP/HS stuff in Bluetooth 3.0 to get a fast connection. My understanding is this creates an AdHoc wireless network between my devices (MBP retina and iPad3, so should be capable of a decent speed.)
According to Wiki, Bluetooth 4.0 includes the HS spec in Bluetooth 3.0 and according to Bluetooth Explorer, the iPad is 4.0 spec. Is there a way, maybe via IOBluetooth, to request a high speed connection?
According to an engineer # Apple, this is not currently feasible. The best you can do is Bluetooth Classic, which is probably the speed I'm getting.
If you want this feature, consider opening a feature request at bugreporter.apple.com.

Bonjour not advertising over BT

I've been banging my head against this for the last week or so. I've already gone through the following resources:
StackOverflow: Bonjour over bluetooth WITHOUT Gamekit ? (3844189)
StackOverflow: How does Bonjour Over Bluetooth Work (3350094)
StackOverflow: Using iOS GameKit's “Bluetooth Bonjour” with other platforms (8070998)
Technical Q&A QA1753 -- Apple Developer
WiTap sample application
SRVResolver sample application
DNSSDObjects sample application
I'm using Mac OS 10.7, Xcode 4.5, an iPhone 4 with iOS 6, and an iPad 1 with iOS 5.1.1.
My problem is this: I am modifying an application that currently uses GameKit's peer picker to connect between an iPad and a iP{hone|od touch}. We want to modify this to use Bonjour over Bluetooth instead because we've had issues with reconnecting the devices using Gamekit if the connection is lost. I've used dns_sd.h API to some success and have gotten the service to advertise and resolve over wifi, but even though I am passing kDNSServiceFlagsIncludeP2P I am not getting any success over bluetooth.
I thought possibly Bluetooth Bonjour need a PAN established between devices already, but even pairing the iPad to the iMac and browsing for DNS-SD services gives me nothing...and the iPhone won't pair to the iPad anyway.
I just finished solving this in my own app in the last 24 hours. I used the core classes from the OS X sample app DNSSDObjects. I only had to change three lines of code to add support for bluetooth. This works great in my iOS app.
In DNSSDBrowser.m, the call to DNSServiceBrowse needs to have kDNSServiceFlagsIncludeP2P passed in for the 2nd parameter.
In DNSSDRegister.m, the call to DNSServiceRegister needs the same change.
In DNSSDService.m, the call to DNSServiceResolve also needs the same change.
If you want to limit yourself to just bluetooth, and not WiFi, then the same three lines of code should be updated so the 3rd parameter is kDNSServiceInterfaceIndexP2P instead of kDNSServiceInterfaceIndexAny.
Indeed, it looks like the kDNSServiceInterfaceIndexP2P flag won't work on OSX.
If you run the code on IOS, you'll notice that Bonjour will publish two IP Adresses: one for your local WiFi network, and an 169.xx.xx.xx adress for Bluetooth.
The same code on OSX never publishes the 169.xx.xx.xx adress, so it's only found over WiFi.

How can I setup peer-to-peer connections without using GKPeerPickerController?

I want people to be able to start my iOS app on their device, and anyone nearby running my app (probably bluetooth only for now) would automatically connect with each other. I've read about and used GKPeerPickerController, but I don't want the user to have to think about which device they want to connect with.
I'm just not understanding how to handle the connectivity without using GKPeerPickerController.
I am targeting iOS 5.0 with this app. Thanks!
This page goes into more detail on how this is possible, although the focus is more on using just bluetooth: http://www.iphonedevsdk.com/forum/iphone-sdk-development/40710-gamekit-api.html

Resources