Ionic.platform.platform() returns android on wp8.1


#1

Hi

I have create a wp8 project with this command

Ionic platform add wp8

I opened visual studio project.
I changed project file with context menu to targetting windows phone 8.1.
After that all platform spesific behaviours up to android.

I add log

Console.log(ionic.Platform.platform())

getting ‘android’

Why and how to correct


#2

I think it came from the new IEMobile user agent:
“Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 635) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537”


#3

Just a note, we don’t really support WP8, so there are bound to be some issues.


#4

Yes I know and after all you are the best :slight_smile:

I missed up browser identity, thanks mathias_muller. I will overcome somehow.


#5

At the very least (supported or not) the platform should return the correct value when running on Windows Phone. This has the potential to break a considerable amount of code.


#6

Well you don’t need ionic for that. ionic.platform.platform is more internal but you can use the raw cordova logic.

.controller('MainCtrl', function($scope, $ionicPlatfrom){
  $ionicPlatfrom.ready(function(){
      console.log(window.device.platform);
  });
})


#7

I bumped into this today and opened a ticket before I spotted this forum post:

Basically re-ordering the if statement with the windows check before Android should get around Microsofts brain dead user agent string:

https://github.com/driftyco/ionic/blob/master/js/utils/platform.js#L247

In the mean time I am using this work around:

if (navigator.userAgent.indexOf("Windows Phone") > -1) {
}

Hopefully Google and Apple won’t put that in their User Agent strings.