Office 365 add-in users can access add-ins through the Windows Outlook client, the Mac client, and OWA (android/iphone). Is there a way to identify device/application using office.js?
Asked
Active
Viewed 1,253 times
3 Answers
0
One way to detect the platform in JavaScript is via the user agent string. Here are examples for some of the specific cases you mentioned:
var ua = navigator.userAgent;
var plat = navigator.platform;
if(ua.match(/iPhone/i)){
//iPhone device
}
else if(ua.match(/iPad/i){
//iPad device
}
if(ua.toLowerCase().indexOf("android") > -1){
//Android OS
}
else if(plat.toLowerCase().indexOf("mac") > -1){
//Mac OS
}
else if(plat.indexOf("Win") > -1){
//Windows OS
}
However, depending on the reason why you want to detect the platform, you may want to use other methods of detecting specific features/functionality instead. The following post covers non-device-related ways to detect environment info, including the "Requirements" model which can check for API capabilities: Neat ways to get environment (i.e. Office version)

Community
- 1
- 1

Michael Saunders
- 2,662
- 1
- 12
- 21
-
this gives browser and OS details but how do we know app users coming through Outlook Mac/Outlook windows or OWA . cant i use **Office.context.mailbox. diagnostics.hostName** to detect application? [http://dev.office.com/reference/add-ins/outlook/Office.context.mailbox.diagnostics](http://dev.office.com/reference/add-ins/outlook/Office.context.mailbox.diagnostics) – DevÁsith Jul 08 '16 at 12:22