watchkit

Phone call from Apple Watch with openSystem API?

∥☆過路亽.° 提交于 2019-12-11 09:07:53
问题 As I watched the WWDC 2015 session video "Introducing WatchKit for watchOS 2" (at 13:29), I saw that it is possible to make phone calls directly on Apple Watch with the openSystem API. How can I use this API in Swift? 回答1: You can use the openSystemURL method, which is available on the shared WKExtension object. Pass a tel: URL to this method to initiate a phone call. if let telURL=NSURL(string:"tel:5553478") { let wkExtension=WKExtension.sharedExtension() wkExtension.openSystemURL(telURL) }

Swift : Extra Argument in call with scheduledTimerWithTimeInterval

走远了吗. 提交于 2019-12-11 08:02:46
问题 I create a simple WatchApp Metronome. I use NSTimer with .scheduledTimerWithTimeInterval, and I have an error Extra Argument 'selector' in call Thanks for your answers func playBeat() { if(self.State == true) { self.State == false [labelPlayPause.setTitle("Pause")] } else { self.State == true [labelPlayPause.setTitle("Play")] } BPMValue = 10 var BPMInt:Int = Int(BPMValue) let value = "\(BPMInt) BPM" labelBPM.setText(value) let aSelector: Selector = "playBeat" dispatch_async(dispatch_get_main

HealthKit crashing when pulling heart rate on second call after working on first call even when not running any code

筅森魡賤 提交于 2019-12-11 05:57:00
问题 I have a WatchKit app using HealthKit. When a view (with custom WKInterfaceController MonitorMetrics) appears it runs the following code: func startRecordingHeartRate() { let heartRateSample = HKSampleType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate) let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute()) let datePredicate = HKQuery.predicateForSamples(withStart: Date(), end: nil, options: .strictStartDate) let anchor: HKQueryAnchor? = nil let updateHandler:

UserDefaults between iOS and WatchOS not working

天涯浪子 提交于 2019-12-11 04:47:49
问题 Here is the code, but for some reason I get nil when I read from Watch. Any idea what am I missing? Writing in iOS Method @IBAction func writeDefaults(_ sender: Any) { UserDefaults(suiteName: "group.testingGroups")!.set(true, forKey: "myKey") } Reading from WatchOS @IBAction func readDefaults() { let readKey = UserDefaults(suiteName: "group.testingGroups")!.bool(forKey: "myKey") print("Key Value: \(readKey)") } I also tried the following when reading but nothing... let readKey = UserDefaults

Communicate data between WatchOS & Today Extension widget

拟墨画扇 提交于 2019-12-11 04:44:16
问题 Standard set up for Watch OS > 2. WCSessionDelegate used to coordinte data between main application and Watch. An App Group "group.***********.TodayExtensionWidget" used to coordinate data between main application and its Today Extension widget via UserDefaults(suiteName: "group.***********.TodayExtensionWidget") When I make a change from the watch it communicates that change with the main application. Then the main application (once launched) communicates this on to the Today Extension. What

How can I awake my iPhone app in the background to run a function and return the results to Apple Watch?

孤人 提交于 2019-12-11 04:26:33
问题 I have a table in my Apple Watch app that is populated by data from the iPhone app. On the iPhone app, I need to get this data from the internet. On the phone, the function is called retrieveData(). I also have a function called sendToWatch() that sends this data to the watch when the phone app is open. I'd like to find a way to run retrieveData() and sendToWatch() without needing to open the phone app. I've looked into this for the past few hours, and it seems very complicated. I've tried

Cannot install Watch app

一曲冷凌霜 提交于 2019-12-11 03:37:53
问题 When trying to test a Watch app on the Watch, in XCode I get the following warning Watch App xcodeproj TARGETED_DEVICE_FAMILY contains a value incompatible with the target type. Looking at the Device logs, it says: (Error) WatchKit: validateWatchKitApplicationInfoDictionary, invalid UIDeviceFamily value What am I missing? 回答1: Modify Targeted Device Family Open file PROJECT.xcodeproj in your project folder Open file project.pbxproj Replace value of TARGETED_DEVICE_FAMILY: "4" for

Understanding handleWatchKitExtensionRequest

Deadly 提交于 2019-12-11 03:35:18
问题 I am testing the execution of some code on the iPhone app. I follow the documentation that Apple suggests (without using background tasks, just a console log ). However I do not get anything on the console (I'd like to see the string "howdy"). Is this because I am running the WatchKit Extension app on the simulator ? Or is there something that I am missing? Apple says: If you are using openParentApplication:reply:, make sure you create a background task immediately upon entering application

How do we use Watchkit Touch Events?

自古美人都是妖i 提交于 2019-12-11 02:52:27
问题 I wanna use touch events in my app. I know gesture recognisers can not be used in watchKit. Is it possible to use functions like touchesBegan, touchesMove etc ? 回答1: A little late to the party, but it's possible to use SceneKit with WatchKit and SceneKit allows you to add gesture handlers. Please see the Apple example project here: https://developer.apple.com/library/content/samplecode/WatchPuzzle/Introduction/Intro.html#//apple_ref/doc/uid/TP40017284-Intro-DontLinkElementID_2 Edit: Looks

How to put one WKInterfaceLabel below WKInterfaceLabel?

本小妞迷上赌 提交于 2019-12-11 02:35:00
问题 hello all i have new in watchkit development and i have special requirement in which i arrange one WKInterfaceLabel below another WKInterfaceLabel, i try with lots off option like edit postions but WKInterfaceLabel is not set properly can you please help me in this. 1)Position of the first WKInterfaceLabel 2) Position of the second WKInterfaceLabel 3) Actual Design 4)Display in Interface file 回答1: I don't know clearly about your question, but if you want to arrange the label as you want, you