In my phone app, the WCSession
is activated within the AppDelegate's didFinishLaunchingWithOptions
method. The watch app is sending an applicationContext
to the phone app. Suppose the phone app is not running at the time of this transfer, and when the phone app is launched later, how early can the call to didReceiveApplicationContext
come into the phone app? I am not worried about the delay or how late it arrives. I am wondering if there is a possibility that the call can come in before the rootViewController's viewDidLoad
method runs. Can this session event get into the event loop somewhere in between the events of UIWindow
creation and the viewDidLoad
on the rootViewController
, as the app is launching on the phone?
In my tests with the apps on real devices, it happened always after the viewDidLoad
invocation but often before the AppDelegate's applicationDidBecomeActive
.
I am using a storyboard. However I am interested in learning any possible differences, had the main view been created in the code. Also the actions within the didReceiveApplicationContext
do not touch any of the views or subviews. It just stores the data and notifies any registered view controllers.
So far I have not found any explicit or implicit guarantee as to when the buffered
applicationContext
will be delivered to the phone, as it launches. By explicit, I am referring to any documented data on the order of the events (say, only after the app becomes active). By implicit, what I mean is any logical inference based on the knowledge of the main run loop as well as the start time events of an app, which can assure that the delivery will no way be attempted before a certain stage in the launch process. As such, I will just note down my observations here.When I used only the
applicationContext
to pass data to a non-running app on the iPhone, it always got delivered after theviewDidLoad
method call on therootViewController
, as and when the phone app eventually launched. However, if I perform asendMessage
from watch to phone following asendApplicationContext
, it would wake up the app on the phone as expected. At this time, the bufferedapplicationContext
sometimes seems to get delivered to the phone even before loading the view of therootViewController
.