Hi,
I’ve been following a nice tutorial by Nic Raboy to determine network availability.
However, my app is complaining when I call platform.device(). The error I catch reads _this.platform.device is not a function.
I see that the Ionic v1 API has exposed the device() function, however, there’s no mention of it in the current v2 API
Ionic v1 API: http://ionicframework.com/docs/api/utility/ionic.Platform/
Ionic v2 API as of April 7 '16: http://ionicframework.com/docs/v2/api/platform/Platform/
Original tutorial: https://www.thepolyglotdeveloper.com/2016/01/determine-network-availability-in-an-ionic-2-mobile-app/
I’d really appreciate any insight getting around this problem.
Thanks,
Ryan
Ionic Team?
Does anyone know how to test network connectivity now that Platform::device() is no longer an exposed function?
@ryanlogsdon Do you have some sample code? What exactly do you wan’t to check, since platform still exists in Ionic V2. If you want to know which device you’re on, simply check it one by one. Their aren’t many options you could try. If you want to now whether you are in the browser or on a cordova platform, check it bij importing Platform into your component, add it to the constructor and assign it. Then you can just als platform.is(‘cordova’) if you want to know if you’re running on a cordova environment or ask platform.is(‘ios’) for ios etc etc. If you want to know if you are NOT running cordova, you could always negate platform.is(‘cordova’) by using an exclamation mark.
You could always use the native network implementation provided with ionic as well, documented here.
hi @luukschoen, thanks a lot! What I was looking for was the Network class. The functionality seems to have been removed from the Platform class and moved to Network.