watchconnectivity

WatchOS app not detecting companion iOS app

烂漫一生 提交于 2020-05-27 12:51:06
问题 I am making an independent Apple Watch app (but with a companion iPhone app which is not necessary for the watch app to function.) The app uses WatchConnectivity to sync data between devices if iPhone companion app is installed. I am able to call session.updateApplicationContext() on the iOS app and receive session(didReceiveApplicationContext) on the Watch app. But going the other way is not possible. I always get an NSError code of 7018 which means the iOS companion app is not installed. I

swift WatchConnectivity running in background - ApplicationContext is not running all the time

浪尽此生 提交于 2020-01-07 05:11:14
问题 I want to know a better way to send (with iPhone) message to Watch (in background). Currently i use: session.update(applicationContext: package, completion: nil) for sending messages to Watch and func didReceivedApplicationContext(applicationContext:[String : Any]) to receive messages in Watch. The problem is that as is said in documentation "The system will transfer content at opportune times" and i can't control those "oportune times". At this time, i check in iPhone class the state of

WatchConnectivity how to share session among multiple WKInterfaceControllers?

拥有回忆 提交于 2020-01-06 20:12:48
问题 I have a situation where I need to share WCSession among multiple WKInterfaceControllers. Singleton approach won't work, once you set delegate to a class, all delegates in the other classes are invalidated. Scenario: interface A send and receive data, based on the data content, present interface B. Tap on interface B, will request and receive additional data. How would you share the WCSession between A and B ? 回答1: The other answer doesn't explain that an app-wide session would work. You can

Checking for protocol availability in Swift

▼魔方 西西 提交于 2020-01-03 00:32:12
问题 I am adopting WatchConnectivity, but I am still supporting iOS7 and iOS 8 for which this library is not available. Moreover I am adopting protocol WCSessionDelegate also not supported but this older systems. In ObjectiveC I would have used preprocessing directives to shield this declaration and the protocol adoption from versions not supporting them. How do I handle that in Swift so that the app does not crash on older systems? 回答1: I thank @joern for the suggestion of adopting the protocol

WCSession error domain code 7005: Device is not Paired

家住魔仙堡 提交于 2019-12-24 14:51:06
问题 By making use of WCSession sendMessage, I am getting ErrorDomainCode 7005 constantly within one of my Projects. I get this error when testing with all simulators and also on real iPhone and paired Apple Watch. Devices are definitely paired. The exact same code works fine for other (newer) projects that I created from scratch together with a Watch Extension. I do have this problem only in an older Project where I have added a watch extension recently. The watch app simply does not communicate

Is it safe to share access tokens with Watch Connectivity's updateApplicationContext?

自作多情 提交于 2019-12-23 10:48:12
问题 Is the applicationContext encrypted? Or is it simply stored as an unencrypted plist file? Because if it's the latter, I shouldn't be transferring access tokens using that. 回答1: The communication between the devices is encrypted, as documented in the iOS Security Guide. I haven't seen any documentation on whether the applicationContext storage location is encrypted, but to be safe you could encrypt the token yourself before queueing it to be sent and decrypt when the other device has received

swift how to share data between Watch and iPhone on background

放肆的年华 提交于 2019-12-23 02:46:40
问题 I have a functional application for sharing the data between iPhone and Watch (share text) and I want to make it work even when the watch is set on background (send data from iPhone to Watch when Watch is on background). I read a lot about how to make this but nothing seemd to be ok for my application. Please add the code to make application work as I said before. Or give me some source which fit with this app. Thank you! Code for iPhone: import UIKit import WatchConnectivity class

WKWatchConnectivityRefreshBackgroundTask example

社会主义新天地 提交于 2019-12-13 07:05:23
问题 I want to pass data from my iOS App to my watchOS 3 app using WKWatchConnectivityRefreshBackgroundTask How do I set up code in my watchOS App to handle the data being transferred? For example in the past I used this iOS code to send a message from the iOS App and if there was no connection send a context: func sendTable() { let tableInfo: WatchWorkout = PhoneData().buildWatchTableData(Foundation.Date().refDays()) let archivedTable: Data = NSKeyedArchiver.archivedData(withRootObject: tableInfo

What is the best practice to call URL in apple watch?

∥☆過路亽.° 提交于 2019-12-11 12:59:00
问题 What is the best practice to call API from Apple watch use sendMessage "watchConnectivity" from Apple watch to iPhone to call the API or use NSURLSession to call the API from the watch itself ? 回答1: Using the NSURLSession API, the device that performs the request is abstracted from the developer. If the phone is available, it will perform the request on the phone and return it to your watch app as if the watch itself performed the request. If the phone is not available, the watch can perform

How to share data using Watch Connectivity when working with Core Data

五迷三道 提交于 2019-12-09 05:22:48
问题 In my iOS application I use Core Data to store data and a fetch request to create an array of NSManagedObject s to display in a UITableView . On the Watch OS I check if WCSession is supported and active a session, then send the iOS application a message from the watchOS extension. When the iOS application receives the message from the watchOS it should send the array of Objects to the watchOS extension to display the data in the WKInterfaceTable , but I am unsure how to do this. Ultimately