Nativescript-angular: How to detect iPhone or Android Model in Nativescript Angular

Created on 2 Feb 2018  路  3Comments  路  Source: NativeScript/nativescript-angular

PSST! Want to get faster responses to bug reports and important issues? Help us keep the issue tracker organized by:

  • Reporting bugs. Please include all details about the problem and provide a sample app (consider using the playground for this.
  • Proposing features and enhancements.
  • Discussing implementation details.

Please move all other content to the forums.

Most helpful comment

@sunpasup it is not clear what you are trying to achieve because there is no information provided for the problem you are facing.

If you need to create different logic for iOs and Android you can achieve that in several ways including wrapping the code in platform-specific checks.

import { isAndroid, isIOS } from "platform";

if (isAndroid) {
    // Android code here
} else if (isIOS) {
    // iOS code here
}

All 3 comments

@sunpasup it is not clear what you are trying to achieve because there is no information provided for the problem you are facing.

If you need to create different logic for iOs and Android you can achieve that in several ways including wrapping the code in platform-specific checks.

import { isAndroid, isIOS } from "platform";

if (isAndroid) {
    // Android code here
} else if (isIOS) {
    // iOS code here
}

for me the import goes something like:

import {isAndroid, isIOS} from 'tns-core-modules/ui/page';

It appears 'platform' is deprecated.

import {isAndroid, isIOS} from 'tns-core-modules/ui/page'
works for me too

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sulman633 picture Sulman633  路  3Comments

samuelvisscher picture samuelvisscher  路  3Comments

triniwiz picture triniwiz  路  3Comments

bhavincb picture bhavincb  路  3Comments

EricRobertBrewer picture EricRobertBrewer  路  3Comments