Issue
I have worked on few tutorials and at last found something regarding this in ionic framework.....
They gave some codes that use ionic native and i did the same by embedding the below code:
//Display OS name and version (Start)
import { Device } from 'ionic-native';
console.log('Device OS is: ' + Device.device.platform);
console.log('Device OS Version is: ' + Device.device.version);
//Display OS name and version (End)
While using ionic serve i got this in the console:
'Device OS is: undefined'
'Device OS version is: undefined'
Then i guessed it wont work in browser and i tried building and run in my phone but still the same log comes...
PS: I have just started with ionic
Thank you in advance :)
Solution
Please see this link http://ionicframework.com/docs/api/utility/ionic.Platform/
angular.module('PlatformApp', ['ionic'])
.controller('PlatformCtrl', function($scope) {
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();
var currentPlatform = ionic.Platform.platform();
var currentPlatformVersion = ionic.Platform.version();
ionic.Platform.exitApp(); // stops the app
});
Answered By - Anil Ravsaheb Ghodake
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.