3

I'm having issues with the WatchConnectivity and potentially Clockkit frameworks. I'm trying to use transferCurrentComplicationUserInfo in the iOS app to send data to the watch and update the complication. Inside my extension delegate on the watch I have implemented the delegate method didReceiveUserInfo where I process the data and then call to update the complication.

When I run the iOS app on the simulator things work fine. However, if I run it on actual devices, the transmit from the phone starts, the complication calls requestedUpdateDidBegin(), but the didReceiveUserInfo inside the extension on the watch is never called and hence I have no data for the complication.

Any suggestions? or should I file a bug report?

Simon
  • 304
  • 2
  • 17
  • It would help to see your watch connectivity code for the watch. –  Mar 02 '16 at 20:30
  • @PetahChristian Isn't my code irrelevant as it works fine in the simulator, just not on device. Anyway, in the parent app, I have `session.transferCurrentComplicationUserInfo(applicationDict)` and then to receive in the Extension delegate on the watch I have `func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) { NSLog("Complication Update didReceiveUserInfo ExtensionDelegate") NSLog("UserInfo recieved from iPhone\n%@", userInfo.description) complicationServer.reloadTimelineForComplication(complication) }` However it is never called – Simon Mar 02 '16 at 22:56
  • How large of a payload are you sending? The allowed size is pretty small and I have seen the simulator handle larger payloads than the physical device. Since there is no error handler on the transfer method, you probably wouldn't get notified of this. – lehn0058 Mar 06 '16 at 01:58
  • I've tried with no payload, just an empty dictionary... Still no luck – Simon Mar 07 '16 at 20:15

3 Answers3

2

It sounds like an issue setting up your WCSession object on your apple watch. For a complication, I recommend doing this in the ExtensionDelegate's init method. The reason for this is because applicationDidFinishLaunching only is called when your watch extension (the main watch app) is launched, not when a complication or glance is shown.

override init() {
    super.init()

    // Setup watch connectivity. We do this here because applicationDidFinishLaunching is only
    // called when the watch extension is being called, not when a complciation is being updated
    self.session.delegate = self
    self.session.activateSession()
}
lehn0058
  • 19,977
  • 15
  • 69
  • 109
  • 1
    Unfortunately Ive tried that, the init method never gets called either, i just get a log statement (which I didn't put in) saying 'Extension received request to wake for complication support and' and then requestedUpdateDidBegin() gets called. Ive put logs in the init before and its never called... – Simon Mar 02 '16 at 18:54
2

It may be because you exceeded the system limits of transferring data by transferCurrentComplicationUserInfo, since you can only transfer 50 times a day

Transfer Data from iOS Alternatively, if your watchOS app has a companion iOS app, you can gather the data in the iOS app, and then transmit that data to Apple Watch. However, this update strategy tethers the watch to the companion iPhone. You can’t update the complication if the user ventures out without their phone, a circumstance that can result in out-of-date or inaccurate complications. Also, like push notifications, the system limits you to 50 complication transfers a day.

You can check the remaining times of allowed transfers by remainingComplicationUserInfoTransfers

Collin Zhang
  • 483
  • 5
  • 14
1

Before determining that the extension is never called, you should check the Watch (console) log messages via the Devices pane. It's possible that the extension is launched in the background, and not attached to the debugger, so you would not see the NSLog message in the Xcode console.

More significantly, you may have transferred some complication userInfo from the phone to the watch but don't appear to do anything with that dictionary once the watch received it. You have to do more than merely transfer the current complication info. The complication data source would need to access that information when getCurrentTimelineEntryForComplication is called (as a result of the timeline being reloaded).

Possible reasons

You didn't share very much code, so I addressed how transferCurrentComplicationUserInfo actually works, and mentioned an unrelated issue I saw with your code.

Without more code, it's difficult to provide a specific answer, but I'll try to help for the sake of anyone else who may have this problem in the future.

Here are some possibilities why your extension's didReceiveUserInfo is not called.

  • You activated WCSession in more than one place, and the transfer is (not) being handled by another delegate.
  • You didn't hold a reference to your activated session, and it went out of scope.
  • The app hasn't been opened on the Watch.
  • The session isn't activated soon enough or in the right place.
  • transferCurrentComplicationUserInfo failed with an error because your phone was locked. (This is a known issue that Apple has acknowledged, and there is a workaround.)

How code would help improve your question and our answers

The purpose of providing code is to identify or eliminate reasons why something isn't working. Code is generally necessary to help answer "Why doesn't this work?" programming questions.

Just because it happens to work in the simulator, that doesn't guarantee that you "set things up correctly." It's reasonable that testing on a device reveals bugs you'd never discover by testing in the simulator.

Community
  • 1
  • 1
  • Clearly the question has not been read very well. I have said that on device requestUpdatedidBegin() is called. I would only know this IF the debugger was correctly attached (which it is). As for the second part of your answer I still think your missing the point, I have already said that didReceiveInfo is never called, meaning Watch Connectivity is not functioning correctly. Within that I handle the info dictionary and request the complication to update. It made very clear from the WWDC 2015 talks that updates can be pushed to the watch in this way – Simon Mar 03 '16 at 20:17
  • Understand, I'll submit a bug report (got no TsI's left :( ) I'll post a solution if I get one – Simon Mar 07 '16 at 20:16
  • Could you post the radar number here to help any apple engineers who happen upon it to look it up easily? – ccjensen Mar 08 '16 at 17:31