Reputation: 1143
I have this code in order to recognize the platform the user use:
ionic.Platform.ready(function(){
// will execute when device is ready, or immediately if the device is already ready.
var deviceInformation = ionic.Platform.device();
var isWebView = ionic.Platform.isWebView();
var isIPad = ionic.Platform.isIPad();
var isIOS = ionic.Platform.isIOS();
var isAndroid = ionic.Platform.isAndroid();
var isWindowsPhone = ionic.Platform.isWindowsPhone();
console.log("isWebView" ,isWebView);
var currentPlatform = ionic.Platform.platform();
var currentPlatformVersion = ionic.Platform.version();
});
isWebView return false when I on web. Why?
currentPlatform return 'web32' - how can I see all options for currentPlatform ?
thanks
Upvotes: 1
Views: 1866
Reputation: 1426
Platform.isWebView() is works on Web server. When you run ionic serve Command it returns false. Following are the test cases:
1. ionic.Platform.isWebView() (will be false in ionic serve, true on device/web server)
2. !!window.cordova (same as above if you are just using cordova)
3. ionic.Platform.is('browser') (will be true in ionic serve, false on device/ webserver)
Upvotes: 0
Reputation: 412
Platform.isWebView() checks to see if window.cordova and window.phonegap exist, and returns true or false. If you're running on the web, it should return false because cordova and phonegap don't exist.
As for currentPlatform returning "web32", this is the return value of self.navigator.platform (at least Chrome and Firefox do).
If you're interested, you can view Ionic's source code on Github and in the Bower package.
Upvotes: 1