0
votes

I'm writing an Outlook OnSend addin (new style web addin, not old style COM), and would like to use a Service Worker to provide functionality when the user is offline. I've written an addin, and when I hit the addin's html page in Edge, I can see the service worker being installed and caching the addin files successfully.

However, when I run the addin in Outlook Desktop, it appears that the service worker is not being installed. I'm testing this by running Fiddler, and I can see that the adding files are being requested on each run, rather than coming from the cache that the service worker should be creating.

My addin HTML references a main.js (see below), which attempts to register the service worker. To provide some tracing/troubleshooting ability, I make an ajax call to a service. What this tells me is that:

  • The check for service worker support returns true
  • The call to navigator.serviceWorker.register never returns (successfully or otherwise)
  • Using Fiddler, I never see a request for the referenced "sw.js" file. I do see an edge process (microsoftedgesh) attempt to open an https connection to my server, but this doesn't request any files. All other traffic in fiddler is from the web view host component

Are service workers supported for outlook addins? I'm running Outlook version 2004 (12730.20270 click to run) and Windows 1909, so I'd expect Outlook to be using Edge rather than IE 11, and therefore to have service worker support.

For reference, my main.js looks like this:

if ('serviceWorker' in navigator) {
  sendMessage('1');
  try {
    navigator.serviceWorker.register('sw.js').then(function(registration) {
      sendMessage('2'); // Never sent
    }).catch(function(error) {
      sendMessage('3'); // Never sent
    });
  }
  catch(err) {
    sendMessage(err.message);
  }
}
else {
    sendMessage('4');
}

function sendMessage(message) {
    $.ajax({
        url: "../api/schedule",
        type: "POST",
        crossDomain: true,
        //contentType: "jsonp",
        contentType: 'application/json; charset=utf-8',
        data: message
    });
}
1

1 Answers

0
votes

Service Workers are currently unsupported in addins and any Service Workers usage will be disabled in the near future. We track add-in feature requests on our user-voice page. Please add your request there. Feature requests on user-voice are considered, when we go through our planning process