realm-swift icon indicating copy to clipboard operation
realm-swift copied to clipboard

Apple Watch Support for Sync

Open TheNoim opened this issue 7 years ago • 15 comments

Goals

Use realm swift in an apple watch app

Expected Results

It should work ?

Actual Results

The sandbox of the apple watch prevents the connection to the realm.

Steps to Reproduce

Create an apple watch app and try to connect to a realm with it on a real device. It works on the simulator but not on a real device.

This is what you will get:

2017-12-10 12:50:24.432939+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
2017-12-10 12:50:24.560815+0100 RealmAWBug WatchKit Extension[373:540433] Unbalanced calls to begin/end appearance transitions for <PUICNavigationController: 0x162f1a00>.
2017-12-10 12:50:25.438822+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
2017-12-10 12:50:26.443064+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
2017-12-10 12:50:27.448825+0100 RealmAWBug WatchKit Extension[373:540595] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:14 Err:-1 Errno:1 Operation not permitted
Sync: Connection[1]: Failed to resolve 'Your address': Host not found (authoritative)

Code Sample

https://github.com/TheNoim/RealmAWBug It dose not really depends on code. But here is an example project This is what I found: https://stackoverflow.com/questions/41219976/apple-watch-kit-wouldnt-fetch-image

Version of Realm and Tooling

ProductName:    Mac OS X
ProductVersion: 10.13.1
BuildVersion:   17B1003

/Applications/Xcode.app/Contents/Developer
Xcode 9.2
Build version 9C40b

/usr/local/bin/pod
1.4.0.beta.2
Realm (3.0.2)
RealmSwift (3.0.2)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)

carthage not found
(not in use here)

/usr/local/bin/git
git version 2.15.0

TheNoim avatar Dec 10 '17 12:12 TheNoim

Sorry for the delay in responding, @TheNoim.

The only networking that watchOS permits directly from the device is HTTP requests made via NSURLSession. Realm Platform's synchronization protocol is based on WebSockets and so cannot be implemented on top of NSURLSession in a way that's compatible with watchOS. This unfortunately means you'll need to limit your use of Realm Platform to your iOS app, and communicate data to your watchOS app via the Watch Connectivity framework.

bdash avatar Jan 25 '18 08:01 bdash

Is there any way that to tell Realm to not try so that these messages stop showing up in the logs?

aaronrogers avatar Jul 27 '18 17:07 aaronrogers

@bdash I recently discovered a web socket swift library supporting watch os. It seems like websockets are possible on an apple watch.

TheNoim avatar Aug 19 '18 12:08 TheNoim

Is there any way that to tell Realm to not try so that these messages stop showing up in the logs?

Getting the same error code on my Mac App, and I have the same concern. I guess it is related to realm cloud stuff(not sure), but cannot find a related doc. Can somebody show how to turn it off?

GiddensssA avatar Sep 29 '19 15:09 GiddensssA

watchOS 6.0 adds support for URLSessionWebSocketTask. It sounds like sync should be possible now.

@realm-support Any idea when we could see sync support on watchOS?

AndresCanella avatar Jun 26 '20 02:06 AndresCanella

If you have a feature request please add it here: https://feedback.mongodb.com/

ianpward avatar Jun 26 '20 13:06 ianpward

I'm getting similar errors with a Mac app. I'm intending to just use it locally and don't want to allow outgoing requests. Is there a way to tell realm to not make the requests?

natebrunette avatar Sep 27 '20 20:09 natebrunette

Any updates on this topic? We would love to use Realm with Sync on our Apple Watch app.

asiergmorato avatar Apr 18 '23 08:04 asiergmorato

Same as I'd love to see this

clarkezone avatar May 29 '23 03:05 clarkezone

Hi @dianaafanador3 👋🏻 , any news regarding this Feature Request? 😄

umutonat avatar May 28 '24 08:05 umutonat

We don't have a timeline yet - it's somewhat lower in the backlog, but it's still on the plan for this year.

nirinchev avatar May 28 '24 11:05 nirinchev

Any updates here? In the meantime, is there any way to establish syncing while we wait for the new feature?

mehmetbaykar avatar Jun 28 '24 10:06 mehmetbaykar

If your watch app is a companion to an iOS app, you can use sync in the iOS app and send visualize the data in the watch app. There's no way to sync from a standalone watch app at this point.

nirinchev avatar Jun 28 '24 13:06 nirinchev

Only interested in standalone sync

clarkezone avatar Jun 30 '24 22:06 clarkezone