Detect between a mobile browser or a PhoneGap application

后端 未结 16 1914
小蘑菇
小蘑菇 2020-11-28 03:03

Is it possible to detect if the user is accessing through the browser or application using JavaScript?

I\'m developing a hybrid application to several mobile OS thr

16条回答
  •  一整个雨季
    2020-11-28 03:33

    Quick solution comes to mind is,

    onDeviceReady
    

    shall help you. As this JS call is invoked only by the Native bridge (objC or Java), the safari mobile browser will fail to detect this. So your on device app(phone gap) source base will initiate from onDeviceReady.

    And if any of the Phonegap's JS calls like Device.platform or Device.name is NaN or null then its obviously a mobile web call.

    Please check and let me know the results.

提交回复
热议问题