transferCurrentComplicationUserInfo(_:) works like transferUserInfo(_:)

Hey there,

I'm implementing Watch Complications in an existing project, and I'm having the problem that transferCurrentComplicationUserInfo(_:) works exactly as transferUserInfo(_:) is described in the documentation, but not as it should.

That is, when the WatchApp is opened, func session(_ session: WCSession, didReceiveUserInfo userInfo: [String: Any] = [:]) receives the data sent by transferCurrentComplicationUserInfo(_:). If not, the data is queued until the Watch App is opened again.

In other words, transferCurrentComplicationUserInfo(_:) never wakes up the ExtensionDelegate when the Watch App is not running.

Has anyone experienced the same thing and know how to fix it?

More details:

  • Testing on iPhone 11 (iOS 17.1.2) and Apple Watch SE (WatchOS 10.2)
  • I made sure that the quota of 50 is not exhausted when I test.
  • The WatchApp is still dual-target (I want to avoid having to migrate to single-target and SwiftUI lifecycle)
  • Watch App code:
class ExtensionDelegate: NSObject, WKExtensionDelegate, WCSessionDelegate {
	let session = WCSession.default

	override init() {
		super.init()
	    if WCSession.isSupported() {
	      session.delegate = self
	      session.activate()
	    }
	}

 	func session(_ session: WCSession, didReceiveUserInfo userInfo: [String: Any] = [:]) {
    	WatchWidgetSessionHandler.shared.processComplicationUserInfo(userInfo)
  	}
} 
  • IOS App code:
class WatchAppDataManager: NSObject, WCSessionDelegate {
   override init() {
    super.init()
     let session = WCSession.default
     session.delegate = self
     session.activate()
   }

  func sendDataToWidget(for kinds: [WatchWidgetKind]) async {
    guard
      WCSession.default.activationState == .activated,
      WCSession.default.isComplicationEnabled
    else {
      return
    }

    let widgetsData = dataProvider.getData(for: kinds)
    if !widgetsData.isEmpty {
      WCSession.default.transferCurrentComplicationUserInfo(widgetsData)
    }
  }
}

Do you have a widget extension as complication active on the watch face? I think this will only wake up the watch app in the background if your watch app's complication is active!

Yeah, transferCurrentComplicationUserInfo(_:) doesn't work with WidgetKit complications for now, and that is a bug on the framework side :-(. I suggest that you file a feedback report with your use case, if not yet, which may help the team prioritize the fix.

transferCurrentComplicationUserInfo(_:) works like transferUserInfo(_:)
 
 
Q