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?
2 Answers
0
votes
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)
0
votes
If you only care about where the request came from, whether it was Outlook for windows/Mac/ web app) you could use the hostname setting from Office.js. more details here