ionic/angular pwa doesn't bootstrap when launched from home screen












1














I followed these guides to add pwa support and host my ionic v4 app:




  • https://www.joshmorony.com/create-a-pwa-with-angular-service-workers-in-ionic-4/

  • https://www.joshmorony.com/hosting-an-ionic-pwa-with-firebase-hosting/


The app loads fine in Safari, and I can also add the app to my home screen (ios). However, from the home screen, the app does not bootstrap when launched.



If I go to Safari DevTools and reload the page after launch, the app is just fine.



I'm also not exactly clear on the minimum requirements for a pwa. My app loads the google maps javascript api on launch, so it doesn't really work without a network connection. I'm not sure if that is part of the problem or not.



ionic info



Ionic:

ionic (Ionic CLI) : 4.3.1 (/Users/m/.nvm/versions/node/v8.9.4/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.15
@angular-devkit/build-angular : 0.8.7
@angular-devkit/schematics : 0.8.7
@angular/cli : 7.0.5
@ionic/angular-toolkit : 1.1.0

Capacitor:

capacitor (Capacitor CLI) : 1.0.0-beta.7
@capacitor/core : 1.0.0-beta.7

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.1.4, (and 10 other plugins)

System:

ios-deploy : 2.0.0
NodeJS : v8.9.4 (/Users/m/.nvm/versions/node/v8.9.4/bin/node)
npm : 6.4.1
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255


on reload of the pwa app from DevTools, I see this error:



[Error] ERROR
Error: Uncaught (in promise): SecurityError: MIME Type is not a JavaScript MIME type
vt (main.0c301dd161ca4cc6d73d.js:1:123807)
handleError (main.0c301dd161ca4cc6d73d.js:1:124014)
next (main.0c301dd161ca4cc6d73d.js:1:139466)
(anonymous function) (main.0c301dd161ca4cc6d73d.js:1:131304)
__tryOrUnsub (main.0c301dd161ca4cc6d73d.js:1:247187)
next (main.0c301dd161ca4cc6d73d.js:1:246340)
_next (main.0c301dd161ca4cc6d73d.js:1:245384)
next (main.0c301dd161ca4cc6d73d.js:1:245056)
next (main.0c301dd161ca4cc6d73d.js:1:272048)
emit (main.0c301dd161ca4cc6d73d.js:1:131085)
run (polyfills.0548e3ebf74d8c45f01b.js:1:2461)
onHandleError (main.0c301dd161ca4cc6d73d.js:1:133065)
runGuarded (polyfills.0548e3ebf74d8c45f01b.js:1:2721)
e (polyfills.0548e3ebf74d8c45f01b.js:1:11589)
microtaskDrainDone (polyfills.0548e3ebf74d8c45f01b.js:1:11638)
d (polyfills.0548e3ebf74d8c45f01b.js:1:10261)
promiseReactionJob


It seems like it should be related to Angular ServiceWorkers + MIME type error, but I'm using ionic build --prod; firebase deploy and the build output is all minimized.



Here's the network log when I launch the App from Home screen:



Network log when App is launched from home screen



And here's what it looks like after I click reload in DevTools



enter image description here










share|improve this question





























    1














    I followed these guides to add pwa support and host my ionic v4 app:




    • https://www.joshmorony.com/create-a-pwa-with-angular-service-workers-in-ionic-4/

    • https://www.joshmorony.com/hosting-an-ionic-pwa-with-firebase-hosting/


    The app loads fine in Safari, and I can also add the app to my home screen (ios). However, from the home screen, the app does not bootstrap when launched.



    If I go to Safari DevTools and reload the page after launch, the app is just fine.



    I'm also not exactly clear on the minimum requirements for a pwa. My app loads the google maps javascript api on launch, so it doesn't really work without a network connection. I'm not sure if that is part of the problem or not.



    ionic info



    Ionic:

    ionic (Ionic CLI) : 4.3.1 (/Users/m/.nvm/versions/node/v8.9.4/lib/node_modules/ionic)
    Ionic Framework : @ionic/angular 4.0.0-beta.15
    @angular-devkit/build-angular : 0.8.7
    @angular-devkit/schematics : 0.8.7
    @angular/cli : 7.0.5
    @ionic/angular-toolkit : 1.1.0

    Capacitor:

    capacitor (Capacitor CLI) : 1.0.0-beta.7
    @capacitor/core : 1.0.0-beta.7

    Cordova:

    cordova (Cordova CLI) : 8.0.0
    Cordova Platforms : ios 4.5.5
    Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.1.4, (and 10 other plugins)

    System:

    ios-deploy : 2.0.0
    NodeJS : v8.9.4 (/Users/m/.nvm/versions/node/v8.9.4/bin/node)
    npm : 6.4.1
    OS : macOS High Sierra
    Xcode : Xcode 10.0 Build version 10A255


    on reload of the pwa app from DevTools, I see this error:



    [Error] ERROR
    Error: Uncaught (in promise): SecurityError: MIME Type is not a JavaScript MIME type
    vt (main.0c301dd161ca4cc6d73d.js:1:123807)
    handleError (main.0c301dd161ca4cc6d73d.js:1:124014)
    next (main.0c301dd161ca4cc6d73d.js:1:139466)
    (anonymous function) (main.0c301dd161ca4cc6d73d.js:1:131304)
    __tryOrUnsub (main.0c301dd161ca4cc6d73d.js:1:247187)
    next (main.0c301dd161ca4cc6d73d.js:1:246340)
    _next (main.0c301dd161ca4cc6d73d.js:1:245384)
    next (main.0c301dd161ca4cc6d73d.js:1:245056)
    next (main.0c301dd161ca4cc6d73d.js:1:272048)
    emit (main.0c301dd161ca4cc6d73d.js:1:131085)
    run (polyfills.0548e3ebf74d8c45f01b.js:1:2461)
    onHandleError (main.0c301dd161ca4cc6d73d.js:1:133065)
    runGuarded (polyfills.0548e3ebf74d8c45f01b.js:1:2721)
    e (polyfills.0548e3ebf74d8c45f01b.js:1:11589)
    microtaskDrainDone (polyfills.0548e3ebf74d8c45f01b.js:1:11638)
    d (polyfills.0548e3ebf74d8c45f01b.js:1:10261)
    promiseReactionJob


    It seems like it should be related to Angular ServiceWorkers + MIME type error, but I'm using ionic build --prod; firebase deploy and the build output is all minimized.



    Here's the network log when I launch the App from Home screen:



    Network log when App is launched from home screen



    And here's what it looks like after I click reload in DevTools



    enter image description here










    share|improve this question



























      1












      1








      1







      I followed these guides to add pwa support and host my ionic v4 app:




      • https://www.joshmorony.com/create-a-pwa-with-angular-service-workers-in-ionic-4/

      • https://www.joshmorony.com/hosting-an-ionic-pwa-with-firebase-hosting/


      The app loads fine in Safari, and I can also add the app to my home screen (ios). However, from the home screen, the app does not bootstrap when launched.



      If I go to Safari DevTools and reload the page after launch, the app is just fine.



      I'm also not exactly clear on the minimum requirements for a pwa. My app loads the google maps javascript api on launch, so it doesn't really work without a network connection. I'm not sure if that is part of the problem or not.



      ionic info



      Ionic:

      ionic (Ionic CLI) : 4.3.1 (/Users/m/.nvm/versions/node/v8.9.4/lib/node_modules/ionic)
      Ionic Framework : @ionic/angular 4.0.0-beta.15
      @angular-devkit/build-angular : 0.8.7
      @angular-devkit/schematics : 0.8.7
      @angular/cli : 7.0.5
      @ionic/angular-toolkit : 1.1.0

      Capacitor:

      capacitor (Capacitor CLI) : 1.0.0-beta.7
      @capacitor/core : 1.0.0-beta.7

      Cordova:

      cordova (Cordova CLI) : 8.0.0
      Cordova Platforms : ios 4.5.5
      Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.1.4, (and 10 other plugins)

      System:

      ios-deploy : 2.0.0
      NodeJS : v8.9.4 (/Users/m/.nvm/versions/node/v8.9.4/bin/node)
      npm : 6.4.1
      OS : macOS High Sierra
      Xcode : Xcode 10.0 Build version 10A255


      on reload of the pwa app from DevTools, I see this error:



      [Error] ERROR
      Error: Uncaught (in promise): SecurityError: MIME Type is not a JavaScript MIME type
      vt (main.0c301dd161ca4cc6d73d.js:1:123807)
      handleError (main.0c301dd161ca4cc6d73d.js:1:124014)
      next (main.0c301dd161ca4cc6d73d.js:1:139466)
      (anonymous function) (main.0c301dd161ca4cc6d73d.js:1:131304)
      __tryOrUnsub (main.0c301dd161ca4cc6d73d.js:1:247187)
      next (main.0c301dd161ca4cc6d73d.js:1:246340)
      _next (main.0c301dd161ca4cc6d73d.js:1:245384)
      next (main.0c301dd161ca4cc6d73d.js:1:245056)
      next (main.0c301dd161ca4cc6d73d.js:1:272048)
      emit (main.0c301dd161ca4cc6d73d.js:1:131085)
      run (polyfills.0548e3ebf74d8c45f01b.js:1:2461)
      onHandleError (main.0c301dd161ca4cc6d73d.js:1:133065)
      runGuarded (polyfills.0548e3ebf74d8c45f01b.js:1:2721)
      e (polyfills.0548e3ebf74d8c45f01b.js:1:11589)
      microtaskDrainDone (polyfills.0548e3ebf74d8c45f01b.js:1:11638)
      d (polyfills.0548e3ebf74d8c45f01b.js:1:10261)
      promiseReactionJob


      It seems like it should be related to Angular ServiceWorkers + MIME type error, but I'm using ionic build --prod; firebase deploy and the build output is all minimized.



      Here's the network log when I launch the App from Home screen:



      Network log when App is launched from home screen



      And here's what it looks like after I click reload in DevTools



      enter image description here










      share|improve this question















      I followed these guides to add pwa support and host my ionic v4 app:




      • https://www.joshmorony.com/create-a-pwa-with-angular-service-workers-in-ionic-4/

      • https://www.joshmorony.com/hosting-an-ionic-pwa-with-firebase-hosting/


      The app loads fine in Safari, and I can also add the app to my home screen (ios). However, from the home screen, the app does not bootstrap when launched.



      If I go to Safari DevTools and reload the page after launch, the app is just fine.



      I'm also not exactly clear on the minimum requirements for a pwa. My app loads the google maps javascript api on launch, so it doesn't really work without a network connection. I'm not sure if that is part of the problem or not.



      ionic info



      Ionic:

      ionic (Ionic CLI) : 4.3.1 (/Users/m/.nvm/versions/node/v8.9.4/lib/node_modules/ionic)
      Ionic Framework : @ionic/angular 4.0.0-beta.15
      @angular-devkit/build-angular : 0.8.7
      @angular-devkit/schematics : 0.8.7
      @angular/cli : 7.0.5
      @ionic/angular-toolkit : 1.1.0

      Capacitor:

      capacitor (Capacitor CLI) : 1.0.0-beta.7
      @capacitor/core : 1.0.0-beta.7

      Cordova:

      cordova (Cordova CLI) : 8.0.0
      Cordova Platforms : ios 4.5.5
      Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.1.4, (and 10 other plugins)

      System:

      ios-deploy : 2.0.0
      NodeJS : v8.9.4 (/Users/m/.nvm/versions/node/v8.9.4/bin/node)
      npm : 6.4.1
      OS : macOS High Sierra
      Xcode : Xcode 10.0 Build version 10A255


      on reload of the pwa app from DevTools, I see this error:



      [Error] ERROR
      Error: Uncaught (in promise): SecurityError: MIME Type is not a JavaScript MIME type
      vt (main.0c301dd161ca4cc6d73d.js:1:123807)
      handleError (main.0c301dd161ca4cc6d73d.js:1:124014)
      next (main.0c301dd161ca4cc6d73d.js:1:139466)
      (anonymous function) (main.0c301dd161ca4cc6d73d.js:1:131304)
      __tryOrUnsub (main.0c301dd161ca4cc6d73d.js:1:247187)
      next (main.0c301dd161ca4cc6d73d.js:1:246340)
      _next (main.0c301dd161ca4cc6d73d.js:1:245384)
      next (main.0c301dd161ca4cc6d73d.js:1:245056)
      next (main.0c301dd161ca4cc6d73d.js:1:272048)
      emit (main.0c301dd161ca4cc6d73d.js:1:131085)
      run (polyfills.0548e3ebf74d8c45f01b.js:1:2461)
      onHandleError (main.0c301dd161ca4cc6d73d.js:1:133065)
      runGuarded (polyfills.0548e3ebf74d8c45f01b.js:1:2721)
      e (polyfills.0548e3ebf74d8c45f01b.js:1:11589)
      microtaskDrainDone (polyfills.0548e3ebf74d8c45f01b.js:1:11638)
      d (polyfills.0548e3ebf74d8c45f01b.js:1:10261)
      promiseReactionJob


      It seems like it should be related to Angular ServiceWorkers + MIME type error, but I'm using ionic build --prod; firebase deploy and the build output is all minimized.



      Here's the network log when I launch the App from Home screen:



      Network log when App is launched from home screen



      And here's what it looks like after I click reload in DevTools



      enter image description here







      angular ionic-framework google-maps-api-3 progressive-web-apps






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 at 2:08

























      asked Nov 11 at 2:58









      michael

      1,22432346




      1,22432346
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I'm using this as a workaround for now:



            async patch_PWA_bootstrap(){
          const RELOAD_LIMIT = 5000
          const el = document.getElementsByTagName('HTML')[0];
          const now = Date.now();
          if (el.classList.contains('plt-pwa')){
          const resp = await Storage.get({key:'PWA_RELOAD'});
          if ( now - JSON.parse(resp.value) < RELOAD_LIMIT)
          return; // wait at before next reload

          const cancel = setTimeout( async ()=>{
          // something not bootstrapping correctly with pwa. reload() fixes
          await Storage.set({key:'PWA_RELOAD', value:JSON.stringify(now)});
          window.location.reload();
          },100)
          }
          }


          I'm calling it when the PWA app loads and when it returns to foreground






          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%2f53245464%2fionic-angular-pwa-doesnt-bootstrap-when-launched-from-home-screen%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














            I'm using this as a workaround for now:



              async patch_PWA_bootstrap(){
            const RELOAD_LIMIT = 5000
            const el = document.getElementsByTagName('HTML')[0];
            const now = Date.now();
            if (el.classList.contains('plt-pwa')){
            const resp = await Storage.get({key:'PWA_RELOAD'});
            if ( now - JSON.parse(resp.value) < RELOAD_LIMIT)
            return; // wait at before next reload

            const cancel = setTimeout( async ()=>{
            // something not bootstrapping correctly with pwa. reload() fixes
            await Storage.set({key:'PWA_RELOAD', value:JSON.stringify(now)});
            window.location.reload();
            },100)
            }
            }


            I'm calling it when the PWA app loads and when it returns to foreground






            share|improve this answer


























              0














              I'm using this as a workaround for now:



                async patch_PWA_bootstrap(){
              const RELOAD_LIMIT = 5000
              const el = document.getElementsByTagName('HTML')[0];
              const now = Date.now();
              if (el.classList.contains('plt-pwa')){
              const resp = await Storage.get({key:'PWA_RELOAD'});
              if ( now - JSON.parse(resp.value) < RELOAD_LIMIT)
              return; // wait at before next reload

              const cancel = setTimeout( async ()=>{
              // something not bootstrapping correctly with pwa. reload() fixes
              await Storage.set({key:'PWA_RELOAD', value:JSON.stringify(now)});
              window.location.reload();
              },100)
              }
              }


              I'm calling it when the PWA app loads and when it returns to foreground






              share|improve this answer
























                0












                0








                0






                I'm using this as a workaround for now:



                  async patch_PWA_bootstrap(){
                const RELOAD_LIMIT = 5000
                const el = document.getElementsByTagName('HTML')[0];
                const now = Date.now();
                if (el.classList.contains('plt-pwa')){
                const resp = await Storage.get({key:'PWA_RELOAD'});
                if ( now - JSON.parse(resp.value) < RELOAD_LIMIT)
                return; // wait at before next reload

                const cancel = setTimeout( async ()=>{
                // something not bootstrapping correctly with pwa. reload() fixes
                await Storage.set({key:'PWA_RELOAD', value:JSON.stringify(now)});
                window.location.reload();
                },100)
                }
                }


                I'm calling it when the PWA app loads and when it returns to foreground






                share|improve this answer












                I'm using this as a workaround for now:



                  async patch_PWA_bootstrap(){
                const RELOAD_LIMIT = 5000
                const el = document.getElementsByTagName('HTML')[0];
                const now = Date.now();
                if (el.classList.contains('plt-pwa')){
                const resp = await Storage.get({key:'PWA_RELOAD'});
                if ( now - JSON.parse(resp.value) < RELOAD_LIMIT)
                return; // wait at before next reload

                const cancel = setTimeout( async ()=>{
                // something not bootstrapping correctly with pwa. reload() fixes
                await Storage.set({key:'PWA_RELOAD', value:JSON.stringify(now)});
                window.location.reload();
                },100)
                }
                }


                I'm calling it when the PWA app loads and when it returns to foreground







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 at 4:31









                michael

                1,22432346




                1,22432346






























                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2f53245464%2fionic-angular-pwa-doesnt-bootstrap-when-launched-from-home-screen%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()