Post not yet marked as solved
Hello,
I have problem witch import this Framework YOChartImageKit to watch extension.
I wold like to use this framework for chart in image.
I was install pod and I can't import this framework to Watch Extension for use. Can you help me someone?
Thank very much.
Post not yet marked as solved
I have a app want to add watch extension,use WatchConnectivity is success when watch and phone all active,but it is fail when watch inactive.
how to do phone can send message success or trigger watch shock when watch inactive
Post not yet marked as solved
Hello How can I create same chart as activity Ring without use healtkit?
I try to use some pod as "YOChartImageKit"
But this pod not function on Apple Watch 5 series, where i tested it.
Post not yet marked as solved
I'm developing an independent WatchOS app that uses NSURLSessionWebSocketTask to access Web Sockets. This works fine as long as the Apple Watch is connected to an iPhone, but when it's not, the web socket won't connect and gives an error that there is no network available. Using NSURLSession to access a web resource works fine though whether the watch is connected to an iPhone or not. Is this a bug or is there a way to get this working? Thanks
Post not yet marked as solved
Could anyone help me?
If push view app crashed only on real Apple Watch, not Crashed in Watch simulator.
override func awake(withContext context: Any?) {
super.awake(withContext: context)
let imageUrlStringQR = "http://192.168.x.x/Image/MainCollection/MainBG.png"
let imageUrlQR = URL(string: imageUrlStringQR)
let imageDataQR = try! Data(contentsOf: imageUrlQR!)
let imageQR2 = UIImage(data: imageDataQR)
QRImage.setImage(imageQR2)
}
Post not yet marked as solved
Hello,
how can i send data to apple watch if app is not running. I need the application in apple watch to run with data from iphone as (login, password))
I send data to apple watch when I click the Sign In button. I need the data to be stored in apple watch even if the application in apple watch is not running. as soon as I run it, the data that was received from the Iphone must be used.
Post not yet marked as solved
Good day,
I am developing an Apple Watch app where one of the main functions should be the Watch to vibrate (a specific sequence of haptic feedback) a few times per day at random intervals.
It should do it roughly 4 times per day with the times being different each day
From what I’ve gathered, the best approach might be the Smart Alarm from WKExtendedRuntime, but that creates a 30 minute window only and I am not sure how (if at all) that would be useful for my case.
PS. It could also be a non Apple approved method, as this app will not go live on the App Store.
Post not yet marked as solved
I developed an independent Apple Watch that can access network resources on its own using NSURLSession without going through the iPhone. This works fine if the iPhone is on, but if I turn the iPhone off it is not able to connect. Why does my app lose network connectivity when the iPhone is off even though it's a standalone app and the Watch is connected to my WIFI? Is there anything special I need to do to get this working? It appears that no apps work with the internet when the iPhone is off. WIFI is enabled and connected to my WIFI network under the Settings on the watch
Post not yet marked as solved
Hello,
The watch app I'm working on won't run on M1 machines. We aren't having this problem on Intel machines. The issue we're seeing is "WatchKit 1 apps aren't supported on this version of watchOS. Quitting "(null)"". It can't be watchOS related because the app runs fine on Intel.
Does anyone know why this is happening and how to fix it?
Post not yet marked as solved
I am receiving the subject error when building my watch-only app to install on my actual watch via iPhone. It does not occur when building for the simulator.
This is Xcode 13 so the Info.plist isn't a separate file anymore. Indeed, this key is present in both places, but I didn't add it there and to my knowledge I can't remove it.
Any Help appreciated. All operating systems at latest levels.
Barry
Post not yet marked as solved
I am using WatchConnectivity to send messages between my swift iPhone / watch app.
When I receive a message on the iPhone, from the watch, I need to jump to the main thread.
The problem is; when the iPhone is in an inactive/not running state it never seems to complete that action.
The iPhone receives the message, but when it tries to dispatchQueue.main.async{} , it seems to time out. The code inside .async{} never gets called.
Here’s the code where it receives the message on the iPhone:
func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
print("Message recieved: ", message)
// We always make it to at least here, no matter what state the application is in.
DispatchQueue.main.async {
// This code is never called if the app is in an inactive/not running state.
// Do something...
}
}
Post not yet marked as solved
I’m trying to read the battery level of a connected Apple Watch on an iPhone app.
The built-in iOS Batteries widget shows the current Apple Watch battery level, so I know the data is being sent from Apple Watch to iPhone frequently, however I could not find a public API to read the level in my iOS app.
My best solution so far was to build an Apple Watch app that periodically sends the battery level of the Apple Watch to the iPhone using WatchConnectivity.
Then, I found this app.
It can show the battery level of my paired Apple Watch without ever installing an app on the Apple Watch.
To try to accomplish this same thing, I have tried a few different approaches.
First, I tried Core Bluetooth, but after a lot of exploring, troubleshooting, and asking at a Core Bluetooth lab, I’ve ruled that out since Apple Watch does not expose its battery information that way.
I experimented with the External Accessory framework, but that doesn’t seem like the right approach either, since it's for MFi accessories and I couldn't find a way to get Apple Watch info with it.
How is it possible to read the Apple Watch battery level in an iPhone app without sending it from a companion Apple Watch app?
Or is the app I linked to probably using private APIs?
Post not yet marked as solved
I have a watch app which communicates with the iPhone app fine. But when running the WCSession from the Intent extension (used for Siri) I'm getting following in the console logs:
Error Domain=WCErrorDomain Code=7018 "Companion app is not installed."
Can the Watch Intent extension communicate with iPhone app - if so how can I enable it?
Post not yet marked as solved
Hi Folks,
I am building a SwiftUI based WatchOS app primarily focused on updating a complication using data from a REST API call.
I am trying to reproduce the approach to updating complications in the background as described in "Keeping your complications up to date".
The trouble I have is that the func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) method on the ExtensionDelegate is never called for the WKURLSessionRefreshBackgroundTask task type. The handle method is invoked for other task types such as WKSnapshotRefreshBackgroundTask.
After some refactoring, I have deviated from the approach in the video and I now reshedule the background task in the func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) method of the URLSessionDownloadDelegate.
This works fine, and the tasks are being resheduled in the background, but my concern is that there maybe a WKURLSessionRefreshBackgroundTask object lurking in the background for which I haven't called setTaskCompletedWithSnapshot.
My session is configured as follows:
private lazy var backgroundURLSession: URLSession = {
let appBundleName = Bundle.main.bundleURL.lastPathComponent.lowercased().replacingOccurrences(of: " ", with: ".")
let sessionIdentifier = "com.gjam.liffeywatch.\(appBundleName)"
let config = URLSessionConfiguration .background(withIdentifier: sessionIdentifier)
config.isDiscretionary = false
config.sessionSendsLaunchEvents = true
config.requestCachePolicy = .reloadIgnoringLocalCacheData
config.urlCache = nil
return URLSession (configuration: config, delegate: self , delegateQueue: nil )
}()
and the scheduling code is a follows:
func schedule(_ first: Bool) {
print("Scheduling background URL session")
let bgTask = backgroundURLSession.downloadTask(with: LiffyDataProvider.url)
#if DEBUG
bgTask.earliestBeginDate = Date().addingTimeInterval(first ? 10 : 60 * 2)
#else
bgTask.earliestBeginDate = Date().addingTimeInterval(first ? 30 : 60 * 60 * 2)
#endif
bgTask.countOfBytesClientExpectsToSend = 200
bgTask.countOfBytesClientExpectsToReceive = 1024
bgTask.resume()
print("Task started")
backgroundTask = bgTask
}
Does anyone have any idea's why the handle method is not invoked with WKURLSessionRefreshBackgroundTask tasks?
Cheers,
Gareth.
Post not yet marked as solved
I'm developing an independent watch app and I have a background task every 60 minutes. But don't have anything happen when I close app or run background mode in over 24 hours.
I have use below code:
ViewController.swift
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
setScheduleBackgroundJob {
// Set success
}
}
func setScheduleBackgroundJob(completed: @escaping () -> Void) {
let dateStartBackgroundTask = Date(timeInterval: TASK_INTERVAL_TIME.timeInterval, since: Date())
WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: dateStartBackgroundTask, userInfo: nil) { error in
if let error = error {
// log if have error
print("Error: ", error.localizedDescription)
return
}
print("BACKGROUND TASK: ", Date());
completed()
}
}
@IBAction func closeApp() {
setScheduleBackgroundJob {
exit(0)
}
}
ExtensionDelegate.swift
func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) {
// Sent when the system needs to launch the application in the background to process tasks. Tasks arrive in a set, so loop through and process each one.
for task in backgroundTasks {
// Use a switch statement to check the task type
switch task {
case let backgroundTask as WKApplicationRefreshBackgroundTask:
// Be sure to complete the background task once you’re done.
createBackgroundSceduleTask()
LocalStorageManager.logCollectData(content: "Collect Health Data Background \(Date())")
DataManager.shared.collectData(bgTask: backgroundTask)
// backgroundTask.setTaskCompletedWithSnapshot(false)
case let snapshotTask as WKSnapshotRefreshBackgroundTask:
// Snapshot tasks have a unique completion call, make sure to set your expiration date
snapshotTask.setTaskCompleted(restoredDefaultState: true, estimatedSnapshotExpiration: Date.distantFuture, userInfo: nil)
case let connectivityTask as WKWatchConnectivityRefreshBackgroundTask:
// Be sure to complete the connectivity task once you’re done.
connectivityTask.setTaskCompletedWithSnapshot(false)
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
// Be sure to complete the URL session task once you’re done.
DataManager.shared.handleData(urlSessionTask)
// urlSessionTask.setTaskCompletedWithSnapshot(false)
case let relevantShortcutTask as WKRelevantShortcutRefreshBackgroundTask:
// Be sure to complete the relevant-shortcut task once you're done.
relevantShortcutTask.setTaskCompletedWithSnapshot(false)
case let intentDidRunTask as WKIntentDidRunRefreshBackgroundTask:
// Be sure to complete the intent-did-run task once you're done.
intentDidRunTask.setTaskCompletedWithSnapshot(false)
default:
// make sure to complete unhandled task types
task.setTaskCompletedWithSnapshot(false)
}
}
}
Post not yet marked as solved
I'm a Rails / Node engineer, wanting to make apps for the Apple Watch.
Does WatchKit allow us to build background streaming apps, and can those apps store audio files locally (to work without a network connection?
Post not yet marked as solved
I have a project of an iOS app with an embedded framework called TotoKit with some model classes.
Now I've added a new target with the template "WatchApp for iOS App" to my project. When I try to do "import TotoKit" from the newly created WatchKit extension, no such module is found. What do I have to do ?
I have tried without success to:
add one dependencies to TotoKi in BuildPhase of the extension target
add AppleWatch in Deployment/Target Device Families of the TotoKit target
Thanks,
Post not yet marked as solved
Hey - can you program the watch to vibrate for 2-20 seconds intervals followed by an off period between each vibration period and repeat these various cycles for any amount of time? It seems you could not in the past but there is an opportunity now. Can you also set alarms to trigger it? Thank you!
My app has a Siri Shortcut that works fine when I execute it from the Shortcuts app on my watch, but if I try to activate it by voice, Siri says: "Sorry, something's wrong. Please try again." and then a second later says "We've had a problem. Please try again."
I'm currently on watchOS 8 beta 6. I last tested this in early July with beta 2 or beta 3 and it was working at that time. I haven't made any changes to the intent extension since then.
The shortcut activates fine by voice on my phone, running iOS 15 beta 6. I'm also able to execute other Shortcuts by voice on my watch.
Has anyone else run into this before? Is there a way to debug the intent extension on the watch, so I can see if any of my intent handler code is even being called?
Post not yet marked as solved
I have a watchOS app that shows a map with the device's current location. This works as expected on a simulator.
On a device in TestFlight, the map shows for an instant, but then the map area turns blue.
When I zoom in and out, again, the correct map shows for an instant, but then the screen turns blue.
I have a couple of images to illustrate the issue:
I'm attaching the mapping code below:
super.awake(withContext: context)
if CLLocationManager.locationServicesEnabled() {
locationManager.requestAlwaysAuthorization()
locationManager.requestWhenInUseAuthorization()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.startUpdatingLocation()
} else {
print("Problem with permissions")
return
}
let span = MKCoordinateSpan(
latitudeDelta: 0.005,
longitudeDelta: 0.005
)
#if targetEnvironment(simulator)
let location = CLLocationCoordinate2D(
latitude: simulatorLatitude,
longitude: simulatorLongitude
)
let region = MKCoordinateRegion(center: location, span: span)
mapView.setRegion(region)
mapView.addAnnotation(location, withImageNamed: "mapPinRed", centerOffset: CGPoint(x: 0, y: 0))
#else
locationManager.requestLocation()
#endif
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
print(#function, "Status: ", status.rawValue)
if status.rawValue == 0 {
locationManager.requestAlwaysAuthorization()
locationManager.requestWhenInUseAuthorization()
locationManager.requestLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let currentLocation = locations[0]
let lat = currentLocation.coordinate.latitude
let long = currentLocation.coordinate.longitude
self.mapLocation = CLLocationCoordinate2DMake(lat, long)
//let span = MKCoordinateSpan.init(latitudeDelta: 0.1, longitudeDelta: 0.1)
let region = MKCoordinateRegion.init()
self.mapView.setRegion(region)
self.mapView.addAnnotation(self.mapLocation!, with: .red)
}
func centerMapOnLocation(location: CLLocation) {
#if targetEnvironment(simulator)
let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: simulatorLatitude, longitude: simulatorLongitude), span: MKCoordinateSpan(latitudeDelta: CLLocationDegrees(zoomValue), longitudeDelta: CLLocationDegrees(zoomValue)))
DispatchQueue.main.async {
self.mapView.setRegion(region)
}
#else
let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude), span: MKCoordinateSpan(latitudeDelta: CLLocationDegrees(zoomValue), longitudeDelta: CLLocationDegrees(zoomValue)))
DispatchQueue.main.async { [self] in
self.mapView.setRegion(region)
self.mapView.addAnnotation(location.coordinate, withImageNamed: "mapPinRed", centerOffset: CGPoint(x: 0, y: 0))
}
#endif
}
My permissions are set in Watch.extension info.plist as follows:
Privacy - Location Always Usage Description
Privacy - Location Always and When In Use Usage Description
Privacy - Location Usage Description
I would appreciate any help.