How early can session didReceiveApplicationContext be called on the iPhone app as it launches












0















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.










share|improve this question





























    0















    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.










    share|improve this question



























      0












      0








      0








      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.










      share|improve this question
















      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.







      ios swift watchkit watchconnectivity wcsession






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 20:20







      mpathi

















      asked Nov 20 '18 at 23:41









      mpathimpathi

      3351319




      3351319
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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 the viewDidLoad method call on the rootViewController, as and when the phone app eventually launched. However, if I perform a sendMessage from watch to phone following a sendApplicationContext, it would wake up the app on the phone as expected. At this time, the buffered applicationContext sometimes seems to get delivered to the phone even before loading the view of the rootViewController.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403254%2fhow-early-can-session-didreceiveapplicationcontext-be-called-on-the-iphone-app-a%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            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 the viewDidLoad method call on the rootViewController, as and when the phone app eventually launched. However, if I perform a sendMessage from watch to phone following a sendApplicationContext, it would wake up the app on the phone as expected. At this time, the buffered applicationContext sometimes seems to get delivered to the phone even before loading the view of the rootViewController.






            share|improve this answer




























              0














              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 the viewDidLoad method call on the rootViewController, as and when the phone app eventually launched. However, if I perform a sendMessage from watch to phone following a sendApplicationContext, it would wake up the app on the phone as expected. At this time, the buffered applicationContext sometimes seems to get delivered to the phone even before loading the view of the rootViewController.






              share|improve this answer


























                0












                0








                0







                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 the viewDidLoad method call on the rootViewController, as and when the phone app eventually launched. However, if I perform a sendMessage from watch to phone following a sendApplicationContext, it would wake up the app on the phone as expected. At this time, the buffered applicationContext sometimes seems to get delivered to the phone even before loading the view of the rootViewController.






                share|improve this answer













                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 the viewDidLoad method call on the rootViewController, as and when the phone app eventually launched. However, if I perform a sendMessage from watch to phone following a sendApplicationContext, it would wake up the app on the phone as expected. At this time, the buffered applicationContext sometimes seems to get delivered to the phone even before loading the view of the rootViewController.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 2 '18 at 9:01









                mpathimpathi

                3351319




                3351319
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403254%2fhow-early-can-session-didreceiveapplicationcontext-be-called-on-the-iphone-app-a%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Xamarin.form Move up view when keyboard appear

                    Post-Redirect-Get with Spring WebFlux and Thymeleaf

                    Anylogic : not able to use stopDelay()