1

Is there a way to detect if an Apple Watch App was launched by the user tapping the apps glance or complication?

lukas
  • 2,300
  • 6
  • 28
  • 41

2 Answers2

0

Yes, you have to implement the handleUserActivity method in your main InterfaceController.

- (void)handleUserActivity:(NSDictionary *)userInfo {
  //Your code
 }

You can find more info in the documentation: https://developer.apple.com/library/ios/documentation/WatchKit/Reference/WKInterfaceController_class/#//apple_ref/occ/instm/WKInterfaceController/handleUserActivity:

jmgomez
  • 742
  • 7
  • 13
0

I know this is quite an old question but thought it's worth answering in case anyone is still interested!

As jmgomez says above, implement the - handleUserActivity: method, but specifically, in that method you can check:

if (userInfo[CLKLaunchedTimelineEntryDateKey] != nil)

as a complication adds this to userInfo, so if there is a value there, you are launching from your complication.

hope this helps someone.

rootOfSound
  • 109
  • 1
  • 5