npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nativescript-platform-free

v1.3.2

Published

A NativeScript plugin to easily deal with getting the platform running on. Since the original plugin requires a subscription now, this plugin is my attempt to maintain it to the point where it does not break.

Downloads

5

Readme

npm npm npm Twitter Follow

nativescript-platform-free

A NativeScript plugin to easily deal with and detect which platform you are on. Since the original plugin requires a subscription now, this plugin is my attempt to maintain it to the point where it does not break.

Developed by

MasterTech

License

This is released under the MIT License, meaning you are free to include this in any type of program -- However for entities that need a support contract, changes, enhancements and/or a commercial license please contact me at http://nativescript.tools.

I also do contract work; so if you have a module you want built for NativeScript (or any other software projects) feel free to contact me [email protected].

Donate Patreon

Requirements

Any version of NativeScript

Installation

tns plugin add nativescript-platform

Usage

To use the module you just require() it:

var myPlatform = require( "nativescript-platform" );
if (myPlatform.android) {
  // do android specific stuff
}

please note you can also simple do, and then the nsPlatform will be available globally everywhere:

require( "nativescript-platform" );
if (nsPlatform.ios) {
 // do ios specific stuff
}

nsPlatform will be declared globally. My recommendation is just to include it in the app.js and then use it everywhere.

You ask, how exactly does this help?

This wraps up several simple ways to check for the platform you are on. This comes up commonly when you are trying to do stuff on just one platform.

Breaking changes

Removed initial windows phone support, its been 4 years -- I don't think NativeScript will ever build actual windows phone apps.

API

Functions

  • .isAndroid();
  • .isIOS(); returns true or false depending on the platform it is on Example:
if (nsPlatform.isAndroid()) { /* do my android specific stuff */ }
  • .hasSoftNav(); returns if device is using Soft Navigation.

Variables

  • .ios
  • .android
  • Is set to either true or false for the platform it is on Example:
if (nsPlatform.ios) { /* do my ios specific stuff */ }

Switch Statement support

.platform

  • .type.IOS
  • .type.ANDROID Example:
switch (nsPlatform.platform) {
  case nsPlatform.type.IOS:     // Do iOS stuff
  case nsPlatform.type.ANDROID: // Do Android stuff
}

.deviceType

Tablet or Phone

.screen

  • .width - Width of Screen (DIP)
  • .height - Height of Screen (DIP)
  • .scale - Scale of Screen (DIP)
  • .widthPixels - Width of Screen (Pixels)
  • .heightPixels - Height of Screen (Pixels)

.device

  • .emulator - True or False
  • .model - Model number of device
  • .name - Name of device (might be the same as model)
  • .manufacturer - Manufacturer of the device
  • .notch - true or false, if device has a notch.
  • .buttonLess - true or false, APPLE only -- if the device has no home button. ( .hasSoftNav() supports both android and ios )
console.log(nsPlatform.manufacturer, nsPlatform.name);
// Outputs: "Apple iPhoneX"