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

vakrilov picture vakrilov  路  3Comments

sarvagayatri picture sarvagayatri  路  3Comments

tsonevn picture tsonevn  路  3Comments

pkoleva picture pkoleva  路  3Comments

VladimirAmiorkov picture VladimirAmiorkov  路  3Comments