Get data for complication: ExtensionDelegate is not called

(This seems to have been encountered by others in previous weeks, but there were no solutions I found.)

I'm trying to do a really basic thing: Get data from my iOS application or my Watch application into my Complication controller.

I find myself less able to achieve this than I thought. The WatchOS 2 Transition Guide indicates that I should "[extract] the necessary data from the extension delegate" using the following code:

ExtensionDelegate* myDelegate = [[WKExtension sharedExtension] delegate]; NSDictionary* data = [myDelegate.myComplicationData objectForKey:ComplicationCurrentEntry]; 

Great. Also, I was not able to figure out how to make this work on the extension side. Although, more importantly, I can't even get the extension delegation code to work at all from running the complexity controller. When I run the complexity, I get this message: "Request to add to wake up to support complications." However, none of the codes inside any of the delegate extension methods seem to run. I also set breakpoints in each method, and none of these breakpoints hit.

It also looks like this: "transferCurrentComplicationUserInfo:" is also suggested for use to update complications, although it is unclear exactly how it is used. As I understand it, he used the extension wakeup so that ExtensionDelegate could store new data the next time the complexity controller starts, but due to a previous problem, I could not confirm.

I have one workaround (ping the server from the complexity controller and hope that the session variables are saved, so I can send the corresponding data), but there is every chance that if I can not handle this, then my work on complication will be thrilled. Any help here would be great.

By the way, here is the code I have for "getCurrentTimelineEntryForComplication", if at all useful.

 - (void)getCurrentTimelineEntryForComplication:(CLKComplication *)complication withHandler:(void(^)(CLKComplicationTimelineEntry * __nullable))handler { NSDate* entryDate = [NSDate date]; ExtensionDelegate* myDelegate = [[WKExtension sharedExtension] delegate]; NSString* data = [myDelegate.complicationData objectForKey:@"meow"]; NSLog(@"complication data: %@", data); CLKComplicationTimelineEntry* entry = [self getTimelineEntry:@"2015-08-25 00:19:42" entryDate:entryDate complication:complication]; handler(entry); } 
+6
source share
2 answers

I worked with Complications in WatchOS2 with Xcode 7 Beta 4. Now I am in the latest version of Xcode Beta 6. I had several problems, as in both versions of the beta versions running on Watch, the iPhone, then installing on Watch, and running on the simulator often gives false negatives due to what seems to be a bug in the API and OS releases. I was able to obtain data to show on the complications as follows.

  • Ensure that your primary interface controller implements the WCSessionDelegate protocol.
  • Inject the didReceiveMessage and didReceiveApplicationContext methods in your front-end controller.
  • In your iPhone application, try sending a message using WCSession to Watch.
  • If the message cannot be sent from the iPhone application, send the application context.
  • Return to the interface controller when you receive the message -or- context, update the values ​​in your extension deletion.
  • Still in the front-end controller and still after receiving the -or-context message, get the CLKComplicationServer handle and, for each complexity, call activeComplications reloadTimelineForComplication.
  • In your Complication controller getCurrentTimelineEntryForComplication, take the data that you set in the extension delete and set the values ​​to CLKComplicationTimelineEntry.
  • This will work normally when the application is already open in Watch, the application is still in memory, but set to Watch, or you start the application, and their context expects when it will consume.
  • I was not able to get the chronological statistics records to function (or future). In addition, I managed to get a timeline for updating regardless of the Watch application.

If you are having problems, try some debugging stuff. As I said above, the API and OS look very bad. The following steps are performed (sometimes).

  • In the sim, use the Reset all Settings parameter on the iPhone and Watch sim.
  • On your device, restart Watch. If necessary, remove and repair the Watch, although this takes a very long time.
  • On the iPhone, uninstall the application (which will also uninstall the Watch application, if installed) and reinstall.

I hope this helps!

Justin

+8
source

To make ComplicationController respond to WCSession activity, you must make the controller compatible with WCSessionDelegate, and then control didReceiveUserInfo from within the ComplicationController. ExtensionDelegate does not wake up for these updates in the background. If necessary, you can update the delegate from the controller.

In addition, at the moment, the simulator does not send transferCurrentComplicationUserInfo to the clock simulator, you need to test it on devices.

-1
source

All Articles