Sp-dev-docs: SharePoint native mobile app (iOS / Android) detection & deep linking

Created on 15 Mar 2018  Â·  8Comments  Â·  Source: SharePoint/sp-dev-docs

Category

  • [x] Question
  • [ ] Typo
  • [ ] Bug
  • [ ] Additional article idea

Is there a way to detect if the user is using the native mobile app for SharePoint? My SPFx WebPart needs to behave slightly differently in a mobile app than in the browser. Also, is there a way to deep link directly to a user profile in the mobile app?

Thanks

tracked question

Most helpful comment

Hi,

I'm also using some elements in DOM as workaround but seems a little bit hacky, A JavaScript environment/context variable would be great, I have been trying to find a clean way to identify if user is using SharePoint App without success, I subscribed to the thread, hope this get answered some day.

All 8 comments

This should be possible with user-agent inspection, but we'll confirm the right model in a day or two if there's additional ways to do this.

hold on there.... I can use spfx webparts in the sharepoint mobile client? i don't need to use powerapps if i want mobile? I had no idea. doubt many others did!

Sent from my iPad

On Mar 15, 2018, at 12:16 PM, Vesa Juvonen notifications@github.com wrote:

This should be possible with user-agent inspection, but we'll confirm the right model in a day or two if there's additional ways to do this.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@VesaJuvonen i had looked at the user agent already but it seemd a bit hacky.

Mobile App (iOS):

Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_6 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Mobile/15D100

Safari (iOS)

Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_6 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0 Mobile/15D100 Safari/604.1

The only difference is the missing Safari part. Haven't tested Android yet.

Hi @VesaJuvonen,
Do you have any information about this case?
Is the user agent the only way to detect that we are on the Sharepoint app?
I tried to watch the ribbon content with document.getElementById('SuiteNavPlaceHolder').innerHTML === "", but when it takes times to load on browser, we find ourselves in the same case that we are on the Sharepoint App or on the browser.
Waiting for your feedback.

Hi,

I'm also using some elements in DOM as workaround but seems a little bit hacky, A JavaScript environment/context variable would be great, I have been trying to find a clean way to identify if user is using SharePoint App without success, I subscribed to the thread, hope this get answered some day.

My 2 cents on this one to detect the environment where the page is rendered based on the user agent of Microsoft Teams and SharePoint mobile app

if (navigator.userAgent.indexOf('Linux') != -1 && navigator.userAgent.indexOf('wv') != -1) {
    console.log("SharePoint APP - Android");
}else if (navigator.userAgent.indexOf('iPhone') != -1 && navigator.userAgent.indexOf('Safari') == -1) {
    console.log("SharePoint APP - iOS iphone");
}else if (navigator.userAgent.indexOf('iPad') != -1 && navigator.userAgent.indexOf('Safari') == -1) {   
    console.log("SharePoint APP - iOS iPad");
}else if (navigator.userAgent.indexOf('iPhone') != -1 && navigator.userAgent.indexOf('Safari') == -1) {
    console.log("SharePoint APP - iOS Iphone");
}else if (navigator.userAgent.indexOf('Teams') != -1 && navigator.userAgent.indexOf('Electron') != -1) {
    console.log("Microsoft Teams - Desktop APP");
}else{
    console.log("Browser");
}

Hi!
This may be a bit offtopic, however, does anyone knows if besides detecting if user is accessing the site from the Mobile App, is there any way to obtain certain phone context information, as current Wifi ESSID or stuff like that? thanks

Currently navigator.userAgent for SharePoint iOS native app contains `SharePoint for iOS'

Was this page helpful?
0 / 5 - 0 ratings