I know this question was asked a long time ago, but it was something I was also looking for, and then stumbled upon the Office.context
object, which gives me all the information I need about the hosting platform of the Office Add-in.
Some examples to follow...
Calling Office.context
on macOS, via Outlook Desktop
:
{
contentLanguage: "en-US"
diagnostics: {
host: "Outlook",
version: "16.47.314.0",
platform: "Mac"
},
displayLanguage: "en-US",
host: "Outlook",
isDialog: false,
platform: "Mac"
}
Calling Office.context
on macOS, via Outlook Web
:
{
contentLanguage: "",
diagnostics: {
host: "Outlook",
platform: "OfficeOnline",
version: "0.0.0.0"
},
displayLanguage: "en-US",
host: "Outlook",
isDialog: false,
platform: "OfficeOnline"
}
So looking at the platform
value is probably the most useful in your situation, where you can learn if this Add-in is being accessed via the web, mobile, desktop, etc.
All of the possible platform
values can be found here: https://learn.microsoft.com/en-us/javascript/api/office/office.platformtype?view=excel-js-preview
The documentation for Office.context
Interface can be found here: https://learn.microsoft.com/en-us/javascript/api/office/office.context?view=excel-js-preview#platform