GithubHelp home page GithubHelp logo

apache / cordova-plugin-device Goto Github PK

View Code? Open in Web Editor NEW
385.0 45.0 427.0 488 KB

Apache Cordova Device Plugin

Home Page: https://cordova.apache.org/

License: Apache License 2.0

Java 17.01% JavaScript 52.74% Objective-C 30.25%
cordova library objective-c java nodejs javascript mobile android hacktoberfest ios

cordova-plugin-device's Introduction

title description
Device
Get device information.

cordova-plugin-device

Android Testsuite Chrome Testsuite iOS Testsuite Lint Test

This plugin defines a global device object, which describes the device's hardware and software. Although the object is in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(device.cordova);
}

Installation

cordova plugin add cordova-plugin-device

Properties

  • device.cordova
  • device.model
  • device.platform
  • device.uuid
  • device.version
  • device.manufacturer
  • device.isVirtual
  • device.serial
  • device.sdkVersion (Android only)

device.cordova

Returns the Cordova platform's version that is bundled in the application.

The version information comes from the cordova.js file.

This property does not display other installed platforms' version information. Only the respective running platform's version is displayed.

Example:

If Cordova Android 10.1.1 is installed on the Cordova project, the cordova.js file, in the Android application, will contain 10.1.1.

The device.cordova property will display 10.1.1.

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows
  • OS X

device.model

The device.model returns the name of the device's model or product. The value is set by the device manufacturer and may be different across versions of the same product.

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows
  • OS X

Quick Example

// Android: Pixel 4             returns "Pixel 4"
//          Motorola Moto G3    returns "MotoG3"
// Browser: Google Chrome       returns "Chrome"
//          Safari              returns "Safari"
// iOS:     iPad Mini           returns "iPad2,5"
//          iPhone 5            returns "iPhone5,1"
// See https://www.theiphonewiki.com/wiki/Models
// OS X:                        returns "x86_64"
//
var model = device.model;

Android Quirks

iOS Quirks

The model value is based on the identifier that Apple supplies.

If you need the exact device name, e.g. iPhone 13 Pro Max, a mapper needs to be created to convert the known identifiers to the associated device name.

Example: The identifier iPhone14,3 is associated to the device iPhone 13 Pro Max.

For the full list of all identifiers to device names, see here

device.platform

Get the device's operating system name.

var string = device.platform;

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows
  • OS X

Quick Example

// Depending on the device, a few examples are:
//   - "Android"
//   - "browser"
//   - "iOS"
//   - "WinCE"
//   - "Mac OS X"
//
var devicePlatform = device.platform;

device.uuid

Get the device's Universally Unique Identifier (UUID).

var string = device.uuid;

Description

The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.

Supported Platforms

  • Android
  • iOS
  • Windows
  • OS X

Quick Example

// Android: Returns a random 64-bit integer (as a string, again!)
//
// iOS: (Paraphrased from the UIDevice Class documentation)
//         Returns the [UIDevice identifierForVendor] UUID which is unique and the same for all apps installed by the same vendor. However the UUID can be different if the user deletes all apps from the vendor and then reinstalls it.
//
// Windows Phone 7 : Returns a hash of device+current user,
// if the user is not defined, a guid is generated and will persist until the app is uninstalled
//
var deviceID = device.uuid;

Android Quirk

The uuid on Android is a 64-bit integer (expressed as a hexadecimal string). The behaviour of this uuid is different on two different OS versions-

For < Android 8.0 (API level 26)

In versions of the platform lower than Android 8.0, the uuid is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device.

For Android 8.0 or higher

The above behaviour was changed in Android 8.0. Read it in detail here.

On Android 8.0 and higher versions, the uuid will be unique to each combination of app-signing key, user, and device. The value is scoped by signing key and user. The value may change if a factory reset is performed on the device or if an APK signing key changes.

Read more here https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID.

iOS Quirk

The uuid on iOS uses the identifierForVendor property. It is unique to the device across the same vendor, but will be different for different vendors and will change if all apps from the vendor are deleted and then reinstalled. Refer here for details. The UUID will be the same if app is restored from a backup or iCloud as it is saved in preferences. Users using older versions of this plugin will still receive the same previous UUID generated by another means as it will be retrieved from preferences.

OS X Quirk

The uuid on OS X is generated automatically if it does not exist yet and is stored in the standardUserDefaults in the CDVUUID property.

device.version

Get the operating system version.

var string = device.version;

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows
  • OS X

Quick Example

// Android:    Froyo OS would return "2.2"
//             Eclair OS would return "2.1", "2.0.1", or "2.0"
//             Version can also return update level "2.1-update1"
//
// Browser:    Returns version number for the browser
//
// iOS:     iOS 3.2 returns "3.2"
//
// Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384
//
// OS X:        El Capitan would return "10.11.2"
//
var deviceVersion = device.version;

device.manufacturer

Get the device's manufacturer.

var string = device.manufacturer;

Supported Platforms

  • Android
  • iOS
  • Windows

Quick Example

// Android:    Motorola XT1032 would return "motorola"
// iOS:     returns "Apple"
//
var deviceManufacturer = device.manufacturer;

device.isVirtual

whether the device is running on a simulator.

var isSim = device.isVirtual;

device.sdkVersion (Android only)

Get the Android device's SDK version (SDK_INT).

Supported Platforms

  • Android

OS X and Browser Quirk

The isVirtual property on OS X and Browser always returns false.

device.serial

Get the device hardware serial number (SERIAL).

var string = device.serial;

Supported Platforms

  • Android
  • OS X

Android Quirk

As of Android 9, the underlying native API that powered the uuid property is deprecated and will always return UNKNOWN without proper permissions. Cordova have never implemented handling the required permissions. As of Android 10, all non-resettable device identifiers are no longer readable by normal applications and will always return UNKNOWN. More information can be read here.

device.isiOSAppOnMac

The iOS app is running on the Mac desktop (Apple Silicon ARM64 processor, M1 or newer). This parameter is only returned for iOS V14.0 or later, and is not returned for Android devices.

var boolean = device.isiOSAppOnMac;

Supported Platforms

  • iOS

iOS Privacy Manifest

As of May 1, 2024, Apple requires a privacy manifest file to be created for apps and third-party SDKs. The purpose of the privacy manifest file is to explain the data being collected and the reasons for the required APIs it uses. Starting with [email protected], APIs are available for configuring the privacy manifest file from config.xml.

This plugin comes pre-bundled with a PrivacyInfo.xcprivacy file that contains the list of APIs it uses and the reasons for using them.

However, as an app developer, it will be your responsibility to identify additional information explaining what your app does with that data.

In this case, you will need to review the "Describing data use in privacy manifests" to understand the list of known NSPrivacyCollectedDataTypes and NSPrivacyCollectedDataTypePurposes.

For example, if you collected the device ID for app functionality and analytics, you would write the following in config.xml:

<platform name="ios">
    <privacy-manifest>
        <key>NSPrivacyTracking</key>
        <false/>
        <key>NSPrivacyTrackingDomains</key>
        <array/>
        <key>NSPrivacyAccessedAPITypes</key>
        <array/>
        <key>NSPrivacyCollectedDataTypes</key>
        <array>
            <dict>
                <key>NSPrivacyCollectedDataType</key>
                <string>NSPrivacyCollectedDataTypeDeviceID</string>
                <key>NSPrivacyCollectedDataTypeLinked</key>
                <false/>
                <key>NSPrivacyCollectedDataTypeTracking</key>
                <false/>
                <key>NSPrivacyCollectedDataTypePurposes</key>
                <array>
                    <string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
                    <string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
                </array>
            </dict>
        </array>
    </privacy-manifest>
</platform>

Also, ensure all four keys—NSPrivacyTracking, NSPrivacyTrackingDomains, NSPrivacyAccessedAPITypes, and NSPrivacyCollectedDataTypes—are defined, even if you are not making an addition to the other items. Apple requires all to be defined.

cordova-plugin-device's People

Contributors

agrieve avatar alsorokin avatar basvanbeek avatar bennmapes avatar clelland avatar cmarcelk avatar dblotsky avatar erisu avatar filmaj avatar hardeep avatar infil00p avatar janpio avatar jcesarmobile avatar ldeluca avatar macdonst avatar nikhilkh avatar niklasmerz avatar pke avatar purplecabbage avatar raphinesse avatar rodms10 avatar sagrawal31 avatar shazron avatar stevengill avatar surajpindoria avatar tenfef avatar timbru31 avatar tripodsan avatar vladimir-kotikov avatar zalun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-device's Issues

UUID in debug and release mode is different

Bug Report

Problem

What is expected to happen?

UUID is the same when debug and release cause that's uuid of device, doesn't have any thing relative to the app

What does actually happen?

In development, build debug, release, they have different UUID, is this valid ?

Environment, Platform, Device

Environment: Linux
Platform: Android
Device: Xiaomi Mi 8 Lite

Version information

Everything is latest
SDK 26 (OREO)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

IOS: Device UUID change each time delete App and reinstall

Bug Report

IOS: Device UUID change each time delete App and reinstall.

Problem

What is expected to happen?

What does actually happen?

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

native implementations should not return info.cordova

From the current sourcecode:

// ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
// TODO: CB-5105 native implementations should not return info.cordova

Still present at:

cordova: browser.cordovaVersion,

devProps[@"cordova"] = [[self class] cordovaVersion];

@"cordova": [[self class] cordovaVersion],

(Note: https://issues.apache.org/jira/browse/CB-5105 says "iOS is doing something special, but doing it right, so don't make any changes to iOS." but no idea what that refers to)

this.device.uuid not returning anything unless it's inside post return data

Hello, I'm having some problems when i'm using this plugin.

For whatever reason, the only time that i can actually get "this.device.uuid" to return anything is inside of a post's promise.then. which is the post call that I need this to work for. I've tried getting it inside of a function, I've tried putting it in an async/await function, I've tried putting it in a function and then calling that function with document.addeventlistener('onready'), the only time that it will return anything is after I need it, and it's been holding me up for about 2 days now...

any thoughts or help on this would be amazing.

`Ionic:

Ionic CLI : 5.4.9 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.24
@angular-devkit/schematics : 8.3.26
@angular/cli : 8.3.26
@ionic/angular-toolkit : 2.3.3

Cordova:

Cordova CLI : 9.0.0
Cordova Platforms : android 8.1.0, ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.0, (and 10 other plugins)

Utility:

cordova-res : 0.9.0 (update available: 0.15.1)
native-run : 0.2.9 (update available: 1.2.1)

System:

ios-deploy : 1.9.2
ios-sim : 8.0.2
NodeJS : v12.13.0 (/usr/local/bin/node)
npm : 6.12.0
OS : macOS Catalina
Xcode : Xcode 12.0.1 Build version 12A7300
`

cordova-plugin-badge 0.8.8 "Badge" cordova-plugin-contacts 3.0.1 "Contacts" cordova-plugin-device 2.0.2 "Device" cordova-plugin-geolocation 4.0.2 "Geolocation" cordova-plugin-inappbrowser 4.0.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 4.2.0 "cordova-plugin-ionic-webview" cordova-plugin-nativeaudio 3.0.9 "Cordova Native Audio" cordova-plugin-nativestorage 2.3.2 "NativeStorage" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" onesignal-cordova-plugin 2.11.1 "OneSignal Push Notifications"

Location setting

For IOS there is location and locations for newer version of the IOS. May i know from which version onwards shld we use 'locations'

Thanks and Regards
minghwee92

ondeviceready won't fire because plugin does not cleanup after itself properly when removed(?)

Bug Report

Originally reported at #125

Problem

If an application has this plugin installed and, for some reason, it's not needed anymore and removed, ondeviceready won't fire anymore.
This seems to be caused by some leftover code... That's probably why the previous reporter mentioned the usual shenanigans of add/remove platform/plugins solved it.

What is expected to happen?

The event should fire as usual, since it's seemingly unrelated to this plugin.

What does actually happen?

ondeviceready never gets fired:
image

Logcat displays the following (easier to find if you filter logcat by the package name):

2023-10-14 22:59:13.783 29167-29267 PluginManager           io.cordova.hellocordova              D  exec() call to unknown plugin: Device
2023-10-14 22:59:13.834 29167-29167 chromium                io.cordova.hellocordova              I  [INFO:CONSOLE(80)] "[ERROR] Error initializing cordova-plugin-device: Class not found", source: https://localhost/plugins/cordova-plugin-device/www/device.js (80)
2023-10-14 22:59:18.645 29167-29167 chromium                io.cordova.hellocordova              I  [INFO:CONSOLE(1237)] "deviceready has not fired after 5 seconds.", source: https://localhost/cordova.js (1237)
2023-10-14 22:59:18.645 29167-29167 chromium                io.cordova.hellocordova              I  [INFO:CONSOLE(1230)] "Channel not fired: onCordovaInfoReady", source: https://localhost/cordova.js (1230)

Command or Code

$ cordova create sample-reproduction
$ cd sample-reproduction
$ cordova platform add android
$ cordova plugin add cordova-plugin-device
$ cordova plugin rm cordova-plugin-device
$ cordova run android

Environment, Platform, Device

  • cordova-android: 12.0.0 and 12.0.1
  • plugin: 2.1.0 (as in clean install below), and also our actual project had it installed on 1.1.4, upgraded to 2.1.0, then realized it's not used and thus, got removed. We also removed other plugins and didn't had this kind of trouble.
  • device: Android emulator, API 30

Version information

Nothing besides what was described above seems relevant.

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Swift errors on cordova ios export

Hi, I wanted to use this plugin in my app but I'm getting errors in xcode:
Screenshot 2019-03-11 at 16 47 37
Any idea how to fix this?

I also saw that the npm package is over 1 year old even though there was activity in this repo - why isn't any new version being published?

Cheers

[email protected] breaks existing projects that (npm tilde) reference ^2.x.x and use Cordova versions < 9

Bug Report

Problem

[email protected] breaks existing projects that (npm caret) reference ^2.x.x and use Cordova versions < 9

What is expected to happen?

[email protected] should not break existing projects that (npm caret) reference ^2.x.x and use Cordova versions < 9

What does actually happen?

Installing "cordova-plugin-device" for android
Failed to restore plugin "cordova-plugin-device" from config.xml. You might need to try adding it again. Error: code: engine.platform or engine.scriptSrc is not defined in custom engine "cordova-electron" from plugin "cordova-plugin-device" for android warn

Information

Clone https://github.com/hexagon-ecosys/cordova812-helloWorld and follow its README

Command or Code

cordova prepare

Environment, Platform, Device

Version information

node 16.14.2
npm 8.5.0
cordova 8.1.2

This is probably not a supported configuration, but hopefully this bug helps someone else.

There are a couple of solutions -

  1. hard-set the reference to 2.0.3 to NOT pull the electron support related changes introduced in 2.1.0.
  2. Upgrade Cordova to at least 9. I tested 9.0.0, 10.0.0 and 11.0.0 where this problem is not reproducible.

Checklist

  • [x ] I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above

device.version returns wrong version on android Q

Bug Report

Problem

Wront version returned on device running Android Q, Pixel 3.

What is expected to happen?

device.version on Android Q should return 10 or similar.

What does actually happen?

device.version on Android Q returns a value considered <= 5.

Information

Unfortunately I don't own an android Q device, but I get an user reporting that issue, and according to my code the output to .version it's considered a version lower or equal to 5, but I can't tell the value.

Android Q is still on beta so is not a high priority issue, but something to check.

Command or Code

device.version

Environment, Platform, Device

Ionic, Android, Pixel 3

Version information

Ionic CLI 4.12.0
Ionic Framewoek 3.9.2
@ionic/app-scripts 3.1.1

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

pod version is not the latest version

The pod component version is 1.1.3, not the latest version

Problem

What is expected to happen?

What does actually happen?

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

New Edge browser based on Chromium not recognized correctly

Bug Report

Problem

What is expected to happen?

The device.model which will execute this code, now detects the new Edge browser which is based on Chromium and released on 15th January as Chrome, which would be incorrect.

What does actually happen?

It detects the new Edge browser as Chrome.

Information

I think it should also not detect this new browser as Edge, but maybe as EdgeChromium? Because there are big difference between the "old" Edge en the new Chromium Edge. And maybe you would like to block the old Edge, but the new Edge is ok! Therefore the detection should return a different browser name I would suggest.

When the "old" Edge was released the following issue solved this check for the old Edge: https://issues.apache.org/jira/browse/CB-12105.

The new Chromium based Edge exposed the following userAgent string:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36 Edg/79.0.309.54

Command or Code

This code has the issue: https://github.com/apache/cordova-plugin-device/blob/master/src/browser/DeviceProxy.js#L35

It could be updated to the next code to see a difference between the old and the new Edge.

function getBrowserInfo (getModel) {
    var userAgent = navigator.userAgent;
    var returnVal = '';
    var offset;

    if ((offset = userAgent.indexOf('Edge')) !== -1) {
        returnVal = (getModel) ? 'Edge' : userAgent.substring(offset + 5);
    } else if ((offset = userAgent.indexOf('Edg')) !== -1) {
        returnVal = (getModel) ? 'EdgeChromium' : userAgent.substring(offset + 4);
    } else if ((offset = userAgent.indexOf('Chrome')) !== -1) {
        returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
    } else if ((offset = userAgent.indexOf('Safari')) !== -1) {
        if (getModel) {
            returnVal = 'Safari';
        } else {
            returnVal = userAgent.substring(offset + 7);

            if ((offset = userAgent.indexOf('Version')) !== -1) {
                returnVal = userAgent.substring(offset + 8);
            }
        }
    } else if ((offset = userAgent.indexOf('Firefox')) !== -1) {
        returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8);
    } else if ((offset = userAgent.indexOf('MSIE')) !== -1) {
        returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5);
    } else if ((offset = userAgent.indexOf('Trident')) !== -1) {
        returnVal = (getModel) ? 'MSIE' : '11';
    }

    if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) {
        returnVal = returnVal.substring(0, offset);
    }

    return returnVal;
}

Environment, Platform, Device

The new Edge released on 15th January

Version information

N/A

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Version 2.0.3 not in the npm repository

Bug Report

Problem

The latest version 2.0.3 is not in the npm repository and therefore cordova plugin add [email protected] fails

What is expected to happen?

cordova plugin add [email protected] succeeds

What does actually happen?

cordova plugin add [email protected] fails

Information

Please publish the latest version to npm.
As far as I know, these other packages are in also the same situation:

  • cordova-plugin-inappbrowser
  • cordova-plugin-network-information
  • cordova-plugin-screen-orientation
  • cordova-plugin-splashscreen
  • cordova-plugin-statusbar
  • cordova-plugin-whitelist

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Device uuid is null on platform browser

Bug Report

Device uuid is null on platform browser

Problem

By running ionic cordova run browser device uuid is null as Device object is empty

What is expected to happen?

Device info should be there as it supports browser platform

What does actually happen?

Device object is empty when running the application on browser platform

Information

Here's my code

import { Device } from '@ionic-native/device/ngx';

constructor(private device: Device) { }

console.log('Device UUID is: ' + this.device.uuid);
Result: Device UUID is: null

Command or Code

ionic cordova run browser

Environment, Platform, Device

Platform is browser using chrome

Version information

@ionic-native/device": "^5.5.0

Please help me out how to resolve this problem. I have tested the code on android device. It's working fine

Cordova Electron Platform

Feature Request

Motivation Behind Feature

Cordova now includes Electron as a platform which runs differently than browser in some functionality (Push API amongst other things)

Feature Description

If the app is run using Electron as a platform return electron, not browser

Alternatives or Workarounds

Currently Electron is included in the browser user agent, but only the chromium variant is detected by the plugin so manual user agent detection is being used

Enable configration for device uuid

Feature Request

Motivation Behind Feature

Currently there are rules in China Mainland regarding to how device uuid can be collected and used.
Some of the android distribution shops eg: Huawei shop, disallow collecting device uuid.
And therefore I wonder if we can support configuration to enable/disable device uuid feature.

Thanks

Feature Description

Support configuration to enable/disable device uuid feature

Alternatives or Workarounds

Alternatively we can comment out #GetUuid() method after the native code is built.

ionic cordova build --prod --release only shows white blank page

Bug Report

Problem

when I do prod build (ionic cordova build android --prod --release), the app is just showing white blank page

Command or Code

ionic cordova build android --prod --release

Environment, Platform, Device

ionic v4.0.2
ionic cli v4.10.3
angular v6.1.1

Drop cordova-osx support

Feature Request

Motivation Behind Feature

With the deprecation of cordova-osx as an officially supported platform it seems a logical step to also deprecate its support within this plugin.

Feature Description

Remove <platform name="osx"> and related files.

Alternatives or Workarounds

n/a

Next steps

If this is a wanted change, I'm willing to create a PR for it.

IOS: device.uuid returned the same characters on two different iphones

Hello,
we use the uuid to allow only 1 device to login to our app, but today we ran into a problem where a user was able to login from a new device without activating it. after analyzing the logs to see how that happened, i was able to notice that the same uuid was generated on two different devices. if someone can enlighten me how is that possible?
old phone: iphone 10
new phone: iPhone 11 Pro, ios: 13.3

now i know that on the same device, if all the apps of the vendor are uninstalled and one of them installed, the uuid will be different. but i can't find any answer for my case. using itunes backup will not change the uuid?

Ability to get the device name

Feature Request

I think this is a very important piece of information this plugin can offer. For example, writing device.name can give me- Shashank's iPhone or My Samsung J6.

Motivation Behind Feature

Only one motivation- Avoid installing one more plugin.

There is one plugin already available https://github.com/becvert/cordova-plugin-device-name which does the job but since this official Cordova plugin is already giving device information so why not include name.

I have seen many developers finding the name in this official Cordova plugin.

Feature Description

Get the device's name from the APIs as implemented here-

Alternatives or Workarounds

https://github.com/becvert/cordova-plugin-device-name

device.cordova?

device.cordova
Get the version of Cordova running on the device.

What does "version of Cordova running on the device" mean? Cordova CLI does not run on the device, Cordova.js is not really relevant, platform maybe?

If so, this should at least be clarified in the docs.

device.serial = 'unknown' on ios 12.3.1

Bug Report

using device.serial on IOS 12.3.1 returns 'unknown'.

Problem

What is expected to happen?

Using device.serial should return the device serial number.

What does actually happen?

device.serial on IOS 12.3.1 returns 'unknown'.

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • [x ] I searched for existing GitHub issues
  • [x ] I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above

divece is undefined for ios in 2.1.0 version

Bug Report

Problem

device is undefined for ios in 2.1.0 version

What is expected to happen?

I use check platform in my code

device.platform

and after update from version 2.0.3 to 2.1.0 the cod doesn't work because device is undefined

I was create test project and check it on ios v5.1.1 and for ios v6.2.0 - it's doesn't work for v2.1.0 and works for v2.0.3

see my test project in attachment
test.zip

What does actually happen?

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

iOS: deviceProperties method crashes when device is locked & data protection is set to "complete"

Bug Report

There is no null checking when creating the dictionary in the deviceProperties method.

Problem

On the Apple developer portal, if you set "data protection" to "complete" for your App ID, and then call this method while your device is locked (e.g., in response to a push notification) some of the properties will be null and result in a crash.

What is expected to happen?

Null properties should not be inserted in to the dictionary, and the App should not crash.

What does actually happen?

The App crashes in the background every time.

Information

An easy way to reproduce this is to turn off your device, then turn it on, but do not enter your passcode to unlock the device. With your device in this state, send a push notification to your app that calls the deviceProperties method.

Command or Code

Environment, Platform, Device

This was first noticed on iOS 13

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

device.uuid=NULL on IOS 12.3.1

Problem

using device.uuid on IOS 12.3.1 returns all as NULL

'Device Name: ' + device.name + '
' +
'Device Cordova: ' + device.cordova + '
' +
'Device Platform: ' + device.platform + '
' +
'Device UUID: ' + device.uuid + '
' +
'Device Version: ' + device.version + '
';

What is expected to happen?

on IOS 12.2 device.uuid will display the correct uuid, however on IOS 12.3.1 they return NULL.

What does actually happen?

device.uuid returns a NULL

Information

working from a cordova build, it has worked on all of our devices until we did an update to 12.3.1 . What is the work around, or a solution to gather the IOS uuid

Command or Code

run device.uuid on 12.3.1 and on 12.2.1

Environment, Platform, Device

Version information

Checklist

  • [x ] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above

Does cordova is spying user's information without any knowledge of developers behind the plugins.

Bug Report

Problem

What is expected to happen?

What does actually happen?

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

image

Our company get above message from google play, some features in app is uploading phone information to cordova server. is this ? in cordova's credibility.

iPhone/ipad simulator model number are not accurate

Bug Report

Problem

iPhone/ipad simulator model number not accurate

What is expected to happen?

While using the plugin we should get the exact mode number but getting 1 or 2 higher than the model present with some extra string number also
Like for iphone 8 plus getting iphone10,5
For iphone se getting iphone 12,3
So it is giving me wrong info everytime

What does actually happen?

It should give the exact device number

Information

Use Cordova plugin device

Command or Code

Import {Device} from "@ionic-native/device/ngx"
..
Private deviceInfo: Device
..
Console.log(this.deviceInfo.model)

Environment, Platform, Device

Every iphone/ipad simulator

Version information

Xcode 13.0
Ionic and capacitor with angular
iPhone/ipad simulator

Checklist

  • [x ] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above

app set id

Bug Report

Problem

What is expected to happen?

The device ID should be sent in android using an App set ID. https://developer.android.com/training/articles/app-set-id

What does actually happen?

This is the new and correct way of sending UID's in android.

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

crashes Ionic 5 app

Bug Report

as per Ionic docs i have:

import { Device } from '@ionic-native/device/ngx';
constructor(private device: Device) { }
...
console.log('Device UUID is: ' + this.device.uuid);

adding the constructor declaration gives:

app.component.html:13 ERROR NullInjectorError: StaticInjectorError(AppModule)[Device]:
StaticInjectorError(Platform: core)[Device]:
NullInjectorError: No provider for Device!

Problem

What is expected to happen?

What does actually happen?

Information

Command or Code

Environment, Platform, Device

running with:
ionic cordova run browser -l

Version information

ionic info:
Ionic:

Ionic CLI : 6.11.6 (C:\Program Files\nodejs\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 5.1.1
@angular-devkit/build-angular : 0.901.6
@angular-devkit/schematics : 9.1.6
@angular/cli : 9.1.6
@ionic/angular-toolkit : 2.2.0

Capacitor:

Capacitor CLI : 2.1.0
@capacitor/core : 2.1.0

Cordova:

Cordova CLI : 10.0.0
Cordova Platforms : 6.0.0, android 8.1.0, browser
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 11 other plugins)

Utility:

cordova-res : not installed
native-run : 1.0.0

System:

Android SDK Tools : 26.1.1 (C:\android-sdk)
NodeJS : v12.18.2 (C:\Program Files\nodejs\node.exe)
npm : 6.14.5
OS : Windows 7

version of this plugin: @ionic-native/[email protected]

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

IsVirlual returns 'true' in real device

Bug Report

Problem

IsVirlual returns 'true' in a real device

  • Phone: Huawei P20 Pro
  • model: CLT-L29

What is expected to happen?

expected to return false

What does actually happens?

it returns true

Information

  • phone: Huawei P20 Pro
  • model: CLT-L29
  • Ionic 3
  • plugin version: 2.0.3

Command or Code

device.isVirtual

Environment, Platform, Device

  • Phone: Huawei P20 Pro
  • model: CLT-L29
  • Platform: Android

Version information

  • Ionic 3
  • plugin version: 2.0.3
  • Android Version: 8.1

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to the most recent version
  • I included all the necessary information above

SERIAL is unknown

Hello

I am using this plugin in Ionic 3 Project for Android Platform. Reading device IMEI and hardware serial number is our requirement. But not able to read hardware serial number with this plugin. Getting the value 'unknown'. Please help.

In android 9.0 Device serial is unknown

Bug Report

In android 9.0 Device serial is unknown

Problem

when we set target android version="28" or above got the device. serial is "unknown"

What is expected to happen?

Get device serial in android 9.0

What does actually happen?

Currently, there have no Properties get devices serial with this permission "android.permission.READ_PHONE_STATE"

Information

I am adding this permission for device.serial in androidManifest.xml

enable this permission by this plugin
https://www.npmjs.com/package/cordova-plugin-sim
but this plugin has only sim info
how can I get the device.serial with this permission "android.permission.READ_PHONE_STATE"

Command or Code

Environment, Platform, Device

Cordova experience in android version 9.0

Version information

android pie (9.0)

Feature request: get original user agent.

The browser user agent has a lot of information. If it was overriden by OverrideUserAgent cordova preference then there is no way to get the original user agent from javascript. It would be nice if this plugin would also have a property for the original user agent.

ios possible implementation

https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/Public/CDVUserAgentUtil.m#L37

android possible implementation

String userAgent = System.getProperty( "http.agent" );

https://stackoverflow.com/questions/4103963/is-there-a-way-to-obtain-the-default-user-agent-string-aside-from-webview-getset/10248817#10248817

iOS - Privacy Manifest

Feature Request

Motivation Behind Feature

On May 1st, Apple will require privacy manifests in all new app store submissions (source).

Feature Description

It appears Cordova has not yet officially added a way for plugins to handle this (source), but the latest cordova-ios release does provide support for an app-level privacy manifest (source).

For the time being, it would be helpful if this plugin could provide a privacy manifest file that consumers could manually cobble together for now, adding full support in the future when Cordova provides a way to do so.

For this plugin, we need two things in the privacy manifest:

  1. API usage
  2. NSPrivacyCollectedDataTypeDeviceID in the NSPrivacyCollectedDataTypes array (source).

Alternatives or Workarounds

I can reasonably determine what needs to be included in the privacy manifest so that others can follow suit and manually add these entries to their manifest.

  1. for API usage:

Grepping the plugin's iOS source files

grep -r -E 'NSURLVolumeAvailableCapacityKey|NSURLVolumeAvailableCapacityForImportantUsageKey|NSURLVolumeAvailableCapacityForOpportunisticUsageKey|NSURLVolumeTotalCapacityKey|NSFileSystemFreeSize|NSFileSystemSize|statfs|statvfs|fstatfs|fstatvfs|getattrlist|fgetattrlist|getattrlistat|activeInputModes|NSUserDefaults'

Yields:

./CDVDevice.m:    NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];

Which is found in the uniqueAppInstanceIdentifier method which is called in deviceProperties which is used in getDeviceInfo.

The usage would seem to possibly fall under two categories:

CA92.1

    Declare this reason to access user defaults to read and write information that is only accessible to the app itself.

    This reason does not permit reading information that was written by other apps or the system, or writing information that can be accessed by other apps.
  1. For NSPrivacyCollectedDataTypeDeviceID consumers of this plugin are probably going to need to provide this themselves. To that end, it may be useful to add an argument to getDeviceInfo so that uuid can be excluded. That way plugin consumers who do not wish to include NSPrivacyCollectedDataTypeDeviceID in their privacy manifest do not need to.

device.serial returns wrong data in samsung devices

Issue Type

  • Bug Report
  • Feature Request
  • Support Question

Description

I have added device plugin. Now i have added alert in device.serial. Now the original device serial and the alert information both are different. i don't know why but it's strange.

Information

I have added the device plugin for getting device serial. Now i have added alert in constructor of page but it's giving different serial then the original phone serial. Please help me.

Command or Code

alert("Serial number : "+this.device.serial)

Environment, Platform, Device

Platform : android
Device : samsung galaxt j4+ and samsung galaxy S9+

Version information

Operating System:
samsung galaxy j4+ : 8.1.0 (Oreo)

cli packages:
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:
cordova (Cordova CLI) : 8.0.0

local packages:
@ionic/app-scripts : 3.2.1
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2

System:
Android SDK Tools : 26.1.1
Node : v8.11.3
npm : 3.10.10
OS : Windows 8.1

Checklist

  • I searched for already existing GitHub issues about this
  • I updated all Cordova tooling to their most recent version
  • I included all the necessary information above

NullInjectorError: No provider for Device

Bug Report

Problem

What is expected to happen?

There is an error ,NullInjectorError: No provider for Device

What does actually happen?

It can not be used.

Information

core.js:4197 ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(Tab1PageModule)[Device -> Device -> Device -> Device -> Device]:
NullInjectorError: No provider for Device!
NullInjectorError: R3InjectorError(Tab1PageModule)[Device -> Device -> Device -> Device -> Device]:
NullInjectorError: No provider for Device!
at NullInjector.get (core.js:915)
at R3Injector.get (core.js:11082)
at R3Injector.get (core.js:11082)
at R3Injector.get (core.js:11082)
at NgModuleRef$1.get (core.js:24199)
at R3Injector.get (core.js:11082)
at NgModuleRef$1.get (core.js:24199)
at R3Injector.get (core.js:11082)
at NgModuleRef$1.get (core.js:24199)
at Object.get (core.js:22102)
at resolvePromise (zone-evergreen.js:798)
at resolvePromise (zone-evergreen.js:750)
at zone-evergreen.js:860
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:27425)
at ZoneDelegate.invokeTask (zone-evergreen.js:398)
at Zone.runTask (zone-evergreen.js:167)
at drainMicroTaskQueue (zone-evergreen.js:569)
defaultErrorLogger @ core.js:4197
handleError @ core.js:4245
next @ core.js:27988
schedulerFn @ core.js:24801
__tryOrUnsub @ Subscriber.js:183
next @ Subscriber.js:122
_next @ Subscriber.js:72
next @ Subscriber.js:49
next @ Subject.js:39
emit @ core.js:24791
(anonymous) @ core.js:27460
invoke @ zone-evergreen.js:364
run @ zone-evergreen.js:123
runOutsideAngular @ core.js:27364
onHandleError @ core.js:27460
handleError @ zone-evergreen.js:368
runGuarded @ zone-evergreen.js:136
api.microtaskDrainDone @ zone-evergreen.js:670
drainMicroTaskQueue @ zone-evergreen.js:576
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:552
scheduleTask @ zone-evergreen.js:388
onScheduleTask @ zone-evergreen.js:272
scheduleTask @ zone-evergreen.js:378
scheduleTask @ zone-evergreen.js:210
scheduleMicroTask @ zone-evergreen.js:230
scheduleResolveOrReject @ zone-evergreen.js:847
resolvePromise @ zone-evergreen.js:785
(anonymous) @ zone-evergreen.js:705
webpackJsonpCallback @ bootstrap:25
(anonymous) @ defaultdetail-detail-moduletab1-tab1-module.js:1

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Option to opt out from storing uuid in iCloud / backup

Feature Request

Motivation Behind Feature

One use case for uuid is to tell devices apart when a user sign in to different devices. However according to the docs there is an iOS quirk that it will persist the uuid from the first device that the user uses and it will carry over via backup / iCloud to new devices.

Feature Description

I would like to be able to opt out from storing uuid and instead have it resolved from iOS / Android each time I call the plugin so that the uuid is not carried over from a backup or iCloud restore.

Alternatives or Workarounds

Use/write a different plugin than cordova-plugin-device that doesn't persist identifierForVendor.

deviceready not fired with angular 9

Bug Report

Problem

What is expected to happen?

when document.addEventListener("deviceready", onDeviceReady, false); is registered the success-method (onDeviceReady) should be called.

What does actually happen?

Sucess method never gets called. Also console-log "deviceready has not fired after 5 seconds." is printed.

Information

No code changes done with update angular 8 to angular 9. Cordova platform "android" has been removed and added again but without luck.

Environment, Platform, Device

Samsung Galaxy S7, Android 9
cordova-plugin-device: 2.0.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.