CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tns-platform-declarations

Platform-specific TypeScript declarations for NativeScript for accessing native objects

84

1.23x
Overview
Eval results
Files

task.mdevals/scenario-8/

Device Information Utility

Create a simple NativeScript utility that retrieves basic device information from both Android and iOS platforms.

Requirements

Your utility should provide a function that returns a JavaScript object containing the following device information:

For Android devices:

  • The Android SDK version number
  • The device manufacturer name
  • The device model name

For iOS devices:

  • The iOS system version string
  • The device name
  • The device model identifier

API

export interface DeviceInfo {
  platform: 'android' | 'ios';
  osVersion: string;
  manufacturer?: string;  // Android only
  deviceModel: string;
  deviceName: string;
}

export function getDeviceInfo(): DeviceInfo;

Implementation

@generates

The function should detect the current platform and retrieve the appropriate information from the native APIs. Return the data as a properly typed object.

Test Cases

  • When running on Android, it returns an object with platform set to 'android', includes manufacturer, deviceModel, deviceName, and osVersion @test
  • When running on iOS, it returns an object with platform set to 'ios', includes deviceModel, deviceName, and osVersion @test
  • The returned object always has a valid platform value of either 'android' or 'ios' @test

Dependencies { .dependencies }

tns-platform-declarations { .dependency }

Provides TypeScript type definitions for accessing native Android and iOS platform APIs.

Install with Tessl CLI

npx tessl i tessl/npm-tns-platform-declarations

tile.json