new cordova plugins
This commit is contained in:
37
cordova/plugins/cordova-plugin-device/CONTRIBUTING.md
Normal file
37
cordova/plugins/cordova-plugin-device/CONTRIBUTING.md
Normal file
@@ -0,0 +1,37 @@
|
||||
<!--
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
-->
|
||||
|
||||
# Contributing to Apache Cordova
|
||||
|
||||
Anyone can contribute to Cordova. And we need your contributions.
|
||||
|
||||
There are multiple ways to contribute: report bugs, improve the docs, and
|
||||
contribute code.
|
||||
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/contribute/).
|
||||
|
||||
The details are explained there, but the important items are:
|
||||
- Sign and submit an Apache ICLA (Contributor License Agreement).
|
||||
- Have a Jira issue open that corresponds to your contribution.
|
||||
- Run the tests so your patch doesn't break existing functionality.
|
||||
|
||||
We look forward to your contributions!
|
202
cordova/plugins/cordova-plugin-device/LICENSE
Normal file
202
cordova/plugins/cordova-plugin-device/LICENSE
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
5
cordova/plugins/cordova-plugin-device/NOTICE
Normal file
5
cordova/plugins/cordova-plugin-device/NOTICE
Normal file
@@ -0,0 +1,5 @@
|
||||
Apache Cordova
|
||||
Copyright 2012 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
244
cordova/plugins/cordova-plugin-device/README.md
Normal file
244
cordova/plugins/cordova-plugin-device/README.md
Normal file
@@ -0,0 +1,244 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
## Properties
|
||||
|
||||
- device.cordova
|
||||
- device.model
|
||||
- device.platform
|
||||
- device.uuid
|
||||
- device.version
|
||||
- device.isVirtual
|
||||
- device.serial
|
||||
|
||||
## device.cordova
|
||||
|
||||
Get the version of Cordova running on the device.
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- Browser
|
||||
- Firefox OS
|
||||
- iOS
|
||||
- Tizen
|
||||
- Windows Phone 7 and 8
|
||||
- Windows 8
|
||||
|
||||
## 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
|
||||
- BlackBerry 10
|
||||
- Browser
|
||||
- iOS
|
||||
- Tizen
|
||||
- Windows Phone 7 and 8
|
||||
- Windows 8
|
||||
|
||||
### Quick Example
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
### Android Quirks
|
||||
|
||||
- Gets the [product name](http://developer.android.com/reference/android/os/Build.html#PRODUCT) instead of the [model name](http://developer.android.com/reference/android/os/Build.html#MODEL), which is often the production code name. For example, the Nexus One returns `Passion`, and Motorola Droid returns `voles`.
|
||||
|
||||
### Tizen Quirks
|
||||
|
||||
- Returns the device model assigned by the vendor, for example, `TIZEN`
|
||||
|
||||
### Windows Phone 7 and 8 Quirks
|
||||
|
||||
- Returns the device model specified by the manufacturer. For example, the Samsung Focus returns `SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Get the device's operating system name.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- Browser
|
||||
- Firefox OS
|
||||
- iOS
|
||||
- Tizen
|
||||
- Windows Phone 7 and 8
|
||||
- Windows 8
|
||||
|
||||
### Quick Example
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
### Windows Phone 7 Quirks
|
||||
|
||||
Windows Phone 7 devices report the platform as `WinCE`.
|
||||
|
||||
### Windows Phone 8 Quirks
|
||||
|
||||
Windows Phone 8 devices report the platform as `Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Get the device's Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
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
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
- Tizen
|
||||
- Windows Phone 7 and 8
|
||||
- Windows 8
|
||||
|
||||
### Quick Example
|
||||
|
||||
// Android: Returns a random 64-bit integer (as a string, again!)
|
||||
// The integer is generated on the device's first boot
|
||||
//
|
||||
// BlackBerry: Returns the PIN number of the device
|
||||
// This is a nine-digit unique integer (as a string, though!)
|
||||
//
|
||||
// iPhone: (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. Please see https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor
|
||||
// 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
|
||||
// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
|
||||
// unique to every GSM and UMTS mobile phone.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
### 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.
|
||||
See https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor
|
||||
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.
|
||||
|
||||
### Windows Phone 7 and 8 Quirks
|
||||
|
||||
The `uuid` for Windows Phone 7 requires the permission
|
||||
`ID_CAP_IDENTITY_DEVICE`. Microsoft will likely deprecate this
|
||||
property soon. If the capability is not available, the application
|
||||
generates a persistent guid that is maintained for the duration of the
|
||||
application's installation on the device.
|
||||
|
||||
## device.version
|
||||
|
||||
Get the operating system version.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android 2.1+
|
||||
- BlackBerry 10
|
||||
- Browser
|
||||
- iOS
|
||||
- Tizen
|
||||
- Windows Phone 7 and 8
|
||||
- Windows 8
|
||||
|
||||
### 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
|
||||
## device.isVirtual
|
||||
|
||||
whether the device is running on a simulator.
|
||||
|
||||
var isSim = device.isVirtual;
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android 2.1+
|
||||
- iOS
|
||||
- Windows Phone 8
|
||||
- Windows 8
|
||||
|
||||
|
||||
## device.serial
|
||||
|
||||
Get the device hardware serial number ([SERIAL](http://developer.android.com/reference/android/os/Build.html#SERIAL)).
|
||||
|
||||
var string = device.serial;
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
|
130
cordova/plugins/cordova-plugin-device/RELEASENOTES.md
Normal file
130
cordova/plugins/cordova-plugin-device/RELEASENOTES.md
Normal file
@@ -0,0 +1,130 @@
|
||||
<!--
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 1.1.0 (Nov 18, 2015)
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
||||
* Add `isVirtual` for **Windows Phone 8.x**
|
||||
* Added basic **Android** support for hardware serial number
|
||||
* [CB-9865](https://issues.apache.org/jira/browse/CB-9865) Better simulator detection for **iOS**
|
||||
* Fixing contribute link.
|
||||
* Added **WP8** implementation
|
||||
* update to use `TARGET_OS_SIMULATOR` as `TARGET_IPHONE_SIMULATOR` is deprecated.
|
||||
* update code to use 'isVirtual'
|
||||
* create test to verify existence and type of new property 'isVirtual'
|
||||
* add `isSimulator` for **iOS** & **Android** device
|
||||
* Updated documentation to mention backwards compatibility
|
||||
* Updated **README** to reflect new behaviour and quirks on **iOS**
|
||||
* Check user defaults first to maintain backwards compatibility
|
||||
* Changed `UUID` to use `[UIDevice identifierForVendor]`
|
||||
|
||||
### 1.0.1 (Jun 17, 2015)
|
||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-device documentation translation: cordova-plugin-device
|
||||
* Attempts to corrent npm markdown issue
|
||||
|
||||
### 1.0.0 (Apr 15, 2015)
|
||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
|
||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
|
||||
* remove defunct windows8 version
|
||||
* add travis badge
|
||||
* Add cross-plugin ios paramedic test running for TravisCI
|
||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
||||
|
||||
### 0.3.0 (Feb 04, 2015)
|
||||
* Added device.manufacturer property for Android, iOS, Blackberry, WP8
|
||||
* Support for Windows Phone 8 ANID2 ANID is only supported up to Windows Phone 7.5
|
||||
* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) Use a local copy of uniqueAppInstanceIdentifier rather than CordovaLib's version
|
||||
* browser: Fixed a bug that caused an "cannot call method of undefined" error if the browser's user agent wasn't recognized
|
||||
|
||||
### 0.2.13 (Dec 02, 2014)
|
||||
* Changing `device.platform` to always report the platform as "browser".
|
||||
* [CB-5892](https://issues.apache.org/jira/browse/CB-5892) - Remove deprecated `window.Settings`
|
||||
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-device documentation translation: cordova-plugin-device
|
||||
* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin
|
||||
|
||||
### 0.2.12 (Sep 17, 2014)
|
||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-device documentation translation
|
||||
* [CB-7552](https://issues.apache.org/jira/browse/CB-7552) device.name docs have not been removed
|
||||
* [fxos] Fix cordova version
|
||||
* added status box and documentation to manual tests
|
||||
* [fxos] Fix cordova version
|
||||
* added status box and documentation to manual tests
|
||||
* Added plugin support for the browser
|
||||
* [CB-7262](https://issues.apache.org/jira/browse/CB-7262) Adds support for universal windows apps.
|
||||
|
||||
### 0.2.11 (Aug 06, 2014)
|
||||
* [FFOS] update DeviceProxy.js
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
|
||||
* Use Windows system calls to get better info
|
||||
|
||||
### 0.2.10 (Jun 05, 2014)
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #12
|
||||
* Changing 1.5 to 2.0
|
||||
* added firefoxos version - conversion
|
||||
* added firefoxos version
|
||||
* [CB-6800](https://issues.apache.org/jira/browse/CB-6800) Add license
|
||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
||||
|
||||
### 0.2.9 (Apr 17, 2014)
|
||||
* [CB-5105](https://issues.apache.org/jira/browse/CB-5105): [Android, windows8, WP, BlackBerry10] Removed dead code for device.version
|
||||
* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy
|
||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
|
||||
* Add NOTICE file
|
||||
|
||||
### 0.2.8 (Feb 05, 2014)
|
||||
* Tizen support added
|
||||
|
||||
### 0.2.7 (Jan 07, 2014)
|
||||
* [CB-5737](https://issues.apache.org/jira/browse/CB-5737) Fix exception on close caused by left over telephony code from [CB-5504](https://issues.apache.org/jira/browse/CB-5504)
|
||||
|
||||
### 0.2.6 (Jan 02, 2014)
|
||||
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Device plugin
|
||||
* [CB-5504](https://issues.apache.org/jira/browse/CB-5504) Moving Telephony Logic out of Device
|
||||
|
||||
### 0.2.5 (Dec 4, 2013)
|
||||
* [CB-5316](https://issues.apache.org/jira/browse/CB-5316) Spell Cordova as a brand unless it's a command or script
|
||||
* [ubuntu] use cordova/exec/proxy
|
||||
* add ubuntu platform
|
||||
* Modify Device.platform logic to use amazon-fireos as the platform for Amazon Devices
|
||||
* 1. Added amazon-fireos platform. 2. Change to use cordova-amazon-fireos as the platform if user agent contains 'cordova-amazon-fireos'
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag in plugin.xml for device plugin
|
||||
* [CB-5085](https://issues.apache.org/jira/browse/CB-5085) device.cordova returning wrong value
|
||||
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.3 (Sept 25, 2013)
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
|
||||
* [windows8] commandProxy has moved
|
||||
* [BlackBerry10] removed uneeded permission tags in plugin.xml
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.device to org.apache.cordova.device
|
||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
||||
* updated to use commandProxy for ffos
|
||||
* add firefoxos support
|
||||
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.1 (Sept 5, 2013)
|
||||
* removed extraneous print statement
|
||||
* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change
|
203
cordova/plugins/cordova-plugin-device/doc/de/README.md
Normal file
203
cordova/plugins/cordova-plugin-device/doc/de/README.md
Normal file
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Dieses Plugin definiert eine globale `device` -Objekt, das des Geräts Hard- und Software beschreibt. Das Objekt im globalen Gültigkeitsbereich ist es zwar nicht verfügbar bis nach dem `deviceready` Ereignis.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Eigenschaften
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Rufen Sie die Version von Cordova, die auf dem Gerät ausgeführt.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Die `device.model` gibt den Namen der Modell- oder des Geräts zurück. Der Wert wird vom Gerätehersteller festgelegt und kann zwischen den Versionen des gleichen Produkts unterschiedlich sein.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Finden Sie unter http://theiphonewiki.com/wiki/index.php?title=Models / / Var-Modell = device.model;
|
||||
|
||||
|
||||
### Android Eigenarten
|
||||
|
||||
* Ruft den [Produktname](http://developer.android.com/reference/android/os/Build.html#PRODUCT) anstelle des [Modellnamens](http://developer.android.com/reference/android/os/Build.html#MODEL), das ist oft der Codename für die Produktion. Beispielsweise das Nexus One gibt `Passion` , und Motorola Droid gibt`voles`.
|
||||
|
||||
### Tizen Macken
|
||||
|
||||
* Gibt z. B. das Gerätemodell von dem Kreditor zugeordnet,`TIZEN`
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
* Gibt das vom Hersteller angegebenen Gerätemodell zurück. Beispielsweise gibt der Samsung-Fokus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Name des Betriebssystems des Geräts zu erhalten.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Macken
|
||||
|
||||
Windows Phone 7 Geräte melden die Plattform als`WinCE`.
|
||||
|
||||
### Windows Phone 8 Macken
|
||||
|
||||
Windows Phone 8 Geräte melden die Plattform als`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Des Geräts Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier) zu erhalten).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Beschreibung
|
||||
|
||||
Die Details wie eine UUID generiert wird werden vom Gerätehersteller und beziehen sich auf die Plattform oder das Modell des Geräts.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
/ / Android: wird eine zufällige 64-Bit-Ganzzahl (als Zeichenfolge, wieder!) / / die ganze Zahl wird beim ersten Start des Geräts erzeugt / / / / BlackBerry: gibt die PIN-Nummer des Gerätes / / Dies ist eine neunstellige eindeutige Ganzzahl (als String, obwohl!) / / / / iPhone: (paraphrasiert aus der Dokumentation zur UIDevice-Klasse) / / liefert eine Reihe von Hash-Werte, die aus mehreren Hardware erstellt identifiziert.
|
||||
/ / Es ist gewährleistet, dass für jedes Gerät eindeutig sein und kann nicht gebunden werden / / an den Benutzer weitergeleitet.
|
||||
/ / Windows Phone 7: gibt einen Hash des Gerät + aktueller Benutzer, / / wenn der Benutzer nicht definiert ist, eine Guid generiert und wird weiter bestehen, bis die app deinstalliert wird / / Tizen: gibt das Gerät IMEI (International Mobile Equipment Identity oder IMEI ist eine Zahl / / einzigartig für jedes GSM- und UMTS-Handy.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Die `uuid` auf iOS ist nicht eindeutig zu einem Gerät, aber für jede Anwendung, für jede Installation variiert. Es ändert sich, wenn Sie löschen und neu die app installieren, und möglicherweise auch beim iOS zu aktualisieren, oder auch ein Upgrade möglich die app pro Version (scheinbaren in iOS 5.1). Die `uuid` ist kein zuverlässiger Wert.
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
Die `uuid` für Windows Phone 7 die Berechtigung erfordert `ID_CAP_IDENTITY_DEVICE` . Microsoft wird diese Eigenschaft wahrscheinlich bald abzuschaffen. Wenn die Funktion nicht verfügbar ist, generiert die Anwendung eine persistente Guid, die für die Dauer der Installation der Anwendung auf dem Gerät gewährleistet ist.
|
||||
|
||||
## device.version
|
||||
|
||||
Version des Betriebssystems zu erhalten.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
206
cordova/plugins/cordova-plugin-device/doc/de/index.md
Normal file
206
cordova/plugins/cordova-plugin-device/doc/de/index.md
Normal file
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Dieses Plugin definiert eine globale `device` -Objekt, das des Geräts Hard- und Software beschreibt. Das Objekt im globalen Gültigkeitsbereich ist es zwar nicht verfügbar bis nach dem `deviceready` Ereignis.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Eigenschaften
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Rufen Sie die Version von Cordova, die auf dem Gerät ausgeführt.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Die `device.model` gibt den Namen der Modell- oder des Geräts zurück. Der Wert wird vom Gerätehersteller festgelegt und kann zwischen den Versionen des gleichen Produkts unterschiedlich sein.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Finden Sie unter http://theiphonewiki.com/wiki/index.php?title=Models / / Var-Modell = device.model;
|
||||
|
||||
|
||||
### Android Eigenarten
|
||||
|
||||
* Ruft den [Produktname][1] anstelle des [Modellnamens][2], das ist oft der Codename für die Produktion. Beispielsweise das Nexus One gibt `Passion` , und Motorola Droid gibt`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Tizen Macken
|
||||
|
||||
* Gibt z. B. das Gerätemodell von dem Kreditor zugeordnet,`TIZEN`
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
* Gibt das vom Hersteller angegebenen Gerätemodell zurück. Beispielsweise gibt der Samsung-Fokus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Name des Betriebssystems des Geräts zu erhalten.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Macken
|
||||
|
||||
Windows Phone 7 Geräte melden die Plattform als`WinCE`.
|
||||
|
||||
### Windows Phone 8 Macken
|
||||
|
||||
Windows Phone 8 Geräte melden die Plattform als`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Des Geräts Universally Unique Identifier ([UUID][3] zu erhalten).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Beschreibung
|
||||
|
||||
Die Details wie eine UUID generiert wird werden vom Gerätehersteller und beziehen sich auf die Plattform oder das Modell des Geräts.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
/ / Android: wird eine zufällige 64-Bit-Ganzzahl (als Zeichenfolge, wieder!) / / die ganze Zahl wird beim ersten Start des Geräts erzeugt / / / / BlackBerry: gibt die PIN-Nummer des Gerätes / / Dies ist eine neunstellige eindeutige Ganzzahl (als String, obwohl!) / / / / iPhone: (paraphrasiert aus der Dokumentation zur UIDevice-Klasse) / / liefert eine Reihe von Hash-Werte, die aus mehreren Hardware erstellt identifiziert.
|
||||
/ / Es ist gewährleistet, dass für jedes Gerät eindeutig sein und kann nicht gebunden werden / / an den Benutzer weitergeleitet.
|
||||
/ / Windows Phone 7: gibt einen Hash des Gerät + aktueller Benutzer, / / wenn der Benutzer nicht definiert ist, eine Guid generiert und wird weiter bestehen, bis die app deinstalliert wird / / Tizen: gibt das Gerät IMEI (International Mobile Equipment Identity oder IMEI ist eine Zahl / / einzigartig für jedes GSM- und UMTS-Handy.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Die `uuid` auf iOS ist nicht eindeutig zu einem Gerät, aber für jede Anwendung, für jede Installation variiert. Es ändert sich, wenn Sie löschen und neu die app installieren, und möglicherweise auch beim iOS zu aktualisieren, oder auch ein Upgrade möglich die app pro Version (scheinbaren in iOS 5.1). Die `uuid` ist kein zuverlässiger Wert.
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
Die `uuid` für Windows Phone 7 die Berechtigung erfordert `ID_CAP_IDENTITY_DEVICE` . Microsoft wird diese Eigenschaft wahrscheinlich bald abzuschaffen. Wenn die Funktion nicht verfügbar ist, generiert die Anwendung eine persistente Guid, die für die Dauer der Installation der Anwendung auf dem Gerät gewährleistet ist.
|
||||
|
||||
## device.version
|
||||
|
||||
Version des Betriebssystems zu erhalten.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
216
cordova/plugins/cordova-plugin-device/doc/es/README.md
Normal file
216
cordova/plugins/cordova-plugin-device/doc/es/README.md
Normal file
@@ -0,0 +1,216 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Este plugin define un global `device` objeto que describe del dispositivo hardware y software. Aunque el objeto está en el ámbito global, no está disponible hasta después de la `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalación
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propiedades
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Obtener la versión de Cordova que se ejecuta en el dispositivo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Amazon fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
El `device.model` devuelve el nombre de modelo del dispositivo o producto. El valor es fijado por el fabricante del dispositivo y puede ser diferente a través de versiones del mismo producto.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Rarezas Android
|
||||
|
||||
* Obtiene el [nombre del producto](http://developer.android.com/reference/android/os/Build.html#PRODUCT) en lugar del [nombre de la modelo](http://developer.android.com/reference/android/os/Build.html#MODEL), que es a menudo el nombre de código de producción. Por ejemplo, el Nexus One devuelve `Passion` y Motorola Droid devuelve `voles`.
|
||||
|
||||
### Rarezas Tizen
|
||||
|
||||
* Devuelve que el modelo de dispositivo asignado por el proveedor, por ejemplo, `TIZEN`
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
* Devuelve el modelo de dispositivo especificado por el fabricante. Por ejemplo, el Samsung Focus devuelve `SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtener el nombre del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 rarezas
|
||||
|
||||
Dispositivos Windows Phone 7 informe de la plataforma como `WinCE`.
|
||||
|
||||
### Windows Phone 8 rarezas
|
||||
|
||||
Dispositivos Windows Phone 8 Informe la plataforma como `Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtener identificador universalmente única del dispositivo ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descripción
|
||||
|
||||
Los detalles de cómo se genera un UUID son determinados por el fabricante del dispositivo y son específicos a la plataforma del dispositivo o modelo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Returns a random 64-bit integer (as a string, again!)
|
||||
// The integer is generated on the device's first boot
|
||||
//
|
||||
// BlackBerry: Returns the PIN number of the device
|
||||
// This is a nine-digit unique integer (as a string, though!)
|
||||
//
|
||||
// iPhone: (Paraphrased from the UIDevice Class documentation)
|
||||
// Returns a string of hash values created from multiple hardware identifies.
|
||||
// It is guaranteed to be unique for every device and can't be tied
|
||||
// to the user account.
|
||||
// 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
|
||||
// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
|
||||
// unique to every GSM and UMTS mobile phone.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Rarezas de iOS
|
||||
|
||||
El `uuid` en iOS no es exclusiva de un dispositivo, pero varía para cada aplicación, para cada instalación. Cambia si puedes borrar y volver a instalar la aplicación, y posiblemente también cuándo actualizar iOS, o incluso mejorar la aplicación por la versión (evidente en iOS 5.1). El `uuid` no es un valor confiable.
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
El `uuid` para Windows Phone 7 requiere el permiso `ID_CAP_IDENTITY_DEVICE`. Microsoft pronto probablemente desaprueban esta propiedad. Si la capacidad no está disponible, la aplicación genera un guid persistente que se mantiene durante la duración de la instalación de la aplicación en el dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Obtener la versión del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
220
cordova/plugins/cordova-plugin-device/doc/es/index.md
Normal file
220
cordova/plugins/cordova-plugin-device/doc/es/index.md
Normal file
@@ -0,0 +1,220 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Este plugin define un global `device` objeto que describe del dispositivo hardware y software. Aunque el objeto está en el ámbito global, no está disponible hasta después de la `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalación
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propiedades
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Obtener la versión de Cordova que se ejecuta en el dispositivo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Amazon fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
El `device.model` devuelve el nombre de modelo del dispositivo o producto. El valor es fijado por el fabricante del dispositivo y puede ser diferente a través de versiones del mismo producto.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Rarezas Android
|
||||
|
||||
* Obtiene el [nombre del producto][1] en lugar del [nombre de la modelo][2], que es a menudo el nombre de código de producción. Por ejemplo, el Nexus One devuelve `Passion` y Motorola Droid devuelve `voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Rarezas Tizen
|
||||
|
||||
* Devuelve que el modelo de dispositivo asignado por el proveedor, por ejemplo, `TIZEN`
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
* Devuelve el modelo de dispositivo especificado por el fabricante. Por ejemplo, el Samsung Focus devuelve `SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtener el nombre del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 rarezas
|
||||
|
||||
Dispositivos Windows Phone 7 informe de la plataforma como `WinCE`.
|
||||
|
||||
### Windows Phone 8 rarezas
|
||||
|
||||
Dispositivos Windows Phone 8 Informe la plataforma como `Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtener identificador universalmente única del dispositivo ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descripción
|
||||
|
||||
Los detalles de cómo se genera un UUID son determinados por el fabricante del dispositivo y son específicos a la plataforma del dispositivo o modelo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: devuelve un entero de 64 bits al azar (como una cadena, otra vez!)
|
||||
// el entero es generado en el primer arranque del dispositivo
|
||||
//
|
||||
// BlackBerry: devuelve el número PIN del dispositivo
|
||||
// este es un entero único de nueve dígitos (como una cadena, aunque!)
|
||||
//
|
||||
// iPhone: (parafraseado de la documentación de la clase UIDevice)
|
||||
// devuelve una cadena de valores hash creado a partir
|
||||
// de múltiples hardware identifica.
|
||||
/ / Está garantizado para ser único para cada dispositivo y no puede ser atado / / a la cuenta de usuario.
|
||||
// Windows Phone 7: devuelve un hash de dispositivo + usuario actual,
|
||||
// si el usuario no está definido, un guid generado y persistirá hasta que se desinstala la aplicación
|
||||
//
|
||||
// Tizen: devuelve el dispositivo IMEI (identidad de equipo móvil internacional o IMEI es un número
|
||||
// único para cada teléfono móvil GSM y UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS chanfle
|
||||
|
||||
El `uuid` en iOS no es exclusiva de un dispositivo, pero varía para cada aplicación, para cada instalación. Cambia si puedes borrar y volver a instalar la aplicación, y posiblemente también cuándo actualizar iOS, o incluso mejorar la aplicación por la versión (evidente en iOS 5.1). El `uuid` no es un valor confiable.
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
El `uuid` para Windows Phone 7 requiere el permiso `ID_CAP_IDENTITY_DEVICE`. Microsoft pronto probablemente desaprueban esta propiedad. Si la capacidad no está disponible, la aplicación genera un guid persistente que se mantiene durante la duración de la instalación de la aplicación en el dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Obtener la versión del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. el Mango se vuelve 7.10.7720
|
||||
// Tizen: devuelve "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
215
cordova/plugins/cordova-plugin-device/doc/fr/README.md
Normal file
215
cordova/plugins/cordova-plugin-device/doc/fr/README.md
Normal file
@@ -0,0 +1,215 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Ce plugin définit un global `device` objet qui décrit le matériel et les logiciels de l'appareil. Bien que l'objet est dans la portée globale, il n'est pas disponible jusqu'après la `deviceready` événement.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propriétés
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Retourne la version de Cordova en cours d'exécution sur l'appareil.
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
L'objet `device.model` retourne le nom du modèle de l'appareil/produit. Cette valeur est définie par le fabricant du périphérique et peut varier entre les différentes versions d'un même produit.
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Voir http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Quirks Android
|
||||
|
||||
* Retourne le [nom du produit](http://developer.android.com/reference/android/os/Build.html#PRODUCT) au lieu du [nom du modèle](http://developer.android.com/reference/android/os/Build.html#MODEL), ce qui équivaut souvent au nom de code de production. Par exemple, `Passion` pour le Nexus One et `voles` pour le Motorola Droid.
|
||||
|
||||
### Bizarreries de paciarelli
|
||||
|
||||
* Retourne le modèle du dispositif, assigné par le vendeur, par exemple `TIZEN`
|
||||
|
||||
### Notes au sujet de Windows Phone 7 et 8
|
||||
|
||||
* Retourne le modèle de l'appareil spécifié par le fabricant. Par exemple `SGH-i917` pour le Samsung Focus.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtenir le nom de système d'exploitation de l'appareil.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Quirks
|
||||
|
||||
Appareils Windows Phone 7 rapport de la plate-forme comme`WinCE`.
|
||||
|
||||
### Notes au sujet de Windows Phone 8
|
||||
|
||||
Appareils Windows Phone 8 rapport de la plate-forme comme`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtenir Universally Unique Identifier de l'appareil ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
Les détails de comment un UUID généré sont déterminées par le fabricant du périphérique et sont spécifiques à la plate-forme ou le modèle de l'appareil.
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// Android : retourne un nombre entier 64-bit aléatoire (sous la forme d'une chaîne de caractères, encore !)
|
||||
// Ce nombre entier est généré lors du premier démarrage de l'appareil
|
||||
//
|
||||
// BlackBerry : retourne le numéro PIN de l'appareil
|
||||
// Il s'agit d'un nombre entier unique à neuf chiffres (sous la forme d'une chaîne de caractères cependant !)
|
||||
//
|
||||
// iPhone : (copié depuis la documentation de la classe UIDevice)
|
||||
// Retourne une chaîne de caractères générée à partir de plusieurs caractéristiques matérielles.
|
||||
/ / Il est garanti pour être unique pour chaque appareil et ne peut pas être lié / / pour le compte d'utilisateur.
|
||||
// Windows Phone 7 : retourne un hashage généré à partir de appareil+utilisateur actuel,
|
||||
// si aucun utilisateur n'est défini, un guid est généré persistera jusqu'à ce que l'application soit désinstallée
|
||||
// Tizen : retourne le numéro IMEI (International Mobile Equipment Identity) de l'appareil, ce numéro est
|
||||
// unique pour chaque téléphone GSM et UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Spécificités iOS
|
||||
|
||||
Le `uuid` sur iOS n'est pas propre à un périphérique, mais varie pour chaque application, pour chaque installation. Elle change si vous supprimez, puis réinstallez l'application, et éventuellement aussi quand vous mettre à jour d'iOS, ou même mettre à jour le soft par version (apparent dans iOS 5.1). Le `uuid` n'est pas une valeur fiable.
|
||||
|
||||
### Notes au sujet de Windows Phone 7 et 8
|
||||
|
||||
Le `uuid` pour Windows Phone 7 requiert l'autorisation `ID_CAP_IDENTITY_DEVICE` . Microsoft va probablement bientôt obsolète de cette propriété. Si la capacité n'est pas disponible, l'application génère un guid persistant qui est maintenu pendant toute la durée de l'installation de l'application sur le périphérique.
|
||||
|
||||
## device.version
|
||||
|
||||
Téléchargez la version de système d'exploitation.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android 2.1+
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
218
cordova/plugins/cordova-plugin-device/doc/fr/index.md
Normal file
218
cordova/plugins/cordova-plugin-device/doc/fr/index.md
Normal file
@@ -0,0 +1,218 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Ce plugin définit un global `device` objet qui décrit le matériel et les logiciels de l'appareil. Bien que l'objet est dans la portée globale, il n'est pas disponible jusqu'après la `deviceready` événement.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propriétés
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Retourne la version de Cordova en cours d'exécution sur l'appareil.
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
L'objet `device.model` retourne le nom du modèle de l'appareil/produit. Cette valeur est définie par le fabricant du périphérique et peut varier entre les différentes versions d'un même produit.
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Voir http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Quirks Android
|
||||
|
||||
* Retourne le [nom du produit][1] au lieu du [nom du modèle][2], ce qui équivaut souvent au nom de code de production. Par exemple, `Passion` pour le Nexus One et `voles` pour le Motorola Droid.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Bizarreries de paciarelli
|
||||
|
||||
* Retourne le modèle du dispositif, assigné par le vendeur, par exemple `TIZEN`
|
||||
|
||||
### Windows Phone 7 et 8 Quirks
|
||||
|
||||
* Retourne le modèle de l'appareil spécifié par le fabricant. Par exemple `SGH-i917` pour le Samsung Focus.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtenir le nom de système d'exploitation de l'appareil.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Quirks
|
||||
|
||||
Appareils Windows Phone 7 rapport de la plate-forme comme`WinCE`.
|
||||
|
||||
### Notes au sujet de Windows Phone 8
|
||||
|
||||
Appareils Windows Phone 8 rapport de la plate-forme comme`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtenir Universally Unique Identifier de l'appareil ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
Les détails de comment un UUID généré sont déterminées par le fabricant du périphérique et sont spécifiques à la plate-forme ou le modèle de l'appareil.
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// Android : retourne un nombre entier 64-bit aléatoire (sous la forme d'une chaîne de caractères, encore !)
|
||||
// Ce nombre entier est généré lors du premier démarrage de l'appareil
|
||||
//
|
||||
// BlackBerry : retourne le numéro PIN de l'appareil
|
||||
// Il s'agit d'un nombre entier unique à neuf chiffres (sous la forme d'une chaîne de caractères cependant !)
|
||||
//
|
||||
// iPhone : (copié depuis la documentation de la classe UIDevice)
|
||||
// Retourne une chaîne de caractères générée à partir de plusieurs caractéristiques matérielles.
|
||||
/ / Il est garanti pour être unique pour chaque appareil et ne peut pas être lié / / pour le compte d'utilisateur.
|
||||
// Windows Phone 7 : retourne un hashage généré à partir de appareil+utilisateur actuel,
|
||||
// si aucun utilisateur n'est défini, un guid est généré persistera jusqu'à ce que l'application soit désinstallée
|
||||
// Tizen : retourne le numéro IMEI (International Mobile Equipment Identity) de l'appareil, ce numéro est
|
||||
// unique pour chaque téléphone GSM et UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Spécificités iOS
|
||||
|
||||
Le `uuid` sur iOS n'est pas propre à un périphérique, mais varie pour chaque application, pour chaque installation. Elle change si vous supprimez, puis réinstallez l'application, et éventuellement aussi quand vous mettre à jour d'iOS, ou même mettre à jour le soft par version (apparent dans iOS 5.1). Le `uuid` n'est pas une valeur fiable.
|
||||
|
||||
### Windows Phone 7 et 8 Quirks
|
||||
|
||||
Le `uuid` pour Windows Phone 7 requiert l'autorisation `ID_CAP_IDENTITY_DEVICE` . Microsoft va probablement bientôt obsolète de cette propriété. Si la capacité n'est pas disponible, l'application génère un guid persistant qui est maintenu pendant toute la durée de l'installation de l'application sur le périphérique.
|
||||
|
||||
## device.version
|
||||
|
||||
Téléchargez la version de système d'exploitation.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android 2.1+
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
203
cordova/plugins/cordova-plugin-device/doc/it/README.md
Normal file
203
cordova/plugins/cordova-plugin-device/doc/it/README.md
Normal file
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Questo plugin definisce un global `device` oggetto che descrive il dispositivo hardware e software. Sebbene l'oggetto sia in ambito globale, non è disponibile fino a dopo il `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installazione
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Proprietà
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Ottenere la versione di Cordova in esecuzione nel dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Amazon fuoco OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Il `device.model` restituisce il nome del modello del dispositivo o del prodotto. Il valore viene impostato dal produttore del dispositivo e può essere differente tra le versioni dello stesso prodotto.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Vedi http://theiphonewiki.com/wiki/index.php?title=Models / / modello var = device.model;
|
||||
|
||||
|
||||
### Stranezze Android
|
||||
|
||||
* Ottiene il [nome del prodotto](http://developer.android.com/reference/android/os/Build.html#PRODUCT) anziché il [nome del modello](http://developer.android.com/reference/android/os/Build.html#MODEL), che è spesso il nome di codice di produzione. Ad esempio, restituisce il Nexus One `Passion` , e Motorola Droid restituisce`voles`.
|
||||
|
||||
### Tizen stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo assegnato dal fornitore, ad esempio,`TIZEN`
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo specificato dal produttore. Ad esempio, restituisce il Samsung Focus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Ottenere il nome del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 capricci
|
||||
|
||||
Windows Phone 7 dispositivi segnalano la piattaforma come`WinCE`.
|
||||
|
||||
### Windows Phone 8 stranezze
|
||||
|
||||
Dispositivi Windows Phone 8 segnalano la piattaforma come`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Ottenere identificatore del dispositivo univoco universale ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descrizione
|
||||
|
||||
I dettagli di come viene generato un UUID sono determinati dal produttore del dispositivo e sono specifici per la piattaforma o il modello del dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
/ / Android: restituisce un intero casuale di 64 bit (come stringa, ancora una volta!) / / il numero intero è generato al primo avvio del dispositivo / / / / BlackBerry: restituisce il numero PIN del dispositivo / / questo è un valore integer univoco a nove cifre (come stringa, benchè!) / / / / iPhone: (parafrasato dalla documentazione della classe UIDevice) / / restituisce una stringa di valori hash creata dall'hardware più identifica.
|
||||
/ / È garantito per essere unica per ogni dispositivo e non può essere legato / / per l'account utente.
|
||||
/ / Windows Phone 7: restituisce un hash dell'utente corrente, + dispositivo / / se l'utente non è definito, un guid generato e persisterà fino a quando l'applicazione viene disinstallata / / Tizen: restituisce il dispositivo IMEI (International Mobile Equipment Identity o IMEI è un numero / / unico per ogni cellulare GSM e UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Il `uuid` su iOS non è univoco per un dispositivo, ma varia per ogni applicazione, per ogni installazione. Cambia se si elimina e re-installare l'app, e possibilmente anche quando aggiornare iOS o anche aggiornare l'app per ogni versione (apparente in iOS 5.1). Il `uuid` non è un valore affidabile.
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
Il `uuid` per Windows Phone 7 richiede l'autorizzazione `ID_CAP_IDENTITY_DEVICE` . Microsoft probabilmente sarà presto deprecare questa proprietà. Se la funzionalità non è disponibile, l'applicazione genera un guid persistente che viene mantenuto per la durata dell'installazione dell'applicazione sul dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Ottenere la versione del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
206
cordova/plugins/cordova-plugin-device/doc/it/index.md
Normal file
206
cordova/plugins/cordova-plugin-device/doc/it/index.md
Normal file
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Questo plugin definisce un global `device` oggetto che descrive il dispositivo hardware e software. Sebbene l'oggetto sia in ambito globale, non è disponibile fino a dopo il `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installazione
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Proprietà
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Ottenere la versione di Cordova in esecuzione nel dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Amazon fuoco OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Il `device.model` restituisce il nome del modello del dispositivo o del prodotto. Il valore viene impostato dal produttore del dispositivo e può essere differente tra le versioni dello stesso prodotto.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Vedi http://theiphonewiki.com/wiki/index.php?title=Models / / modello var = device.model;
|
||||
|
||||
|
||||
### Stranezze Android
|
||||
|
||||
* Ottiene il [nome del prodotto][1] anziché il [nome del modello][2], che è spesso il nome di codice di produzione. Ad esempio, restituisce il Nexus One `Passion` , e Motorola Droid restituisce`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Tizen stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo assegnato dal fornitore, ad esempio,`TIZEN`
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo specificato dal produttore. Ad esempio, restituisce il Samsung Focus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Ottenere il nome del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 capricci
|
||||
|
||||
Windows Phone 7 dispositivi segnalano la piattaforma come`WinCE`.
|
||||
|
||||
### Windows Phone 8 stranezze
|
||||
|
||||
Dispositivi Windows Phone 8 segnalano la piattaforma come`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Ottenere identificatore del dispositivo univoco universale ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descrizione
|
||||
|
||||
I dettagli di come viene generato un UUID sono determinati dal produttore del dispositivo e sono specifici per la piattaforma o il modello del dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
/ / Android: restituisce un intero casuale di 64 bit (come stringa, ancora una volta!) / / il numero intero è generato al primo avvio del dispositivo / / / / BlackBerry: restituisce il numero PIN del dispositivo / / questo è un valore integer univoco a nove cifre (come stringa, benchè!) / / / / iPhone: (parafrasato dalla documentazione della classe UIDevice) / / restituisce una stringa di valori hash creata dall'hardware più identifica.
|
||||
/ / È garantito per essere unica per ogni dispositivo e non può essere legato / / per l'account utente.
|
||||
/ / Windows Phone 7: restituisce un hash dell'utente corrente, + dispositivo / / se l'utente non è definito, un guid generato e persisterà fino a quando l'applicazione viene disinstallata / / Tizen: restituisce il dispositivo IMEI (International Mobile Equipment Identity o IMEI è un numero / / unico per ogni cellulare GSM e UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Il `uuid` su iOS non è univoco per un dispositivo, ma varia per ogni applicazione, per ogni installazione. Cambia se si elimina e re-installare l'app, e possibilmente anche quando aggiornare iOS o anche aggiornare l'app per ogni versione (apparente in iOS 5.1). Il `uuid` non è un valore affidabile.
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
Il `uuid` per Windows Phone 7 richiede l'autorizzazione `ID_CAP_IDENTITY_DEVICE` . Microsoft probabilmente sarà presto deprecare questa proprietà. Se la funzionalità non è disponibile, l'applicazione genera un guid persistente che viene mantenuto per la durata dell'installazione dell'applicazione sul dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Ottenere la versione del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
203
cordova/plugins/cordova-plugin-device/doc/ja/README.md
Normal file
203
cordova/plugins/cordova-plugin-device/doc/ja/README.md
Normal file
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
このプラグインをグローバル定義します `device` オブジェクトは、デバイスのハードウェアとソフトウェアについて説明します。 それは後まで利用可能なオブジェクトがグローバル スコープでは、 `deviceready` イベント。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## インストール
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## プロパティ
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
デバイスで実行されているコルドバのバージョンを取得します。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アマゾン火 OS
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`、デバイスのモデルまたは製品の名前を返します。値は、デバイスの製造元によって設定され、同じ製品のバージョン間で異なる可能性があります。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models を参照してください//var モデル = device.model;
|
||||
|
||||
|
||||
### Android の癖
|
||||
|
||||
* 生産コード名は[モデル名](http://developer.android.com/reference/android/os/Build.html#MODEL)の代わりに[製品名](http://developer.android.com/reference/android/os/Build.html#PRODUCT)を取得します。 たとえば、ネクサス 1 つを返します `Passion` 、Motorola のドロイドを返します`voles`.
|
||||
|
||||
### Tizen の癖
|
||||
|
||||
* たとえば、ベンダーによって割り当てられているデバイスのモデルを返します`TIZEN`
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
* 製造元によって指定されたデバイスのモデルを返します。たとえば、三星フォーカスを返します`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
デバイスのオペレーティング システム名を取得します。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* Browser4
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 の癖
|
||||
|
||||
Windows Phone 7 デバイスとプラットフォームを報告します。`WinCE`.
|
||||
|
||||
### Windows Phone 8 癖
|
||||
|
||||
Windows Phone 8 デバイスとプラットフォームを報告します。`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
デバイスのユニバーサル ・ ユニーク識別子 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)を取得します。).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 解説
|
||||
|
||||
UUID を生成する方法の詳細は、デバイスの製造元によって決定され、デバイスのプラットフォームやモデルに固有です。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
//アンドロイド: ランダムな 64 ビットの整数 (を文字列として返します、再び !)/デバイスの最初の起動時に生成される整数/////ブラックベリー: デバイスのピン番号を返します//これは 9 桁の一意な整数 (を文字列としても !)////iPhone: (UIDevice クラスのドキュメントから言い換え)//識別複数のハードウェアから作成されたハッシュ値の文字列を返します。。
|
||||
//それはすべてのデバイスに対して一意であることが保証され、接続することはできません//ユーザー アカウント。
|
||||
//Windows Phone 7: デバイス + 現在のユーザーのハッシュを返します//ユーザーが定義されていない場合 guid が生成され、アプリがアンインストールされるまで保持されます//Tizen: デバイスの IMEI を返します (国際モバイル機器アイデンティティまたは IMEI は番号です//すべての GSM および UMTS の携帯電話に固有です。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS の気まぐれ
|
||||
|
||||
`uuid`IOS で、デバイスに固有ではないインストールごと、アプリケーションごとに異なります。 削除、アプリを再インストールした場合に変更と多分またときアップグレード iOS の, またはもアップグレードするアプリ (iOS の 5.1 で明らかに) バージョンごと。 `uuid`は信頼性の高い値ではありません。
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
`uuid`のために Windows Phone 7 には、権限が必要です `ID_CAP_IDENTITY_DEVICE` 。 Microsoft はすぐにこのプロパティを廃止して可能性があります。 機能が利用できない場合、アプリケーションはデバイスへのアプリケーションのインストールの持続期間のために保持されている永続的な guid を生成します。
|
||||
|
||||
## device.version
|
||||
|
||||
オペレーティング システムのバージョンを取得します。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド 2.1 +
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
206
cordova/plugins/cordova-plugin-device/doc/ja/index.md
Normal file
206
cordova/plugins/cordova-plugin-device/doc/ja/index.md
Normal file
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
このプラグインをグローバル定義します `device` オブジェクトは、デバイスのハードウェアとソフトウェアについて説明します。 それは後まで利用可能なオブジェクトがグローバル スコープでは、 `deviceready` イベント。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## インストール
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## プロパティ
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
デバイスで実行されているコルドバのバージョンを取得します。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アマゾン火 OS
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`、デバイスのモデルまたは製品の名前を返します。値は、デバイスの製造元によって設定され、同じ製品のバージョン間で異なる可能性があります。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models を参照してください//var モデル = device.model;
|
||||
|
||||
|
||||
### Android の癖
|
||||
|
||||
* 生産コード名は[モデル名][1]の代わりに[製品名][2]を取得します。 たとえば、ネクサス 1 つを返します `Passion` 、Motorola のドロイドを返します`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
|
||||
### Tizen の癖
|
||||
|
||||
* たとえば、ベンダーによって割り当てられているデバイスのモデルを返します`TIZEN`
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
* 製造元によって指定されたデバイスのモデルを返します。たとえば、三星フォーカスを返します`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
デバイスのオペレーティング システム名を取得します。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* Browser4
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 の癖
|
||||
|
||||
Windows Phone 7 デバイスとプラットフォームを報告します。`WinCE`.
|
||||
|
||||
### Windows Phone 8 癖
|
||||
|
||||
Windows Phone 8 デバイスとプラットフォームを報告します。`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
デバイスのユニバーサル ・ ユニーク識別子 ([UUID][3]を取得します。).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 説明
|
||||
|
||||
UUID を生成する方法の詳細は、デバイスの製造元によって決定され、デバイスのプラットフォームやモデルに固有です。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
//アンドロイド: ランダムな 64 ビットの整数 (を文字列として返します、再び !)/デバイスの最初の起動時に生成される整数/////ブラックベリー: デバイスのピン番号を返します//これは 9 桁の一意な整数 (を文字列としても !)////iPhone: (UIDevice クラスのドキュメントから言い換え)//識別複数のハードウェアから作成されたハッシュ値の文字列を返します。。
|
||||
//それはすべてのデバイスに対して一意であることが保証され、接続することはできません//ユーザー アカウント。
|
||||
//Windows Phone 7: デバイス + 現在のユーザーのハッシュを返します//ユーザーが定義されていない場合 guid が生成され、アプリがアンインストールされるまで保持されます//Tizen: デバイスの IMEI を返します (国際モバイル機器アイデンティティまたは IMEI は番号です//すべての GSM および UMTS の携帯電話に固有です。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS の気まぐれ
|
||||
|
||||
`uuid`IOS で、デバイスに固有ではないインストールごと、アプリケーションごとに異なります。 削除、アプリを再インストールした場合に変更と多分またときアップグレード iOS の, またはもアップグレードするアプリ (iOS の 5.1 で明らかに) バージョンごと。 `uuid`は信頼性の高い値ではありません。
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
`uuid`のために Windows Phone 7 には、権限が必要です `ID_CAP_IDENTITY_DEVICE` 。 Microsoft はすぐにこのプロパティを廃止して可能性があります。 機能が利用できない場合、アプリケーションはデバイスへのアプリケーションのインストールの持続期間のために保持されている永続的な guid を生成します。
|
||||
|
||||
## device.version
|
||||
|
||||
オペレーティング システムのバージョンを取得します。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド 2.1 +
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
203
cordova/plugins/cordova-plugin-device/doc/ko/README.md
Normal file
203
cordova/plugins/cordova-plugin-device/doc/ko/README.md
Normal file
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
이 플러그인 정의 전역 `device` 개체, 디바이스의 하드웨어 및 소프트웨어에 설명 합니다. 개체는 전역 범위에서 비록 그것은 후까지 사용할 수 있는 `deviceready` 이벤트.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 설치
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 속성
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
코르도바는 장치에서 실행 중인 버전을 얻을.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 아마존 화재 운영 체제
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`소자의 모델 또는 제품의 이름을 반환 합니다. 값 장치 제조업체에서 설정 되 고 동일 제품의 버전 간에 다를 수 있습니다.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models 참조 / / var 모델 = device.model;
|
||||
|
||||
|
||||
### 안 드 로이드 단점
|
||||
|
||||
* 어떤은 종종 프로덕션 코드 이름 대신 [제품 모델 이름](http://developer.android.com/reference/android/os/Build.html#MODEL), [제품 이름](http://developer.android.com/reference/android/os/Build.html#PRODUCT) 을 가져옵니다. 예를 들어 넥서스 하나 반환 합니다 `Passion` , 모토로라 Droid를 반환 합니다`voles`.
|
||||
|
||||
### Tizen 특수
|
||||
|
||||
* 예를 들어, 공급 업체에 의해 할당 된 디바이스 모델을 반환 합니다.`TIZEN`
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
* 제조업체에서 지정 하는 장치 모델을 반환 합니다. 예를 들어 삼성 포커스를 반환 합니다.`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
장치의 운영 체제 이름을 얻을.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* Browser4
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 단점
|
||||
|
||||
Windows Phone 7 장치 보고 플랫폼으로`WinCE`.
|
||||
|
||||
### Windows Phone 8 단점
|
||||
|
||||
Windows Phone 8 장치 보고 플랫폼으로`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
소자의 보편적으로 고유 식별자 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier) 를 얻을합니다).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 설명
|
||||
|
||||
UUID 생성 방법의 자세한 내용은 장치 제조업체에 의해 결정 됩니다 및 소자의 플랫폼 이나 모델.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
/ / 안 드 로이드: (문자열로 다시!) 임의의 64 비트 정수를 반환 합니다 / / 정수 장치의 첫 번째 부팅에서 생성 / / / / 블랙베리: 디바이스의 핀 번호를 반환 합니다 / / 이것은 9 자리 고유 정수 (문자열로 비록!) / / / / 아이폰: (UIDevice 클래스 설명서에서 읊 었) / / 문자열 여러 하드웨어에서 생성 하는 해시 값을 식별 하는 반환 합니다.
|
||||
/ 그것은 모든 장치에 대 한 고유 해야 보장 되 고 묶일 수 없습니다 / / / 사용자 계정에.
|
||||
/ / Windows Phone 7: 장치 + 현재 사용자의 해시를 반환 합니다 / / 사용자 정의 되지 않은 경우 guid 생성 되 고 응용 프로그램을 제거할 때까지 유지 됩니다 / / Tizen: 반환 장치 IMEI (국제 모바일 기기 식별 또는 IMEI 숫자입니다 / / 모든 GSM와 UMTS 휴대 전화 고유.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 특질
|
||||
|
||||
`uuid`ios 장치에 고유 하지 않습니다 하지만 각 설치에 대 한 응용 프로그램 마다 다릅니다. 삭제 하 고 다시 애플 리 케이 션을 설치 하는 경우 변경 가능 하 게 또한 iOS를 업그레이드 하거나 때 버전 (iOS 5.1에에서 명백한) 당 응용 프로그램 업그레이드도 하 고. `uuid`은 신뢰할 수 있는 값이 아닙니다.
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
`uuid`Windows Phone 7 필요 허가 `ID_CAP_IDENTITY_DEVICE` . Microsoft는 곧이 속성을 세웁니다 가능성이 것입니다. 기능을 사용할 수 없는 경우 응용 프로그램 장치에 응용 프로그램의 설치 하는 동안 유지 하는 영구 guid를 생성 합니다.
|
||||
|
||||
## device.version
|
||||
|
||||
운영 체제 버전을 얻을.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드 2.1 +
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
206
cordova/plugins/cordova-plugin-device/doc/ko/index.md
Normal file
206
cordova/plugins/cordova-plugin-device/doc/ko/index.md
Normal file
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
이 플러그인 정의 전역 `device` 개체, 디바이스의 하드웨어 및 소프트웨어에 설명 합니다. 개체는 전역 범위에서 비록 그것은 후까지 사용할 수 있는 `deviceready` 이벤트.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 설치
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 속성
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
코르도바는 장치에서 실행 중인 버전을 얻을.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 아마존 화재 운영 체제
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`소자의 모델 또는 제품의 이름을 반환 합니다. 값 장치 제조업체에서 설정 되 고 동일 제품의 버전 간에 다를 수 있습니다.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models 참조 / / var 모델 = device.model;
|
||||
|
||||
|
||||
### 안 드 로이드 단점
|
||||
|
||||
* 어떤은 종종 프로덕션 코드 이름 대신 [제품 모델 이름][1], [제품 이름][2] 을 가져옵니다. 예를 들어 넥서스 하나 반환 합니다 `Passion` , 모토로라 Droid를 반환 합니다`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
|
||||
### Tizen 특수
|
||||
|
||||
* 예를 들어, 공급 업체에 의해 할당 된 디바이스 모델을 반환 합니다.`TIZEN`
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
* 제조업체에서 지정 하는 장치 모델을 반환 합니다. 예를 들어 삼성 포커스를 반환 합니다.`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
장치의 운영 체제 이름을 얻을.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* Browser4
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 단점
|
||||
|
||||
Windows Phone 7 장치 보고 플랫폼으로`WinCE`.
|
||||
|
||||
### Windows Phone 8 단점
|
||||
|
||||
Windows Phone 8 장치 보고 플랫폼으로`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
소자의 보편적으로 고유 식별자 ([UUID][3] 를 얻을합니다).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 설명
|
||||
|
||||
UUID 생성 방법의 자세한 내용은 장치 제조업체에 의해 결정 됩니다 및 소자의 플랫폼 이나 모델.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
/ / 안 드 로이드: (문자열로 다시!) 임의의 64 비트 정수를 반환 합니다 / / 정수 장치의 첫 번째 부팅에서 생성 / / / / 블랙베리: 디바이스의 핀 번호를 반환 합니다 / / 이것은 9 자리 고유 정수 (문자열로 비록!) / / / / 아이폰: (UIDevice 클래스 설명서에서 읊 었) / / 문자열 여러 하드웨어에서 생성 하는 해시 값을 식별 하는 반환 합니다.
|
||||
/ 그것은 모든 장치에 대 한 고유 해야 보장 되 고 묶일 수 없습니다 / / / 사용자 계정에.
|
||||
/ / Windows Phone 7: 장치 + 현재 사용자의 해시를 반환 합니다 / / 사용자 정의 되지 않은 경우 guid 생성 되 고 응용 프로그램을 제거할 때까지 유지 됩니다 / / Tizen: 반환 장치 IMEI (국제 모바일 기기 식별 또는 IMEI 숫자입니다 / / 모든 GSM와 UMTS 휴대 전화 고유.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 특질
|
||||
|
||||
`uuid`ios 장치에 고유 하지 않습니다 하지만 각 설치에 대 한 응용 프로그램 마다 다릅니다. 삭제 하 고 다시 애플 리 케이 션을 설치 하는 경우 변경 가능 하 게 또한 iOS를 업그레이드 하거나 때 버전 (iOS 5.1에에서 명백한) 당 응용 프로그램 업그레이드도 하 고. `uuid`은 신뢰할 수 있는 값이 아닙니다.
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
`uuid`Windows Phone 7 필요 허가 `ID_CAP_IDENTITY_DEVICE` . Microsoft는 곧이 속성을 세웁니다 가능성이 것입니다. 기능을 사용할 수 없는 경우 응용 프로그램 장치에 응용 프로그램의 설치 하는 동안 유지 하는 영구 guid를 생성 합니다.
|
||||
|
||||
## device.version
|
||||
|
||||
운영 체제 버전을 얻을.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드 2.1 +
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
214
cordova/plugins/cordova-plugin-device/doc/pl/README.md
Normal file
214
cordova/plugins/cordova-plugin-device/doc/pl/README.md
Normal file
@@ -0,0 +1,214 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Ten plugin określa globalne `device` obiekt, który opisuje urządzenia sprzętowe i programowe. Mimo, że obiekt jest w globalnym zasięgu, nie jest dostępne dopiero po `deviceready` zdarzenie.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalacja
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Właściwości
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Pobierz wersję Cordova działa na urządzeniu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`Zwraca nazwę modelu lub produktu. Wartość jest zestaw przez producenta urządzenia i mogą się różnić między wersjami tego samego produktu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Zobacz http://theiphonewiki.com/wiki/index.php?title=Models / / modelu var = device.model;
|
||||
|
||||
|
||||
### Dziwactwa Androida
|
||||
|
||||
* Pobiera [nazwę produktu](http://developer.android.com/reference/android/os/Build.html#PRODUCT) zamiast [nazwy modelu](http://developer.android.com/reference/android/os/Build.html#MODEL), który często jest nazwą kod produkcji. Na przykład, Nexus One zwraca `Passion` , i zwraca Motorola Droid`voles`.
|
||||
|
||||
### Dziwactwa Tizen
|
||||
|
||||
* Zwraca modelu urządzenia przypisane przez dostawcę, na przykład,`TIZEN`
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
* Zwraca modelu urządzenia, określonej przez producenta. Na przykład Samsung ostrości zwraca`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Uzyskać nazwę systemu operacyjnego urządzenia.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Dziwactwa Windows Phone 7
|
||||
|
||||
Urządzenia Windows Phone 7 raport platformy jako`WinCE`.
|
||||
|
||||
### Windows Phone 8 dziwactwa
|
||||
|
||||
Urządzenia Windows Phone 8 raport platformy jako`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Się urządzenia uniwersalnie unikatowy identyfikator ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Opis
|
||||
|
||||
Szczegóły jak UUID jest generowane są określane przez producenta urządzenia i są specyficzne dla platformy lub modelu urządzenia.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Returns a random 64-bit integer (as a string, again!)
|
||||
// The integer is generated on the device's first boot
|
||||
//
|
||||
// BlackBerry: Returns the PIN number of the device
|
||||
// This is a nine-digit unique integer (as a string, though!)
|
||||
//
|
||||
// iPhone: (Paraphrased from the UIDevice Class documentation)
|
||||
// Returns a string of hash values created from multiple hardware identifies.
|
||||
// It is guaranteed to be unique for every device and can't be tied
|
||||
// to the user account.
|
||||
// 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
|
||||
// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
|
||||
// unique to every GSM and UMTS mobile phone.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS dziwactwo
|
||||
|
||||
`uuid`Na iOS nie jest przypisany do urządzenia, ale różni się dla każdej aplikacji, dla każdej instalacji. Zmienia się jeśli możesz usunąć i ponownie zainstalować aplikację, a ewentualnie także po aktualizacji iOS czy nawet uaktualnienia aplikacji dla wersji (widoczny w iOS 5.1). `uuid`Jest nie wiarygodne wartości.
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
`uuid`Dla Windows Phone 7 wymaga uprawnień `ID_CAP_IDENTITY_DEVICE` . Microsoft będzie prawdopodobnie potępiać ten wkrótce. Jeśli funkcja nie jest dostępna, aplikacja generuje trwałe identyfikator guid, który jest utrzymywany przez czas trwania instalacji aplikacji na urządzeniu.
|
||||
|
||||
## device.version
|
||||
|
||||
Pobierz wersję systemu operacyjnego.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
206
cordova/plugins/cordova-plugin-device/doc/pl/index.md
Normal file
206
cordova/plugins/cordova-plugin-device/doc/pl/index.md
Normal file
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Ten plugin określa globalne `device` obiekt, który opisuje urządzenia sprzętowe i programowe. Mimo, że obiekt jest w globalnym zasięgu, nie jest dostępne dopiero po `deviceready` zdarzenie.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalacja
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Właściwości
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Pobierz wersję Cordova działa na urządzeniu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`Zwraca nazwę modelu lub produktu. Wartość jest zestaw przez producenta urządzenia i mogą się różnić między wersjami tego samego produktu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Zobacz http://theiphonewiki.com/wiki/index.php?title=Models / / modelu var = device.model;
|
||||
|
||||
|
||||
### Dziwactwa Androida
|
||||
|
||||
* Pobiera [nazwę produktu][1] zamiast [nazwy modelu][2], który często jest nazwą kod produkcji. Na przykład, Nexus One zwraca `Passion` , i zwraca Motorola Droid`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Dziwactwa Tizen
|
||||
|
||||
* Zwraca modelu urządzenia przypisane przez dostawcę, na przykład,`TIZEN`
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
* Zwraca modelu urządzenia, określonej przez producenta. Na przykład Samsung ostrości zwraca`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Uzyskać nazwę systemu operacyjnego urządzenia.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Dziwactwa Windows Phone 7
|
||||
|
||||
Urządzenia Windows Phone 7 raport platformy jako`WinCE`.
|
||||
|
||||
### Windows Phone 8 dziwactwa
|
||||
|
||||
Urządzenia Windows Phone 8 raport platformy jako`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Się urządzenia uniwersalnie unikatowy identyfikator ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Opis
|
||||
|
||||
Szczegóły jak UUID jest generowane są określane przez producenta urządzenia i są specyficzne dla platformy lub modelu urządzenia.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
/ / Android: zwraca losowe 64-bitowa liczba całkowita (jako ciąg, znowu!) / / liczba całkowita jest generowany na pierwszego uruchomienia urządzenia / / / / BlackBerry: zwraca numer PIN urządzenia / / to jest unikatową liczbą całkowitą dziewięciu cyfr (jako ciąg, choć!) / / / / iPhone: (zacytowana w dokumentacji klasy UIDevice) / / zwraca ciąg wartości mieszania utworzone z wielu sprzętu identyfikuje.
|
||||
Zapewniona jest unikatowy dla każdego urządzenia i nie może być związane z / do konta użytkownika.
|
||||
/ / Windows Phone 7: zwraca wartość mieszania urządzenia + bieżący użytkownik, / / jeśli nie zdefiniowane przez użytkownika, identyfikator guid jest generowany i będzie trwać do czasu odinstalowania aplikacji / / Tizen: zwraca urządzenia IMEI (International Mobile Equipment Identity lub IMEI jest liczbą / / unikatowe dla każdego telefonu komórkowego GSM i UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS dziwactwo
|
||||
|
||||
`uuid`Na iOS nie jest przypisany do urządzenia, ale różni się dla każdej aplikacji, dla każdej instalacji. Zmienia się jeśli możesz usunąć i ponownie zainstalować aplikację, a ewentualnie także po aktualizacji iOS czy nawet uaktualnienia aplikacji dla wersji (widoczny w iOS 5.1). `uuid`Jest nie wiarygodne wartości.
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
`uuid`Dla Windows Phone 7 wymaga uprawnień `ID_CAP_IDENTITY_DEVICE` . Microsoft będzie prawdopodobnie potępiać ten wkrótce. Jeśli funkcja nie jest dostępna, aplikacja generuje trwałe identyfikator guid, który jest utrzymywany przez czas trwania instalacji aplikacji na urządzeniu.
|
||||
|
||||
## device.version
|
||||
|
||||
Pobierz wersję systemu operacyjnego.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
219
cordova/plugins/cordova-plugin-device/doc/ru/index.md
Normal file
219
cordova/plugins/cordova-plugin-device/doc/ru/index.md
Normal file
@@ -0,0 +1,219 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Этот плагин определяет глобальный объект `device`, который описывает оборудование и программное обеспечение устройства. Несмотря на то что объект в глобальной области видимости, он не доступен до того момента пока не произойдет событие `deviceready`.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Установка
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Параметры
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Возвращает версию Cordova, работающую на устройстве.
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Обозреватель
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Свойство `device.model` возвращает имя устройства модели или продукта. Значение устанавливается производителем устройства и могут отличаться в разных версиях одного и того же продукта.
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Обозреватель
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Особенности Android
|
||||
|
||||
* Возвращает [имя продукта][1] , а не [имя модели][2], которое часто является производственным кодом. Например, Nexus One из них возвращает `Passion` , и Motorola Droid возвращает `voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Особенности Tizen
|
||||
|
||||
* Возвращает модель устройства, назначенного вендором, например,`TIZEN`
|
||||
|
||||
### Особенности Windows Phone 7 и 8
|
||||
|
||||
* Возвращает модель устройства, указанной заводом-изготовителем. Например Samsung Focus возвращает `SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Получите имя операционной системы устройства.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Браузером4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Особенности Windows Phone 7
|
||||
|
||||
Windows Phone 7 устройства сообщают платформу как `WinCE`.
|
||||
|
||||
### Особенности Windows Phone 8
|
||||
|
||||
Устройства Windows Phone 8 сообщают платформу как `Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Возвращает универсальный уникального идентификатора ([UUID][3] устройства).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Описание
|
||||
|
||||
Подробная информация о том как UUID генерируется, определяются изготовителем устройства и являются специфическими для платформы или модели устройства.
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// Android: Возвращает случайное 64-разрядное целое число (в виде строки, опять!)
|
||||
// целое число генерируется при первой загрузке устройства
|
||||
//
|
||||
// BlackBerry: Возвращает номер PIN устройства
|
||||
// это 9 значный уникальный целочисленный (как строка, хотя!)
|
||||
//
|
||||
// iPhone: (Перефразировано из документации класса UIDevice)
|
||||
// возвращает строку хэш-значения, созданные из нескольких аппаратных определяет.
|
||||
// Это значение гарантированно является уникальным для каждого устройства и не может быть привязано
|
||||
// к учетной записи пользователя.
|
||||
// Windows Phone 7: Возвращает хэш устройство + текущего пользователя,
|
||||
// если пользователь не определен, формируется guid который и будет сохраняться до тех пор, пока приложение не удалиться
|
||||
// Tizen: возвращает IMEI устройства (Международный идентификатор мобильного оборудования или IMEI это число
|
||||
// уникальное для каждого мобильного телефона GSM и UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Особенности iOS
|
||||
|
||||
На iOS `uuid` не является уникальным для устройства, но варьируется для каждого приложения, и для каждой установки. Значение меняется, если удалить и повторно установить приложение, и возможно также когда вы обновите iOS, или даже обновить приложение до следующей версии (очевидно в iOS 5.1). Значение `uuid` не является надежным.
|
||||
|
||||
### Особенности Windows Phone 7 и 8
|
||||
|
||||
Для Windows Phone 7 `uuid` требует разрешения `ID_CAP_IDENTITY_DEVICE` . Microsoft скорее всего скоро сделает это свойство устаревшим. Если возможность недоступна, приложение создает постоянные guid, который сохраняется на все время установки приложения на устройстве.
|
||||
|
||||
## device.version
|
||||
|
||||
Возвращает версию операционной системы.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Обозреватель
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
203
cordova/plugins/cordova-plugin-device/doc/zh/README.md
Normal file
203
cordova/plugins/cordova-plugin-device/doc/zh/README.md
Normal file
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
這個外掛程式定義全球 `device` 物件,描述該設備的硬體和軟體。 雖然物件是在全球範圍內,但不是可用,直到後 `deviceready` 事件。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 安裝
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 屬性
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
獲取科爾多瓦在設備上運行的版本。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* 亞馬遜火 OS
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* 火狐瀏覽器作業系統
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`返回設備的模型或產品的名稱。值由設備製造商設置和同一產品的不同版本可能不同。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. 請參閱 HTTP://theiphonewiki.com/wiki/index.php?title=Models / / var 模型 = device.model ;
|
||||
|
||||
|
||||
### Android 的怪癖
|
||||
|
||||
* 獲取[產品名稱](http://developer.android.com/reference/android/os/Build.html#PRODUCT)而不是[產品型號名稱](http://developer.android.com/reference/android/os/Build.html#MODEL),這往往是生產代碼名稱。 例如,Nexus One 返回 `Passion` ,和摩托羅拉 Droid 返回`voles`.
|
||||
|
||||
### Tizen 怪癖
|
||||
|
||||
* 例如,返回與供應商指派的設備模型`TIZEN`
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
* 返回由製造商指定的設備模型。例如,三星焦點返回`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
獲取設備的作業系統名稱。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* Browser4
|
||||
* 火狐瀏覽器作業系統
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 的怪癖
|
||||
|
||||
Windows Phone 7 設備報告作為平臺`WinCE`.
|
||||
|
||||
### Windows Phone 8 怪癖
|
||||
|
||||
Windows Phone 8 設備報告作為平臺`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
獲取設備的通用唯一識別碼 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 說明
|
||||
|
||||
如何生成一個 UUID 的細節由設備製造商和特定于設備的平臺或模型。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
/ / Android: 一個隨機的 64 位整數 (作為字串返回,再次!) / / 上設備的第一次啟動生成的整數 / / / / 黑莓手機: 返回設備的 PIN 號碼 / / 這是九個數字的唯一整數 (作為字串,雖然!) / / / / iPhone: (從 UIDevice 類文檔解釋) / / 返回一個字串的雜湊值創建的多個硬體標識。
|
||||
/ / 它保證是唯一的每個設備並不能綁 / / 到使用者帳戶。
|
||||
/ / Windows Phone 7: 返回的雜湊代碼的設備 + 當前使用者,/ / 如果未定義使用者,則一個 guid 生成的並且將會保留直到卸載該應用程式 / / Tizen: 返回設備 IMEI (國際行動裝置身份或 IMEI 是一個數位 / / 獨有的每一個 UMTS 和 GSM 行動電話。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 怪癖
|
||||
|
||||
`uuid`在 iOS 不是唯一的一種裝置,但對於每個應用程式,為每個安裝而異。 如果您刪除並重新安裝該應用程式,它更改和可能還當你升級 iOS,或甚至升級每個版本 (iOS 5.1 中存在明顯的) 的應用程式。 `uuid`不是一個可靠的值。
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
`uuid`為 Windows Phone 7 須經許可 `ID_CAP_IDENTITY_DEVICE` 。 Microsoft 可能會很快棄用此屬性。 如果沒有可用的能力,應用程式將生成設備上應用程式的安裝過程中保持持續的 guid。
|
||||
|
||||
## device.version
|
||||
|
||||
獲取作業系統版本。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 2.1 +
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
206
cordova/plugins/cordova-plugin-device/doc/zh/index.md
Normal file
206
cordova/plugins/cordova-plugin-device/doc/zh/index.md
Normal file
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
這個外掛程式定義全球 `device` 物件,描述該設備的硬體和軟體。 雖然物件是在全球範圍內,但不是可用,直到後 `deviceready` 事件。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 安裝
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 屬性
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
獲取科爾多瓦在設備上運行的版本。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* 亞馬遜火 OS
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* 火狐瀏覽器的作業系統
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`返回設備的模型或產品的名稱。值由設備製造商設置和同一產品的不同版本可能不同。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. 請參閱 HTTP://theiphonewiki.com/wiki/index.php?title=Models / / var 模型 = device.model ;
|
||||
|
||||
|
||||
### Android 的怪癖
|
||||
|
||||
* 獲取[產品名稱][1]而不是[產品型號名稱][2],這往往是生產代碼名稱。 例如,Nexus One 返回 `Passion` ,和摩托羅拉 Droid 返回`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Tizen 怪癖
|
||||
|
||||
* 例如,返回與供應商指派的設備模型`TIZEN`
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
* 返回由製造商指定的設備模型。例如,三星焦點返回`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
獲取設備的作業系統名稱。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* Browser4
|
||||
* 火狐瀏覽器的作業系統
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 的怪癖
|
||||
|
||||
Windows Phone 7 設備報告作為平臺`WinCE`.
|
||||
|
||||
### Windows Phone 8 怪癖
|
||||
|
||||
Windows Phone 8 設備報告作為平臺`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
獲取設備的通用唯一識別碼 ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 說明
|
||||
|
||||
如何生成一個 UUID 的細節由設備製造商和特定于設備的平臺或模型。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
/ / Android: 一個隨機的 64 位整數 (作為字串返回,再次!) / / 上設備的第一次啟動生成的整數 / / / / 黑莓手機: 返回設備的 PIN 號碼 / / 這是九個數字的唯一整數 (作為字串,雖然!) / / / / iPhone: (從 UIDevice 類文檔解釋) / / 返回一個字串的雜湊值創建的多個硬體標識。
|
||||
/ / 它保證是唯一的每個設備並不能綁 / / 到使用者帳戶。
|
||||
/ / Windows Phone 7: 返回的雜湊代碼的設備 + 當前使用者,/ / 如果未定義使用者,則一個 guid 生成的並且將會保留直到卸載該應用程式 / / Tizen: 返回設備 IMEI (國際行動裝置身份或 IMEI 是一個數位 / / 獨有的每一個 UMTS 和 GSM 行動電話。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 怪癖
|
||||
|
||||
`uuid`在 iOS 不是唯一的一種裝置,但對於每個應用程式,為每個安裝而異。 如果您刪除並重新安裝該應用程式,它更改和可能還當你升級 iOS,或甚至升級每個版本 (iOS 5.1 中存在明顯的) 的應用程式。 `uuid`不是一個可靠的值。
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
`uuid`為 Windows Phone 7 須經許可 `ID_CAP_IDENTITY_DEVICE` 。 Microsoft 可能會很快棄用此屬性。 如果沒有可用的能力,應用程式將生成設備上應用程式的安裝過程中保持持續的 guid。
|
||||
|
||||
## device.version
|
||||
|
||||
獲取作業系統版本。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 2.1 +
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// 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"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
45
cordova/plugins/cordova-plugin-device/package.json
Normal file
45
cordova/plugins/cordova-plugin-device/package.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "cordova-plugin-device",
|
||||
"version": "1.1.0",
|
||||
"description": "Cordova Device Plugin",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-device",
|
||||
"platforms": [
|
||||
"firefoxos",
|
||||
"tizen",
|
||||
"android",
|
||||
"amazon-fireos",
|
||||
"ubuntu",
|
||||
"ios",
|
||||
"blackberry10",
|
||||
"wp7",
|
||||
"wp8",
|
||||
"windows8",
|
||||
"windows",
|
||||
"browser"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-device"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"device",
|
||||
"ecosystem:cordova",
|
||||
"cordova-firefoxos",
|
||||
"cordova-tizen",
|
||||
"cordova-android",
|
||||
"cordova-amazon-fireos",
|
||||
"cordova-ubuntu",
|
||||
"cordova-ios",
|
||||
"cordova-blackberry10",
|
||||
"cordova-wp7",
|
||||
"cordova-wp8",
|
||||
"cordova-windows8",
|
||||
"cordova-windows",
|
||||
"cordova-browser"
|
||||
],
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache 2.0"
|
||||
}
|
161
cordova/plugins/cordova-plugin-device/plugin.xml
Normal file
161
cordova/plugins/cordova-plugin-device/plugin.xml
Normal file
@@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-device"
|
||||
version="1.1.0">
|
||||
<name>Device</name>
|
||||
<description>Cordova Device Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
<keywords>cordova,device</keywords>
|
||||
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git</repo>
|
||||
<issue>https://issues.apache.org/jira/browse/CB/component/12320648</issue>
|
||||
|
||||
<js-module src="www/device.js" name="device">
|
||||
<clobbers target="device" />
|
||||
</js-module>
|
||||
|
||||
<!-- firefoxos -->
|
||||
<platform name="firefoxos">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="Device">
|
||||
<param name="firefoxos-package" value="Device" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<js-module src="src/firefoxos/DeviceProxy.js" name="DeviceProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
<!-- tizen -->
|
||||
<platform name="tizen">
|
||||
<js-module src="src/tizen/DeviceProxy.js" name="DeviceProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
<!-- android -->
|
||||
<platform name="android">
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="Device" >
|
||||
<param name="android-package" value="org.apache.cordova.device.Device"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/Device.java" target-dir="src/org/apache/cordova/device" />
|
||||
</platform>
|
||||
|
||||
<!-- amazon-fireos -->
|
||||
<platform name="amazon-fireos">
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="Device" >
|
||||
<param name="android-package" value="org.apache.cordova.device.Device"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/Device.java" target-dir="src/org/apache/cordova/device" />
|
||||
</platform>
|
||||
|
||||
<!-- ubuntu -->
|
||||
<platform name="ubuntu">
|
||||
<header-file src="src/ubuntu/device.h" />
|
||||
<source-file src="src/ubuntu/device.cpp" />
|
||||
<js-module src="src/ubuntu/device.js" name="DeviceProxy">
|
||||
<merges target="device" />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="Device">
|
||||
<param name="ios-package" value="CDVDevice"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<header-file src="src/ios/CDVDevice.h" />
|
||||
<source-file src="src/ios/CDVDevice.m" />
|
||||
</platform>
|
||||
|
||||
<!-- blackberry10 -->
|
||||
<platform name="blackberry10">
|
||||
<source-file src="src/blackberry10/index.js" target-dir="Device" />
|
||||
<config-file target="www/config.xml" parent="/widget">
|
||||
<feature name="Device" value="Device"/>
|
||||
</config-file>
|
||||
<config-file target="www/config.xml" parent="/widget/rim:permissions">
|
||||
<rim:permit>read_device_identifying_information</rim:permit>
|
||||
</config-file>
|
||||
</platform>
|
||||
|
||||
<!-- wp7 -->
|
||||
<platform name="wp7">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="Device">
|
||||
<param name="wp-package" value="Device"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/wp/Device.cs" />
|
||||
</platform>
|
||||
|
||||
<!-- wp8 -->
|
||||
<platform name="wp8">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="Device">
|
||||
<param name="wp-package" value="Device"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/wp/Device.cs" />
|
||||
</platform>
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="src/windows/DeviceProxy.js" name="DeviceProxy">
|
||||
<merges target="" />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
<!-- browser -->
|
||||
<platform name="browser">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="Device">
|
||||
<param name="browser-package" value="Device" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<js-module src="src/browser/DeviceProxy.js" name="DeviceProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
</plugin>
|
174
cordova/plugins/cordova-plugin-device/src/android/Device.java
Normal file
174
cordova/plugins/cordova-plugin-device/src/android/Device.java
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
package org.apache.cordova.device;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.provider.Settings;
|
||||
|
||||
public class Device extends CordovaPlugin {
|
||||
public static final String TAG = "Device";
|
||||
|
||||
public static String platform; // Device OS
|
||||
public static String uuid; // Device UUID
|
||||
|
||||
private static final String ANDROID_PLATFORM = "Android";
|
||||
private static final String AMAZON_PLATFORM = "amazon-fireos";
|
||||
private static final String AMAZON_DEVICE = "Amazon";
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Device() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context of the Command. This can then be used to do things like
|
||||
* get file paths associated with the Activity.
|
||||
*
|
||||
* @param cordova The context of the main Activity.
|
||||
* @param webView The CordovaWebView Cordova is running in.
|
||||
*/
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
Device.uuid = getUuid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackContext The callback id used when calling back into JavaScript.
|
||||
* @return True if the action was valid, false if not.
|
||||
*/
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
if ("getDeviceInfo".equals(action)) {
|
||||
JSONObject r = new JSONObject();
|
||||
r.put("uuid", Device.uuid);
|
||||
r.put("version", this.getOSVersion());
|
||||
r.put("platform", this.getPlatform());
|
||||
r.put("model", this.getModel());
|
||||
r.put("manufacturer", this.getManufacturer());
|
||||
r.put("isVirtual", this.isVirtual());
|
||||
r.put("serial", this.getSerialNumber());
|
||||
callbackContext.success(r);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// LOCAL METHODS
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get the OS name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPlatform() {
|
||||
String platform;
|
||||
if (isAmazonDevice()) {
|
||||
platform = AMAZON_PLATFORM;
|
||||
} else {
|
||||
platform = ANDROID_PLATFORM;
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device's Universally Unique Identifier (UUID).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getUuid() {
|
||||
String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
String model = android.os.Build.MODEL;
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
String productname = android.os.Build.PRODUCT;
|
||||
return productname;
|
||||
}
|
||||
|
||||
public String getManufacturer() {
|
||||
String manufacturer = android.os.Build.MANUFACTURER;
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
public String getSerialNumber() {
|
||||
String serial = android.os.Build.SERIAL;
|
||||
return serial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the OS version.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getOSVersion() {
|
||||
String osversion = android.os.Build.VERSION.RELEASE;
|
||||
return osversion;
|
||||
}
|
||||
|
||||
public String getSDKVersion() {
|
||||
@SuppressWarnings("deprecation")
|
||||
String sdkversion = android.os.Build.VERSION.SDK;
|
||||
return sdkversion;
|
||||
}
|
||||
|
||||
public String getTimeZoneID() {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
return (tz.getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to check if the device is manufactured by Amazon
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isAmazonDevice() {
|
||||
if (android.os.Build.MANUFACTURER.equals(AMAZON_DEVICE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVirtual() {
|
||||
return android.os.Build.FINGERPRINT.contains("generic") ||
|
||||
android.os.Build.PRODUCT.contains("sdk");
|
||||
}
|
||||
|
||||
}
|
69
cordova/plugins/cordova-plugin-device/src/blackberry10/index.js
vendored
Normal file
69
cordova/plugins/cordova-plugin-device/src/blackberry10/index.js
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
function getModelName () {
|
||||
var modelName = window.qnx.webplatform.device.modelName;
|
||||
//Pre 10.2 (meaning Z10 or Q10)
|
||||
if (typeof modelName === "undefined") {
|
||||
if (window.screen.height === 720 && window.screen.width === 720) {
|
||||
if ( window.matchMedia("(-blackberry-display-technology: -blackberry-display-oled)").matches) {
|
||||
modelName = "Q10";
|
||||
} else {
|
||||
modelName = "Q5";
|
||||
}
|
||||
} else if ((window.screen.height === 1280 && window.screen.width === 768) ||
|
||||
(window.screen.height === 768 && window.screen.width === 1280)) {
|
||||
modelName = "Z10";
|
||||
} else {
|
||||
modelName = window.qnx.webplatform.deviceName;
|
||||
}
|
||||
}
|
||||
|
||||
return modelName;
|
||||
}
|
||||
|
||||
function getUUID () {
|
||||
var uuid = "";
|
||||
try {
|
||||
//Must surround by try catch because this will throw if the app is missing permissions
|
||||
uuid = window.qnx.webplatform.device.devicePin;
|
||||
} catch (e) {
|
||||
//DO Nothing
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDeviceInfo: function (success, fail, args, env) {
|
||||
var result = new PluginResult(args, env),
|
||||
modelName = getModelName(),
|
||||
uuid = getUUID(),
|
||||
info = {
|
||||
manufacturer: 'BlackBerry',
|
||||
platform: "blackberry10",
|
||||
version: window.qnx.webplatform.device.scmBundle,
|
||||
model: modelName,
|
||||
uuid: uuid
|
||||
};
|
||||
|
||||
result.ok(info);
|
||||
}
|
||||
};
|
82
cordova/plugins/cordova-plugin-device/src/browser/DeviceProxy.js
vendored
Normal file
82
cordova/plugins/cordova-plugin-device/src/browser/DeviceProxy.js
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
var browser = require('cordova/platform');
|
||||
var cordova = require('cordova');
|
||||
|
||||
function getPlatform() {
|
||||
return "browser";
|
||||
}
|
||||
|
||||
function getModel() {
|
||||
return getBrowserInfo(true);
|
||||
}
|
||||
|
||||
function getVersion() {
|
||||
return getBrowserInfo(false);
|
||||
}
|
||||
|
||||
function getBrowserInfo(getModel) {
|
||||
var userAgent = navigator.userAgent;
|
||||
var returnVal = '';
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
getDeviceInfo: function (success, error) {
|
||||
setTimeout(function () {
|
||||
success({
|
||||
cordova: browser.cordovaVersion,
|
||||
platform: getPlatform(),
|
||||
model: getModel(),
|
||||
version: getVersion(),
|
||||
uuid: null
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("Device", module.exports);
|
79
cordova/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js
vendored
Normal file
79
cordova/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
//example UA String for Firefox OS
|
||||
//Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0
|
||||
var firefoxos = require('cordova/platform');
|
||||
var cordova = require('cordova');
|
||||
|
||||
//UA parsing not recommended but currently this is the only way to get the Firefox OS version
|
||||
//https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
|
||||
|
||||
//Should be replaced when better conversion to Firefox OS Version is available
|
||||
function convertVersionNumber(ver) {
|
||||
var hashVersion = {
|
||||
'18.0': '1.0.1',
|
||||
'18.1': '1.1',
|
||||
'26.0': '1.2',
|
||||
'28.0': '1.3',
|
||||
'30.0': '1.4',
|
||||
'32.0': '2.0'
|
||||
};
|
||||
var rver = ver;
|
||||
var sStr = ver.substring(0, 4);
|
||||
if (hashVersion[sStr]) {
|
||||
rver = hashVersion[sStr];
|
||||
}
|
||||
return (rver);
|
||||
|
||||
}
|
||||
function getVersion() {
|
||||
if (navigator.userAgent.match(/(mobile|tablet)/i)) {
|
||||
var ffVersionArray = (navigator.userAgent.match(/Firefox\/([\d]+\.[\w]?\.?[\w]+)/));
|
||||
if (ffVersionArray.length === 2) {
|
||||
return (convertVersionNumber(ffVersionArray[1]));
|
||||
}
|
||||
}
|
||||
return (null);
|
||||
}
|
||||
|
||||
function getModel() {
|
||||
var uaArray = navigator.userAgent.split(/\s*[;)(]\s*/);
|
||||
if (navigator.userAgent.match(/(mobile|tablet)/i)) {
|
||||
if (uaArray.length === 5) {
|
||||
return (uaArray[2]);
|
||||
}
|
||||
}
|
||||
return (null);
|
||||
}
|
||||
module.exports = {
|
||||
getDeviceInfo: function (success, error) {
|
||||
setTimeout(function () {
|
||||
success({
|
||||
platform: 'firefoxos',
|
||||
model: getModel(),
|
||||
version: getVersion(),
|
||||
uuid: null
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("Device", module.exports);
|
30
cordova/plugins/cordova-plugin-device/src/ios/CDVDevice.h
Normal file
30
cordova/plugins/cordova-plugin-device/src/ios/CDVDevice.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
|
||||
@interface CDVDevice : CDVPlugin
|
||||
{}
|
||||
|
||||
+ (NSString*)cordovaVersion;
|
||||
|
||||
- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
106
cordova/plugins/cordova-plugin-device/src/ios/CDVDevice.m
Normal file
106
cordova/plugins/cordova-plugin-device/src/ios/CDVDevice.m
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include "TargetConditionals.h"
|
||||
|
||||
#import <Cordova/CDV.h>
|
||||
#import "CDVDevice.h"
|
||||
|
||||
@implementation UIDevice (ModelVersion)
|
||||
|
||||
- (NSString*)modelVersion
|
||||
{
|
||||
size_t size;
|
||||
|
||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
||||
char* machine = malloc(size);
|
||||
sysctlbyname("hw.machine", machine, &size, NULL, 0);
|
||||
NSString* platform = [NSString stringWithUTF8String:machine];
|
||||
free(machine);
|
||||
|
||||
return platform;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface CDVDevice () {}
|
||||
@end
|
||||
|
||||
@implementation CDVDevice
|
||||
|
||||
- (NSString*)uniqueAppInstanceIdentifier:(UIDevice*)device
|
||||
{
|
||||
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
static NSString* UUID_KEY = @"CDVUUID";
|
||||
|
||||
// Check user defaults first to maintain backwards compaitibility with previous versions
|
||||
// which didn't user identifierForVendor
|
||||
NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
|
||||
if (app_uuid == nil) {
|
||||
app_uuid = [[device identifierForVendor] UUIDString];
|
||||
[userDefaults setObject:app_uuid forKey:UUID_KEY];
|
||||
[userDefaults synchronize];
|
||||
}
|
||||
|
||||
return app_uuid;
|
||||
}
|
||||
|
||||
- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSDictionary* deviceProperties = [self deviceProperties];
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
- (NSDictionary*)deviceProperties
|
||||
{
|
||||
UIDevice* device = [UIDevice currentDevice];
|
||||
NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
|
||||
|
||||
[devProps setObject:@"Apple" forKey:@"manufacturer"];
|
||||
[devProps setObject:[device modelVersion] forKey:@"model"];
|
||||
[devProps setObject:@"iOS" forKey:@"platform"];
|
||||
[devProps setObject:[device systemVersion] forKey:@"version"];
|
||||
[devProps setObject:[self uniqueAppInstanceIdentifier:device] forKey:@"uuid"];
|
||||
[devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
|
||||
[devProps setObject:@([self isVirtual]) forKey:@"isVirtual"];
|
||||
NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
|
||||
return devReturn;
|
||||
}
|
||||
|
||||
+ (NSString*)cordovaVersion
|
||||
{
|
||||
return CDV_VERSION;
|
||||
}
|
||||
|
||||
- (BOOL)isVirtual
|
||||
{
|
||||
#if TARGET_OS_SIMULATOR
|
||||
return true;
|
||||
#elif TARGET_IPHONE_SIMULATOR
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
39
cordova/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js
vendored
Normal file
39
cordova/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var tizen = require('cordova/platform');
|
||||
var cordova = require('cordova');
|
||||
|
||||
module.exports = {
|
||||
getDeviceInfo: function(success, error) {
|
||||
setTimeout(function () {
|
||||
success({
|
||||
cordova: tizen.cordovaVersion,
|
||||
platform: 'tizen',
|
||||
model: null,
|
||||
version: null,
|
||||
uuid: null
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
require("cordova/tizen/commandProxy").add("Device", module.exports);
|
64
cordova/plugins/cordova-plugin-device/src/ubuntu/device.cpp
Normal file
64
cordova/plugins/cordova-plugin-device/src/ubuntu/device.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2011 Wolfgang Koller - http://www.gofg.at/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <QDeviceInfo>
|
||||
#include <QtSystemInfo>
|
||||
|
||||
#include"device.h"
|
||||
|
||||
#define CORDOVA "3.0.0"
|
||||
|
||||
Device::Device(Cordova *cordova) : CPlugin(cordova) {
|
||||
}
|
||||
|
||||
static QString getOSName() {
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
QString platform = "Symbian";
|
||||
#endif
|
||||
#ifdef Q_OS_WIN
|
||||
QString platform = "Windows";
|
||||
#endif
|
||||
#ifdef Q_OS_WINCE
|
||||
QString platform = "Windows CE";
|
||||
#endif
|
||||
#ifdef Q_OS_LINUX
|
||||
QString platform = "Linux";
|
||||
#endif
|
||||
return platform;
|
||||
}
|
||||
|
||||
void Device::getInfo(int scId, int ecId) {
|
||||
Q_UNUSED(ecId)
|
||||
|
||||
QDeviceInfo systemDeviceInfo;
|
||||
QDeviceInfo systemInfo;
|
||||
|
||||
QString platform = getOSName();
|
||||
|
||||
QString uuid = systemDeviceInfo.uniqueDeviceID();
|
||||
if (uuid.isEmpty()) {
|
||||
QString deviceDescription = systemInfo.imei(0) + ";" + systemInfo.manufacturer() + ";" + systemInfo.model() + ";" + systemInfo.productName() + ";" + platform;
|
||||
QString user = qgetenv("USER");
|
||||
if (user.isEmpty()) {
|
||||
user = qgetenv("USERNAME");
|
||||
if (user.isEmpty())
|
||||
user = QDir::homePath();
|
||||
}
|
||||
uuid = QString(QCryptographicHash::hash((deviceDescription + ";" + user).toUtf8(), QCryptographicHash::Md5).toHex());
|
||||
}
|
||||
|
||||
this->cb(scId, systemDeviceInfo.model(), CORDOVA, platform, uuid, systemInfo.version(QDeviceInfo::Os));
|
||||
}
|
47
cordova/plugins/cordova-plugin-device/src/ubuntu/device.h
Normal file
47
cordova/plugins/cordova-plugin-device/src/ubuntu/device.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2011 Wolfgang Koller - http://www.gofg.at/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DEVICE_H_FDSAFAS
|
||||
#define DEVICE_H_FDSAFAS
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
#include <cplugin.h>
|
||||
|
||||
class Device: public CPlugin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Device(Cordova *cordova);
|
||||
|
||||
virtual const QString fullName() override {
|
||||
return Device::fullID();
|
||||
}
|
||||
|
||||
virtual const QString shortName() override {
|
||||
return "Device";
|
||||
}
|
||||
|
||||
static const QString fullID() {
|
||||
return "com.cordova.Device";
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void getInfo(int scId, int ecId);
|
||||
};
|
||||
|
||||
#endif
|
34
cordova/plugins/cordova-plugin-device/src/ubuntu/device.js
vendored
Normal file
34
cordova/plugins/cordova-plugin-device/src/ubuntu/device.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var cordova = require('cordova');
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
module.exports = {
|
||||
getInfo:function(win,fail,args) {
|
||||
Cordova.exec(function (model, cordova, platform, uuid, version) {
|
||||
win({name: name, model: model, cordova: cordova,
|
||||
platform: platform, uuid: uuid, version: version});
|
||||
}, null, "com.cordova.Device", "getInfo", []);
|
||||
}
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("Device", module.exports);
|
96
cordova/plugins/cordova-plugin-device/src/windows/DeviceProxy.js
vendored
Normal file
96
cordova/plugins/cordova-plugin-device/src/windows/DeviceProxy.js
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var ROOT_CONTAINER = "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}";
|
||||
var DEVICE_CLASS_KEY = "{A45C254E-DF1C-4EFD-8020-67D146A850E0},10";
|
||||
var DEVICE_CLASS_KEY_NO_SEMICOLON = '{A45C254E-DF1C-4EFD-8020-67D146A850E0}10';
|
||||
var ROOT_CONTAINER_QUERY = "System.Devices.ContainerId:=\"" + ROOT_CONTAINER + "\"";
|
||||
var HAL_DEVICE_CLASS = "4d36e966-e325-11ce-bfc1-08002be10318";
|
||||
var DEVICE_DRIVER_VERSION_KEY = "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3";
|
||||
|
||||
module.exports = {
|
||||
|
||||
getDeviceInfo:function(win, fail, args) {
|
||||
|
||||
// deviceId aka uuid, stored in Windows.Storage.ApplicationData.current.localSettings.values.deviceId
|
||||
var deviceId;
|
||||
// get deviceId, or create and store one
|
||||
var localSettings = Windows.Storage.ApplicationData.current.localSettings;
|
||||
if (localSettings.values.deviceId) {
|
||||
deviceId = localSettings.values.deviceId;
|
||||
}
|
||||
else {
|
||||
// App-specific hardware id could be used as uuid, but it changes if the hardware changes...
|
||||
try {
|
||||
var ASHWID = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(null).id;
|
||||
deviceId = Windows.Storage.Streams.DataReader.fromBuffer(ASHWID).readGuid();
|
||||
} catch (e) {
|
||||
// Couldn't get the hardware UUID
|
||||
deviceId = createUUID();
|
||||
}
|
||||
//...so cache it per-install
|
||||
localSettings.values.deviceId = deviceId;
|
||||
}
|
||||
|
||||
|
||||
var userAgent = window.clientInformation.userAgent;
|
||||
// this will report "windows" in windows8.1 and windows phone 8.1 apps
|
||||
// and "windows8" in windows 8.0 apps similar to cordova.js
|
||||
// See https://github.com/apache/cordova-js/blob/master/src/windows/platform.js#L25
|
||||
var devicePlatform = userAgent.indexOf("MSAppHost/1.0") == -1 ? "windows" : "windows8";
|
||||
var versionString = userAgent.match(/Windows (?:Phone |NT )?([0-9.]+)/)[1];
|
||||
|
||||
var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
|
||||
// Running in the Windows Simulator is a remote session.
|
||||
// Running in the Windows Phone Emulator has the systemProductName set to "Virtual"
|
||||
var isVirtual = Windows.System.RemoteDesktop.InteractiveSession.isRemote || deviceInfo.systemProductName == "Virtual";
|
||||
var manufacturer = deviceInfo.systemManufacturer;
|
||||
var model = deviceInfo.systemProductName;
|
||||
|
||||
var Pnp = Windows.Devices.Enumeration.Pnp;
|
||||
|
||||
Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.device,
|
||||
[DEVICE_DRIVER_VERSION_KEY, DEVICE_CLASS_KEY],
|
||||
ROOT_CONTAINER_QUERY)
|
||||
.then(function (rootDevices) {
|
||||
for (var i = 0; i < rootDevices.length; i++) {
|
||||
var rootDevice = rootDevices[i];
|
||||
if (!rootDevice.properties) continue;
|
||||
if (rootDevice.properties[DEVICE_CLASS_KEY_NO_SEMICOLON] == HAL_DEVICE_CLASS) {
|
||||
versionString = rootDevice.properties[DEVICE_DRIVER_VERSION_KEY];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
win({ platform: devicePlatform,
|
||||
version: versionString,
|
||||
uuid: deviceId,
|
||||
isVirtual: isVirtual,
|
||||
model: model,
|
||||
manufacturer:manufacturer});
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
|
||||
}; // exports
|
||||
|
||||
require("cordova/exec/proxy").add("Device", module.exports);
|
87
cordova/plugins/cordova-plugin-device/src/wp/Device.cs
Normal file
87
cordova/plugins/cordova-plugin-device/src/wp/Device.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
using Microsoft.Phone.Info;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.IsolatedStorage;
|
||||
|
||||
namespace WPCordovaClassLib.Cordova.Commands
|
||||
{
|
||||
public class Device : BaseCommand
|
||||
{
|
||||
public void getDeviceInfo(string notused)
|
||||
{
|
||||
string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\",\"manufacturer\":\"{5}\",\"isVirtual\":{6}",
|
||||
DeviceStatus.DeviceName,
|
||||
Environment.OSVersion.Platform.ToString(),
|
||||
UUID,
|
||||
Environment.OSVersion.Version.ToString(),
|
||||
DeviceStatus.DeviceName,
|
||||
DeviceStatus.DeviceManufacturer,
|
||||
IsVirtual ? "true" : "false");
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "{" + res + "}"));
|
||||
}
|
||||
|
||||
|
||||
public bool IsVirtual
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator);
|
||||
}
|
||||
}
|
||||
|
||||
public string UUID
|
||||
{
|
||||
get
|
||||
{
|
||||
object id;
|
||||
|
||||
UserExtendedProperties.TryGetValue("ANID", out id);
|
||||
if (id != null)
|
||||
{
|
||||
return id.ToString().Substring(2, 32);
|
||||
}
|
||||
|
||||
UserExtendedProperties.TryGetValue("ANID2", out id);
|
||||
if (id != null)
|
||||
{
|
||||
return id.ToString();
|
||||
}
|
||||
|
||||
string returnVal = "???unknown???";
|
||||
|
||||
using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
|
||||
{
|
||||
try
|
||||
{
|
||||
IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage);
|
||||
|
||||
using (StreamReader reader = new StreamReader(fileStream))
|
||||
{
|
||||
returnVal = reader.ReadLine();
|
||||
}
|
||||
}
|
||||
catch (Exception /*ex*/)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
cordova/plugins/cordova-plugin-device/tests/plugin.xml
Normal file
31
cordova/plugins/cordova-plugin-device/tests/plugin.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-device-tests"
|
||||
version="1.1.0">
|
||||
<name>Cordova Device Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
<js-module src="tests.js" name="tests">
|
||||
</js-module>
|
||||
</plugin>
|
111
cordova/plugins/cordova-plugin-device/tests/tests.js
vendored
Normal file
111
cordova/plugins/cordova-plugin-device/tests/tests.js
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
exports.defineAutoTests = function() {
|
||||
describe('Device Information (window.device)', function () {
|
||||
it("should exist", function() {
|
||||
expect(window.device).toBeDefined();
|
||||
});
|
||||
|
||||
it("should contain a platform specification that is a string", function() {
|
||||
expect(window.device.platform).toBeDefined();
|
||||
expect((new String(window.device.platform)).length > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("should contain a version specification that is a string", function() {
|
||||
expect(window.device.version).toBeDefined();
|
||||
expect((new String(window.device.version)).length > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("should contain a UUID specification that is a string or a number", function() {
|
||||
expect(window.device.uuid).toBeDefined();
|
||||
if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') {
|
||||
expect((new String(window.device.uuid)).length > 0).toBe(true);
|
||||
} else {
|
||||
expect(window.device.uuid > 0).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("should contain a cordova specification that is a string", function() {
|
||||
expect(window.device.cordova).toBeDefined();
|
||||
expect((new String(window.device.cordova)).length > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("should depend on the presence of cordova.version string", function() {
|
||||
expect(window.cordova.version).toBeDefined();
|
||||
expect((new String(window.cordova.version)).length > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("should contain device.cordova equal to cordova.version", function() {
|
||||
expect(window.device.cordova).toBe(window.cordova.version);
|
||||
});
|
||||
|
||||
it("should contain a model specification that is a string", function() {
|
||||
expect(window.device.model).toBeDefined();
|
||||
expect((new String(window.device.model)).length > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("should contain a manufacturer property that is a string", function() {
|
||||
expect(window.device.manufacturer).toBeDefined();
|
||||
expect((new String(window.device.manufacturer)).length > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("should contain an isVirtual property that is a boolean", function() {
|
||||
expect(window.device.isVirtual).toBeDefined();
|
||||
expect(typeof window.device.isVirtual).toBe("boolean");
|
||||
});
|
||||
|
||||
it("should contain a serial number specification that is a string", function() {
|
||||
expect(window.device.serial).toBeDefined();
|
||||
expect((new String(window.device.serial)).length > 0).toBe(true);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
exports.defineManualTests = function(contentEl, createActionButton) {
|
||||
var logMessage = function (message, color) {
|
||||
var log = document.getElementById('info');
|
||||
var logLine = document.createElement('div');
|
||||
if (color) {
|
||||
logLine.style.color = color;
|
||||
}
|
||||
logLine.innerHTML = message;
|
||||
log.appendChild(logLine);
|
||||
}
|
||||
|
||||
var clearLog = function () {
|
||||
var log = document.getElementById('info');
|
||||
log.innerHTML = '';
|
||||
}
|
||||
|
||||
var device_tests = '<h3>Press Dump Device button to get device information</h3>' +
|
||||
'<div id="dump_device"></div>' +
|
||||
'Expected result: Status box will get updated with device info. (i.e. platform, version, uuid, model, etc)';
|
||||
|
||||
contentEl.innerHTML = '<div id="info"></div>' + device_tests;
|
||||
|
||||
createActionButton('Dump device', function() {
|
||||
clearLog();
|
||||
logMessage(JSON.stringify(window.device, null, '\t'));
|
||||
}, "dump_device");
|
||||
};
|
83
cordova/plugins/cordova-plugin-device/www/device.js
vendored
Normal file
83
cordova/plugins/cordova-plugin-device/www/device.js
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
channel = require('cordova/channel'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec'),
|
||||
cordova = require('cordova');
|
||||
|
||||
channel.createSticky('onCordovaInfoReady');
|
||||
// Tell cordova channel to wait on the CordovaInfoReady event
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device() {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
this.model = null;
|
||||
this.manufacturer = null;
|
||||
this.isVirtual = null;
|
||||
this.serial = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
me.getInfo(function(info) {
|
||||
//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
|
||||
var buildLabel = cordova.version;
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = buildLabel;
|
||||
me.model = info.model;
|
||||
me.isVirtual = info.isVirtual;
|
||||
me.manufacturer = info.manufacturer || 'unknown';
|
||||
me.serial = info.serial || 'unknown';
|
||||
channel.onCordovaInfoReady.fire();
|
||||
},function(e) {
|
||||
me.available = false;
|
||||
utils.alert("[ERROR] Error initializing Cordova: " + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
|
||||
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
@@ -0,0 +1,44 @@
|
||||
## ChangeLog
|
||||
#### Version 0.6.4 (03.03.2015)
|
||||
- Resolve possibly dependency conflict
|
||||
|
||||
#### Version 0.6.3 (01.01.2015)
|
||||
- [feature:] Silent mode for Android
|
||||
|
||||
#### Version 0.6.2 (14.12.2014)
|
||||
- [bugfix:] Type error
|
||||
- [bugfix:] Wrong default values for `isEnabled` and `isActive`.
|
||||
|
||||
#### Version 0.6.1 (14.12.2014)
|
||||
- [enhancement:] Set default settings through `setDefaults`.
|
||||
- [enhancement:] New method `isEnabled` to receive if mode is enabled.
|
||||
- [enhancement:] New method `isActive` to receive if mode is active.
|
||||
- [bugfix:] Events caused thread collision.
|
||||
|
||||
|
||||
#### Version 0.6.0 (14.12.2014)
|
||||
- [feature:] Android support
|
||||
- [feature:] Change Android notification through `configure`.
|
||||
- [feature:] `onactivate`, `ondeactivate` and `onfailure` callbacks.
|
||||
- [___change___:] Disabled by default
|
||||
- [enhancement:] Get default settings through `getDefaults`.
|
||||
- [enhancement:] iOS does not require user permissions, internet connection and geo location anymore.
|
||||
|
||||
#### Version 0.5.0 (13.02.2014)
|
||||
- __retired__
|
||||
|
||||
#### Version 0.4.1 (13.02.2014)
|
||||
- Release under the Apache 2.0 license.
|
||||
- [enhancement:] Location tracking is only activated on WP8 if the location service is available.
|
||||
- [bigfix:] Nullpointer exception on WP8.
|
||||
|
||||
#### Version 0.4.0 (10.10.2013)
|
||||
- Added WP8 support<br>
|
||||
The plugin turns the app into an location tracking app *(for the time it runs in the background)*.
|
||||
|
||||
#### Version 0.2.1 (09.10.2013)
|
||||
- Added js interface to manually enable/disable the background mode.
|
||||
|
||||
#### Version 0.2.0 (08.10.2013)
|
||||
- Added iOS (>= 5) support<br>
|
||||
The plugin turns the app into an location tracking app for the time it runs in the background.
|
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@@ -0,0 +1,273 @@
|
||||
|
||||
<p align="right">
|
||||
<a href="https://github.com/katzer/cordova-plugin-background-mode/tree/example">EXAMPLE :point_right:</a>
|
||||
</p>
|
||||
|
||||
Cordova Background Plug-in
|
||||
==========================
|
||||
|
||||
[Cordova][cordova] plugin to prevent the app from going to sleep while in background.
|
||||
|
||||
Most mobile operating systems are multitasking capable, but most apps dont need to run while in background and not present for the user. Therefore they pause the app in background mode and resume the app before switching to foreground mode.
|
||||
The system keeps all network connections open while in background, but does not deliver the data until the app resumes.
|
||||
|
||||
### Plugin's Purpose
|
||||
This cordova plug-in can be used for applications, who rely on continuous network communication independent of from direct user interactions and remote push notifications.
|
||||
|
||||
### :bangbang: Store Compliance :bangbang:
|
||||
The plugin focuses on enterprise-only distribution and may not compliant with all public store vendors.
|
||||
|
||||
|
||||
## Overview
|
||||
1. [Supported Platforms](#supported-platforms)
|
||||
2. [Installation](#installation)
|
||||
3. [ChangeLog](#changelog)
|
||||
4. [Usage](#usage)
|
||||
5. [Examples](#examples)
|
||||
6. [Platform specifics](#platform-specifics)
|
||||
|
||||
|
||||
## Supported Platforms
|
||||
- __iOS__ (_including iOS8_)
|
||||
- __Android__ _(SDK >=11)_
|
||||
- __WP8__
|
||||
|
||||
|
||||
## Installation
|
||||
The plugin can either be installed from git repository, from local file system through the [Command-line Interface][CLI]. Or cloud based through [PhoneGap Build][PGB].
|
||||
|
||||
### Local development environment
|
||||
From master:
|
||||
```bash
|
||||
# ~~ from master branch ~~
|
||||
cordova plugin add https://github.com/katzer/cordova-plugin-background-mode.git
|
||||
```
|
||||
from a local folder:
|
||||
```bash
|
||||
# ~~ local folder ~~
|
||||
cordova plugin add de.appplant.cordova.plugin.background-mode --searchpath path
|
||||
```
|
||||
or to use the last stable version:
|
||||
```bash
|
||||
# ~~ stable version ~~
|
||||
cordova plugin add de.appplant.cordova.plugin.background-mode@0.6.3
|
||||
```
|
||||
|
||||
To remove the plug-in, run the following command:
|
||||
```bash
|
||||
cordova plugin rm de.appplant.cordova.plugin.background-mode
|
||||
```
|
||||
|
||||
### PhoneGap Build
|
||||
Add the following xml to your config.xml to always use the latest version of this plugin:
|
||||
```xml
|
||||
<gap:plugin name="de.appplant.cordova.plugin.background-mode" version="0.6.3" />
|
||||
```
|
||||
|
||||
More informations can be found [here][PGB_plugin].
|
||||
|
||||
|
||||
## ChangeLog
|
||||
#### Version 0.6.4 (03.03.2015)
|
||||
- Resolve possibly dependency conflict
|
||||
|
||||
#### Version 0.6.3 (01.01.2015)
|
||||
- [feature:] Silent mode for Android
|
||||
|
||||
#### Version 0.6.2 (14.12.2014)
|
||||
- [bugfix:] Type error
|
||||
- [bugfix:] Wrong default values for `isEnabled` and `isActive`.
|
||||
|
||||
#### Further informations
|
||||
- The former `plugin.backgroundMode` namespace has been deprecated and will be removed with the next major release.
|
||||
- See [CHANGELOG.md][changelog] to get the full changelog for the plugin.
|
||||
|
||||
#### Known issues
|
||||
- Plug-in is broken on Windows Phone 8.1 platform.
|
||||
|
||||
|
||||
## Usage
|
||||
The plugin creates the object `cordova.plugins.backgroundMode` with the following methods:
|
||||
|
||||
1. [backgroundMode.enable][enable]
|
||||
2. [backgroundMode.disable][disable]
|
||||
3. [backgroundMode.isEnabled][is_enabled]
|
||||
4. [backgroundMode.isActive][is_active]
|
||||
5. [backgroundMode.getDefaults][android_specifics]
|
||||
6. [backgroundMode.setDefaults][android_specifics]
|
||||
7. [backgroundMode.configure][configure]
|
||||
8. [backgroundMode.onactivate][onactivate]
|
||||
9. [backgroundMode.ondeactivate][ondeactivate]
|
||||
10. [backgroundMode.onfailure][onfailure]
|
||||
|
||||
### Plugin initialization
|
||||
The plugin and its methods are not available before the *deviceready* event has been fired.
|
||||
|
||||
```javascript
|
||||
document.addEventListener('deviceready', function () {
|
||||
// cordova.plugins.backgroundMode is now available
|
||||
}, false);
|
||||
```
|
||||
|
||||
### Prevent the app from going to sleep in background
|
||||
To prevent the app from being paused while in background, the `backroundMode.enable` interface has to be called.
|
||||
|
||||
#### Further informations
|
||||
- The background mode will be activated once the app has entered the background and will be deactivated after the app has entered the foreground.
|
||||
- To activate the background mode the app needs to be in foreground.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.enable();
|
||||
```
|
||||
|
||||
### Pause the app while in background
|
||||
The background mode can be disabled through the `backgroundMode.disable` interface.
|
||||
|
||||
#### Further informations
|
||||
- Once the background mode has been disabled, the app will be paused when in background.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.disable();
|
||||
```
|
||||
|
||||
### Receive if the background mode is enabled
|
||||
The `backgroundMode.isEnabled` interface can be used to get the information if the background mode is enabled or disabled.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.isEnabled(); // => boolean
|
||||
```
|
||||
|
||||
### Receive if the background mode is active
|
||||
The `backgroundMode.isActive` interface can be used to get the information if the background mode is active.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.isActive(); // => boolean
|
||||
```
|
||||
|
||||
### Get informed when the background mode has been activated
|
||||
The `backgroundMode.onactivate` interface can be used to get notified when the background mode has been activated.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.onactivate = function() {};
|
||||
```
|
||||
|
||||
### Get informed when the background mode has been deactivated
|
||||
The `backgroundMode.ondeactivate` interface can be used to get notified when the background mode has been deactivated.
|
||||
|
||||
#### Further informations
|
||||
- Once the mode has been deactivated the app will be paused soon after the callback has been fired.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.ondeactivate = function() {};
|
||||
```
|
||||
|
||||
### Get informed when the background mode could not been activated
|
||||
The `backgroundMode.onfailure` interface can be used to get notified when the background mode could not been activated.
|
||||
|
||||
The listener has to be a function and takes the following arguments:
|
||||
- errorCode: Error code which describes the error
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.onfailure = function(errorCode) {};
|
||||
```
|
||||
|
||||
|
||||
## Examples
|
||||
The following example demonstrates how to enable the background mode after device is ready. The mode itself will be activated when the app has entered the background.
|
||||
|
||||
```javascript
|
||||
document.addEventListener('deviceready', function () {
|
||||
// Android customization
|
||||
cordova.plugins.backgroundMode.setDefaults({ text:'Doing heavy tasks.'});
|
||||
// Enable background mode
|
||||
cordova.plugins.backgroundMode.enable();
|
||||
|
||||
// Called when background mode has been activated
|
||||
cordova.plugins.backgroundMode.onactivate = function () {
|
||||
setTimeout(function () {
|
||||
// Modify the currently displayed notification
|
||||
cordova.plugins.backgroundMode.configure({
|
||||
text:'Running in background for more than 5s now.'
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
}, false);
|
||||
```
|
||||
|
||||
|
||||
## Platform specifics
|
||||
|
||||
### Android customization
|
||||
To indicate that the app is executing tasks in background and being paused would disrupt the user, the plug-in has to create a notification while in background - like a download progress bar.
|
||||
|
||||
#### Override defaults
|
||||
The title, ticker and text for that notification can be customized as follows:
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.setDefaults({
|
||||
title: String,
|
||||
ticker: String,
|
||||
text: String
|
||||
})
|
||||
```
|
||||
|
||||
By default the app will come to foreground when taping on the notification. That can be changed also.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.setDefaults({
|
||||
resume: false
|
||||
})
|
||||
```
|
||||
|
||||
#### Modify the currently displayed notification
|
||||
It's also possible to modify the currently displayed notification while in background.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.configure({
|
||||
title: String,
|
||||
...
|
||||
})
|
||||
```
|
||||
|
||||
#### Run in background without notification
|
||||
In silent mode the plugin will not display a notification - which is not the default. Be aware that Android recommends adding a notification otherwise the OS may pause the app.
|
||||
|
||||
```javascript
|
||||
cordova.plugins.backgroundMode.configure({
|
||||
silent: true
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork it
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||
4. Push to the branch (`git push origin my-new-feature`)
|
||||
5. Create new Pull Request
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This software is released under the [Apache 2.0 License][apache2_license].
|
||||
|
||||
© 2013-2014 appPlant UG, Inc. All rights reserved
|
||||
|
||||
|
||||
[cordova]: https://cordova.apache.org
|
||||
[CLI]: http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface
|
||||
[PGB]: http://docs.build.phonegap.com/en_US/index.html
|
||||
[PGB_plugin]: https://build.phonegap.com/plugins/2056
|
||||
[changelog]: CHANGELOG.md
|
||||
[enable]: #prevent-the-app-from-going-to-sleep-in-background
|
||||
[disable]: #pause-the-app-while-in-background
|
||||
[is_enabled]: #receive-if-the-background-mode-is-enabled
|
||||
[is_active]: #receive-if-the-background-mode-is-active
|
||||
[android_specifics]: #android-customization
|
||||
[configure]: #modify-the-currently-displayed-notification
|
||||
[onactivate]: #get-informed-when-the-background-mode-has-been-activated
|
||||
[ondeactivate]: #get-informed-when-the-background-mode-has-been-deactivated
|
||||
[onfailure]: #get-informed-when-the-background-mode-could-not-been-activated
|
||||
[apache2_license]: http://opensource.org/licenses/Apache-2.0
|
||||
[appplant]: http://appplant.de
|
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "de.appplant.cordova.plugin.background-mode",
|
||||
"version": "0.6.4",
|
||||
"description": "Cordova plugin to prevent the app from going to sleep in background.",
|
||||
"cordova": {
|
||||
"id": "de.appplant.cordova.plugin.background-mode",
|
||||
"platforms": [
|
||||
"ios",
|
||||
"android",
|
||||
"wp8"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/katzer/cordova-plugin-background-mode.git"
|
||||
},
|
||||
"keywords": [
|
||||
"appplant",
|
||||
"background",
|
||||
"mode",
|
||||
"background-mode",
|
||||
"katzer",
|
||||
"ecosystem:cordova",
|
||||
"cordova-ios",
|
||||
"cordova-android",
|
||||
"cordova-wp8"
|
||||
],
|
||||
"engines": [
|
||||
{
|
||||
"name": "cordova",
|
||||
"version": ">=3.0.0"
|
||||
}
|
||||
],
|
||||
"author": "Sebastián Katzer",
|
||||
"license": "Apache 2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/katzer/cordova-plugin-background-mode/issues"
|
||||
},
|
||||
"homepage": "https://github.com/katzer/cordova-plugin-background-mode"
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="de.appplant.cordova.plugin.background-mode"
|
||||
version="0.6.4">
|
||||
|
||||
<name>BackgroundMode</name>
|
||||
|
||||
<description>
|
||||
Cordova plugin to prevent the app from going to sleep in background.
|
||||
</description>
|
||||
|
||||
<repo>https://github.com/katzer/cordova-plugin-background-mode.git</repo>
|
||||
|
||||
<keywords>appplant, background</keywords>
|
||||
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
<author>Sebastián Katzer</author>
|
||||
|
||||
<!-- dependencies -->
|
||||
<dependency id="org.apache.cordova.device" />
|
||||
|
||||
<!-- cordova -->
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.0.0" />
|
||||
</engines>
|
||||
|
||||
<!-- js -->
|
||||
<js-module src="www/background-mode.js" name="BackgroundMode">
|
||||
<clobbers target="cordova.plugins.backgroundMode" />
|
||||
<clobbers target="plugin.backgroundMode" />
|
||||
</js-module>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="BackgroundMode">
|
||||
<param name="ios-package" value="APPBackgroundMode" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<!-- The app is able to run in background through audio mode -->
|
||||
<config-file target="*-Info.plist" parent="UIBackgroundModes">
|
||||
<array>
|
||||
<string>audio</string>
|
||||
</array>
|
||||
</config-file>
|
||||
|
||||
<resource-file src="appbeep.wav" />
|
||||
|
||||
<header-file src="src/ios/APPBackgroundMode.h" />
|
||||
<source-file src="src/ios/APPBackgroundMode.m" />
|
||||
</platform>
|
||||
|
||||
<!-- android -->
|
||||
<platform name="android">
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="BackgroundMode" >
|
||||
<param name="android-package"
|
||||
value="de.appplant.cordova.plugin.background.BackgroundMode"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<preference name="KeepRunning" value="true" />
|
||||
</config-file>
|
||||
|
||||
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
||||
<!--
|
||||
* Puts the service in a foreground state, where the system considers
|
||||
* it to be something the user is actively aware of and thus not a
|
||||
* candidate for killing when low on memory.
|
||||
-->
|
||||
<service android:name="de.appplant.cordova.plugin.background.ForegroundService" />
|
||||
|
||||
</config-file>
|
||||
|
||||
<source-file
|
||||
src="src/android/BackgroundMode.java"
|
||||
target-dir="src/de/appplant/cordova/plugin/background" />
|
||||
|
||||
<source-file
|
||||
src="src/android/ForegroundService.java"
|
||||
target-dir="src/de/appplant/cordova/plugin/background" />
|
||||
|
||||
</platform>
|
||||
|
||||
<!-- wp8 -->
|
||||
<platform name="wp8">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="BackgroundMode">
|
||||
<param name="wp-package" value="BackgroundMode" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<!-- The app is able to run in background through location-tracking mode -->
|
||||
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Tasks/DefaultTask">
|
||||
<BackgroundExecution>
|
||||
<ExecutionType Name="LocationTracking" />
|
||||
</BackgroundExecution>
|
||||
</config-file>
|
||||
|
||||
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||
<Capability Name="ID_CAP_LOCATION" />
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/wp8/BackgroundMode.cs" />
|
||||
</platform>
|
||||
</plugin>
|
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
package de.appplant.cordova.plugin.background;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
|
||||
public class BackgroundMode extends CordovaPlugin {
|
||||
|
||||
// Event types for callbacks
|
||||
private enum Event {
|
||||
ACTIVATE, DEACTIVATE, FAILURE
|
||||
}
|
||||
|
||||
// Plugin namespace
|
||||
private static final String JS_NAMESPACE = "cordova.plugins.backgroundMode";
|
||||
|
||||
// Flag indicates if the app is in background or foreground
|
||||
private boolean inBackground = false;
|
||||
|
||||
// Flag indicates if the plugin is enabled or disabled
|
||||
private boolean isDisabled = true;
|
||||
|
||||
// Flag indicates if the service is bind
|
||||
private boolean isBind = false;
|
||||
|
||||
// Default settings for the notification
|
||||
private static JSONObject defaultSettings = new JSONObject();
|
||||
|
||||
// Tmp config settings for the notification
|
||||
private static JSONObject updateSettings;
|
||||
|
||||
// Used to (un)bind the service to with the activity
|
||||
private final ServiceConnection connection = new ServiceConnection() {
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
// Nothing to do here
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the request.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args The exec() arguments.
|
||||
* @param callback The callback context used when
|
||||
* calling back into JavaScript.
|
||||
*
|
||||
* @return
|
||||
* Returning false results in a "MethodNotFound" error.
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
@Override
|
||||
public boolean execute (String action, JSONArray args,
|
||||
CallbackContext callback) throws JSONException {
|
||||
|
||||
if (action.equalsIgnoreCase("configure")) {
|
||||
JSONObject settings = args.getJSONObject(0);
|
||||
boolean update = args.getBoolean(1);
|
||||
|
||||
if (update) {
|
||||
setUpdateSettings(settings);
|
||||
updateNotifcation();
|
||||
} else {
|
||||
setDefaultSettings(settings);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("enable")) {
|
||||
enableMode();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("disable")) {
|
||||
disableMode();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the system is about to start resuming a previous activity.
|
||||
*
|
||||
* @param multitasking
|
||||
* Flag indicating if multitasking is turned on for app
|
||||
*/
|
||||
@Override
|
||||
public void onPause(boolean multitasking) {
|
||||
super.onPause(multitasking);
|
||||
inBackground = true;
|
||||
startService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity will start interacting with the user.
|
||||
*
|
||||
* @param multitasking
|
||||
* Flag indicating if multitasking is turned on for app
|
||||
*/
|
||||
@Override
|
||||
public void onResume(boolean multitasking) {
|
||||
super.onResume(multitasking);
|
||||
inBackground = false;
|
||||
stopService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity will be destroyed.
|
||||
*/
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
stopService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the background mode.
|
||||
*/
|
||||
private void enableMode() {
|
||||
isDisabled = false;
|
||||
|
||||
if (inBackground) {
|
||||
startService();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the background mode.
|
||||
*/
|
||||
private void disableMode() {
|
||||
stopService();
|
||||
isDisabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the default settings for the notification.
|
||||
*
|
||||
* @param settings
|
||||
* The new default settings
|
||||
*/
|
||||
private void setDefaultSettings(JSONObject settings) {
|
||||
defaultSettings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the config settings for the notification.
|
||||
*
|
||||
* @param settings
|
||||
* The tmp config settings
|
||||
*/
|
||||
private void setUpdateSettings(JSONObject settings) {
|
||||
updateSettings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings for the new/updated notification.
|
||||
*
|
||||
* @return
|
||||
* updateSettings if set or default settings
|
||||
*/
|
||||
protected static JSONObject getSettings() {
|
||||
if (updateSettings != null)
|
||||
return updateSettings;
|
||||
|
||||
return defaultSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by ForegroundService to delete the update settings.
|
||||
*/
|
||||
protected static void deleteUpdateSettings() {
|
||||
updateSettings = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the notification.
|
||||
*/
|
||||
private void updateNotifcation() {
|
||||
if (isBind) {
|
||||
stopService();
|
||||
startService();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind the activity to a background service and put them into foreground
|
||||
* state.
|
||||
*/
|
||||
private void startService() {
|
||||
Activity context = cordova.getActivity();
|
||||
|
||||
Intent intent = new Intent(
|
||||
context, ForegroundService.class);
|
||||
|
||||
if (isDisabled || isBind)
|
||||
return;
|
||||
|
||||
try {
|
||||
context.bindService(
|
||||
intent, connection, Context.BIND_AUTO_CREATE);
|
||||
|
||||
fireEvent(Event.ACTIVATE, null);
|
||||
|
||||
context.startService(intent);
|
||||
} catch (Exception e) {
|
||||
fireEvent(Event.FAILURE, e.getMessage());
|
||||
}
|
||||
|
||||
isBind = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind the activity to a background service and put them into foreground
|
||||
* state.
|
||||
*/
|
||||
private void stopService() {
|
||||
Activity context = cordova.getActivity();
|
||||
|
||||
Intent intent = new Intent(
|
||||
context, ForegroundService.class);
|
||||
|
||||
if (!isBind)
|
||||
return;
|
||||
|
||||
fireEvent(Event.DEACTIVATE, null);
|
||||
|
||||
context.unbindService(connection);
|
||||
context.stopService(intent);
|
||||
|
||||
isBind = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire vent with some parameters inside the web view.
|
||||
*
|
||||
* @param event
|
||||
* The name of the event
|
||||
* @param params
|
||||
* Optional arguments for the event
|
||||
*/
|
||||
private void fireEvent (Event event, String params) {
|
||||
String eventName;
|
||||
|
||||
if (updateSettings != null && event != Event.FAILURE)
|
||||
return;
|
||||
|
||||
switch (event) {
|
||||
case ACTIVATE:
|
||||
eventName = "activate"; break;
|
||||
case DEACTIVATE:
|
||||
eventName = "deactivate"; break;
|
||||
default:
|
||||
eventName = "failure";
|
||||
}
|
||||
|
||||
String active = event == Event.ACTIVATE ? "true" : "false";
|
||||
|
||||
String flag = String.format("%s._isActive=%s;",
|
||||
JS_NAMESPACE, active);
|
||||
|
||||
String fn = String.format("setTimeout('%s.on%s(%s)',0);",
|
||||
JS_NAMESPACE, eventName, params);
|
||||
|
||||
final String js = flag + fn;
|
||||
|
||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
webView.loadUrl("javascript:" + js);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
package de.appplant.cordova.plugin.background;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Puts the service in a foreground state, where the system considers it to be
|
||||
* something the user is actively aware of and thus not a candidate for killing
|
||||
* when low on memory.
|
||||
*/
|
||||
public class ForegroundService extends Service {
|
||||
|
||||
// Fixed ID for the 'foreground' notification
|
||||
private static final int NOTIFICATION_ID = -574543954;
|
||||
|
||||
// Scheduler to exec periodic tasks
|
||||
final Timer scheduler = new Timer();
|
||||
|
||||
// Used to keep the app alive
|
||||
TimerTask keepAliveTask;
|
||||
|
||||
/**
|
||||
* Allow clients to call on to the service.
|
||||
*/
|
||||
@Override
|
||||
public IBinder onBind (Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the service in a foreground state to prevent app from being killed
|
||||
* by the OS.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate () {
|
||||
super.onCreate();
|
||||
keepAwake();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
sleepWell();
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the service in a foreground state to prevent app from being killed
|
||||
* by the OS.
|
||||
*/
|
||||
public void keepAwake() {
|
||||
final Handler handler = new Handler();
|
||||
|
||||
if (!this.inSilentMode()) {
|
||||
startForeground(NOTIFICATION_ID, makeNotification());
|
||||
} else {
|
||||
Log.w("BackgroundMode", "In silent mode app may be paused by OS!");
|
||||
}
|
||||
|
||||
BackgroundMode.deleteUpdateSettings();
|
||||
|
||||
keepAliveTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Nothing to do here
|
||||
// Log.d("BackgroundMode", "" + new Date().getTime());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
scheduler.schedule(keepAliveTask, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop background mode.
|
||||
*/
|
||||
private void sleepWell() {
|
||||
stopForeground(true);
|
||||
keepAliveTask.cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a notification as the visible part to be able to put the service
|
||||
* in a foreground state.
|
||||
*
|
||||
* @return
|
||||
* A local ongoing notification which pending intent is bound to the
|
||||
* main activity.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressWarnings("deprecation")
|
||||
private Notification makeNotification() {
|
||||
JSONObject settings = BackgroundMode.getSettings();
|
||||
Context context = getApplicationContext();
|
||||
String pkgName = context.getPackageName();
|
||||
Intent intent = context.getPackageManager()
|
||||
.getLaunchIntentForPackage(pkgName);
|
||||
|
||||
Notification.Builder notification = new Notification.Builder(context)
|
||||
.setContentTitle(settings.optString("title", ""))
|
||||
.setContentText(settings.optString("text", ""))
|
||||
.setTicker(settings.optString("ticker", ""))
|
||||
.setOngoing(true)
|
||||
.setSmallIcon(getIconResId());
|
||||
|
||||
if (intent != null && settings.optBoolean("resume")) {
|
||||
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(
|
||||
context, NOTIFICATION_ID, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
notification.setContentIntent(contentIntent);
|
||||
}
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
// Build notification for HoneyComb to ICS
|
||||
return notification.getNotification();
|
||||
} else {
|
||||
// Notification for Jellybean and above
|
||||
return notification.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the resource ID of the app icon.
|
||||
*
|
||||
* @return
|
||||
* The resource ID of the app icon
|
||||
*/
|
||||
private int getIconResId() {
|
||||
Context context = getApplicationContext();
|
||||
Resources res = context.getResources();
|
||||
String pkgName = context.getPackageName();
|
||||
|
||||
int resId;
|
||||
resId = res.getIdentifier("icon", "drawable", pkgName);
|
||||
|
||||
return resId;
|
||||
}
|
||||
|
||||
/**
|
||||
* In silent mode no notification has to be added.
|
||||
*
|
||||
* @return
|
||||
* True if silent: was set to true
|
||||
*/
|
||||
private boolean inSilentMode() {
|
||||
JSONObject settings = BackgroundMode.getSettings();
|
||||
|
||||
return settings.optBoolean("silent", false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
|
||||
@interface APPBackgroundMode : CDVPlugin {
|
||||
AVAudioPlayer *audioPlayer;
|
||||
BOOL enabled;
|
||||
}
|
||||
|
||||
// Activate the background mode
|
||||
- (void) enable:(CDVInvokedUrlCommand *)command;
|
||||
// Deactivate the background mode
|
||||
- (void) disable:(CDVInvokedUrlCommand *)command;
|
||||
|
||||
@end
|
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import "APPBackgroundMode.h"
|
||||
|
||||
@implementation APPBackgroundMode
|
||||
|
||||
NSString *const kAPPBackgroundJsNamespace = @"cordova.plugins.backgroundMode";
|
||||
NSString *const kAPPBackgroundEventActivate = @"activate";
|
||||
NSString *const kAPPBackgroundEventDeactivate = @"deactivate";
|
||||
NSString *const kAPPBackgroundEventFailure = @"failure";
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Initialization methods
|
||||
|
||||
/**
|
||||
* Initialize the plugin.
|
||||
*/
|
||||
- (void) pluginInitialize
|
||||
{
|
||||
[self disable:NULL];
|
||||
[self configureAudioPlayer];
|
||||
[self configureAudioSession];
|
||||
[self observeLifeCycle];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the listener for pause and resume events.
|
||||
*/
|
||||
- (void) observeLifeCycle
|
||||
{
|
||||
NSNotificationCenter* listener = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
|
||||
|
||||
[listener addObserver:self
|
||||
selector:@selector(keepAwake)
|
||||
name:UIApplicationDidEnterBackgroundNotification
|
||||
object:nil];
|
||||
|
||||
[listener addObserver:self
|
||||
selector:@selector(stopKeepingAwake)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
|
||||
[listener addObserver:self
|
||||
selector:@selector(handleAudioSessionInterruption:)
|
||||
name:AVAudioSessionInterruptionNotification
|
||||
object:nil];
|
||||
|
||||
} else {
|
||||
[self enable:NULL];
|
||||
[self keepAwake];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Interface methods
|
||||
|
||||
/**
|
||||
* Enable the mode to stay awake
|
||||
* when switching to background for the next time.
|
||||
*/
|
||||
- (void) enable:(CDVInvokedUrlCommand *)command
|
||||
{
|
||||
enabled = YES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the background mode
|
||||
* and stop being active in background.
|
||||
*/
|
||||
- (void) disable:(CDVInvokedUrlCommand *)command
|
||||
{
|
||||
enabled = NO;
|
||||
|
||||
[self stopKeepingAwake];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Core methods
|
||||
|
||||
/**
|
||||
* Keep the app awake.
|
||||
*/
|
||||
- (void) keepAwake {
|
||||
if (enabled) {
|
||||
[audioPlayer play];
|
||||
[self fireEvent:kAPPBackgroundEventActivate withParams:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Let the app going to sleep.
|
||||
*/
|
||||
- (void) stopKeepingAwake {
|
||||
|
||||
if (TARGET_IPHONE_SIMULATOR) {
|
||||
NSLog(@"BackgroundMode: On simulator apps never pause in background!");
|
||||
}
|
||||
|
||||
if (audioPlayer.isPlaying) {
|
||||
[self fireEvent:kAPPBackgroundEventDeactivate withParams:NULL];
|
||||
}
|
||||
|
||||
[audioPlayer pause];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the audio player.
|
||||
*/
|
||||
- (void) configureAudioPlayer {
|
||||
NSString* path = [[NSBundle mainBundle] pathForResource:@"appbeep"
|
||||
ofType:@"wav"];
|
||||
|
||||
NSURL* url = [NSURL fileURLWithPath:path];
|
||||
|
||||
|
||||
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url
|
||||
error:NULL];
|
||||
|
||||
// Silent
|
||||
audioPlayer.volume = 0;
|
||||
// Infinite
|
||||
audioPlayer.numberOfLoops = -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Configure the audio session.
|
||||
*/
|
||||
- (void) configureAudioSession {
|
||||
AVAudioSession* session = [AVAudioSession
|
||||
sharedInstance];
|
||||
|
||||
// Play music even in background and dont stop playing music
|
||||
// even another app starts playing sound
|
||||
[session setCategory:AVAudioSessionCategoryPlayback
|
||||
withOptions:AVAudioSessionCategoryOptionMixWithOthers
|
||||
error:NULL];
|
||||
|
||||
[session setActive:YES error:NULL];
|
||||
};
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Helper methods
|
||||
|
||||
/**
|
||||
* Restart playing sound when interrupted by phone calls.
|
||||
*/
|
||||
- (void) handleAudioSessionInterruption:(NSNotification*)notification {
|
||||
[self fireEvent:kAPPBackgroundEventDeactivate withParams:NULL];
|
||||
[self keepAwake];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to fire an event with some parameters in the browser.
|
||||
*/
|
||||
- (void) fireEvent:(NSString*)event withParams:(NSString*)params
|
||||
{
|
||||
NSString* active = [event isEqualToString:kAPPBackgroundEventActivate] ? @"true" : @"false";
|
||||
|
||||
NSString* flag = [NSString stringWithFormat:@"%@._isActive=%@;",
|
||||
kAPPBackgroundJsNamespace, active];
|
||||
|
||||
NSString* fn = [NSString stringWithFormat:@"setTimeout('%@.on%@(%@)',0);",
|
||||
kAPPBackgroundJsNamespace, event, params];
|
||||
|
||||
NSString* js = [flag stringByAppendingString:fn];
|
||||
|
||||
[self.commandDelegate evalJs:js];
|
||||
}
|
||||
|
||||
@end
|
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
using WPCordovaClassLib.Cordova.Commands;
|
||||
using Windows.Devices.Geolocation;
|
||||
using Microsoft.Phone.Shell;
|
||||
using System;
|
||||
using WPCordovaClassLib.Cordova;
|
||||
|
||||
namespace Cordova.Extension.Commands
|
||||
{
|
||||
/// </summary>
|
||||
/// Ermöglicht, dass eine Anwendung im Hintergrund läuft ohne pausiert zu werden
|
||||
/// </summary>
|
||||
public class BackgroundMode : BaseCommand
|
||||
{
|
||||
/// </summary>
|
||||
/// Event types for callbacks
|
||||
/// </summary>
|
||||
enum Event {
|
||||
ACTIVATE, DEACTIVATE, FAILURE
|
||||
}
|
||||
|
||||
#region Instance variables
|
||||
|
||||
/// </summary>
|
||||
/// Flag indicates if the plugin is enabled or disabled
|
||||
/// </summary>
|
||||
private bool IsDisabled = true;
|
||||
|
||||
/// </summary>
|
||||
/// Geolocator to monitor location changes
|
||||
/// </summary>
|
||||
private static Geolocator Geolocator { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interface methods
|
||||
|
||||
/// </summary>
|
||||
/// Enable the mode to stay awake when switching
|
||||
/// to background for the next time.
|
||||
/// </summary>
|
||||
public void enable (string args)
|
||||
{
|
||||
IsDisabled = false;
|
||||
}
|
||||
|
||||
/// </summary>
|
||||
/// Disable the background mode and stop
|
||||
/// being active in background.
|
||||
/// </summary>
|
||||
public void disable (string args)
|
||||
{
|
||||
IsDisabled = true;
|
||||
|
||||
Deactivate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Core methods
|
||||
|
||||
/// </summary>
|
||||
/// Keep the app awake by tracking
|
||||
/// for position changes.
|
||||
/// </summary>
|
||||
private void Activate()
|
||||
{
|
||||
if (IsDisabled || Geolocator != null)
|
||||
return;
|
||||
|
||||
if (!IsServiceAvailable())
|
||||
{
|
||||
FireEvent(Event.FAILURE, null);
|
||||
return;
|
||||
}
|
||||
|
||||
Geolocator = new Geolocator();
|
||||
|
||||
Geolocator.DesiredAccuracy = PositionAccuracy.Default;
|
||||
Geolocator.MovementThreshold = 100000;
|
||||
Geolocator.PositionChanged += geolocator_PositionChanged;
|
||||
|
||||
FireEvent(Event.ACTIVATE, null);
|
||||
}
|
||||
|
||||
/// </summary>
|
||||
/// Let the app going to sleep.
|
||||
/// </summary>
|
||||
private void Deactivate ()
|
||||
{
|
||||
if (Geolocator == null)
|
||||
return;
|
||||
|
||||
FireEvent(Event.DEACTIVATE, null);
|
||||
|
||||
Geolocator.PositionChanged -= geolocator_PositionChanged;
|
||||
Geolocator = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper methods
|
||||
|
||||
/// </summary>
|
||||
/// Determine if location service is available and enabled.
|
||||
/// </summary>
|
||||
private bool IsServiceAvailable()
|
||||
{
|
||||
Geolocator geolocator = (Geolocator == null) ? new Geolocator() : Geolocator;
|
||||
|
||||
PositionStatus status = geolocator.LocationStatus;
|
||||
|
||||
if (status == PositionStatus.Disabled)
|
||||
return false;
|
||||
|
||||
if (status == PositionStatus.NotAvailable)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires the given event.
|
||||
/// </summary>
|
||||
private void FireEvent(Event Event, string Param)
|
||||
{
|
||||
string EventName;
|
||||
|
||||
switch (Event) {
|
||||
case Event.ACTIVATE:
|
||||
EventName = "activate"; break;
|
||||
case Event.DEACTIVATE:
|
||||
EventName = "deactivate"; break;
|
||||
default:
|
||||
EventName = "failure"; break;
|
||||
}
|
||||
|
||||
string js = String.Format("cordova.plugins.backgroundMode.on{0}({1})", EventName, Param);
|
||||
|
||||
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, js);
|
||||
|
||||
pluginResult.KeepCallback = true;
|
||||
|
||||
DispatchCommandResult(pluginResult);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Delegate methods
|
||||
|
||||
private void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lifecycle methods
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the application is being deactivated.
|
||||
/// </summary>
|
||||
public override void OnPause(object sender, DeactivatedEventArgs e)
|
||||
{
|
||||
Activate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the application is being made active after previously being put
|
||||
/// into a dormant state or tombstoned.
|
||||
/// </summary>
|
||||
public override void OnResume(object sender, ActivatedEventArgs e)
|
||||
{
|
||||
Deactivate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
|
||||
// Override back button action to prevent being killed
|
||||
document.addEventListener('backbutton', function () {}, false);
|
||||
|
||||
// Called before 'deviceready' listener will be called
|
||||
channel.onCordovaReady.subscribe(function () {
|
||||
// Device plugin is ready now
|
||||
channel.onCordovaInfoReady.subscribe(function () {
|
||||
// Set the defaults
|
||||
exports.setDefaults({});
|
||||
});
|
||||
|
||||
// Only enable WP8 by default
|
||||
if (['WinCE', 'Win32NT'].indexOf(device.platform) > -1) {
|
||||
exports.enable();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Flag indicated if the mode is enabled.
|
||||
*/
|
||||
exports._isEnabled = false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Flag indicated if the mode is active.
|
||||
*/
|
||||
exports._isActive = false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Default values of all available options.
|
||||
*/
|
||||
exports._defaults = {
|
||||
title: 'App is running in background',
|
||||
text: 'Doing heavy tasks.',
|
||||
ticker: 'App is running in background',
|
||||
resume: true,
|
||||
silent: false
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Activates the background mode. When activated the application
|
||||
* will be prevented from going to sleep while in background
|
||||
* for the next time.
|
||||
*/
|
||||
exports.enable = function () {
|
||||
this._isEnabled = true;
|
||||
cordova.exec(null, null, 'BackgroundMode', 'enable', []);
|
||||
};
|
||||
|
||||
/**
|
||||
* Deactivates the background mode. When deactivated the application
|
||||
* will not stay awake while in background.
|
||||
*/
|
||||
exports.disable = function () {
|
||||
this._isEnabled = false;
|
||||
cordova.exec(null, null, 'BackgroundMode', 'disable', []);
|
||||
};
|
||||
|
||||
/**
|
||||
* List of all available options with their default value.
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
exports.getDefaults = function () {
|
||||
return this._defaults;
|
||||
};
|
||||
|
||||
/**
|
||||
* Overwrite default settings
|
||||
*
|
||||
* @param {Object} overrides
|
||||
* Dict of options which shall be overridden
|
||||
*/
|
||||
exports.setDefaults = function (overrides) {
|
||||
var defaults = this.getDefaults();
|
||||
|
||||
for (var key in defaults) {
|
||||
if (overrides.hasOwnProperty(key)) {
|
||||
defaults[key] = overrides[key];
|
||||
}
|
||||
}
|
||||
|
||||
if (device.platform == 'Android') {
|
||||
cordova.exec(null, null, 'BackgroundMode', 'configure', [defaults, false]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Configures the notification settings for Android.
|
||||
* Will be merged with the defaults.
|
||||
*
|
||||
* @param {Object} options
|
||||
* Dict with key/value pairs
|
||||
*/
|
||||
exports.configure = function (options) {
|
||||
var settings = this.mergeWithDefaults(options);
|
||||
|
||||
if (device.platform == 'Android') {
|
||||
cordova.exec(null, null, 'BackgroundMode', 'configure', [settings, true]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If the mode is enabled or disabled.
|
||||
*
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isEnabled = function () {
|
||||
return this._isEnabled;
|
||||
};
|
||||
|
||||
/**
|
||||
* If the mode is active.
|
||||
*
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isActive = function () {
|
||||
return this._isActive;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the background mode has been activated.
|
||||
*/
|
||||
exports.onactivate = function () {};
|
||||
|
||||
/**
|
||||
* Called when the background mode has been deaktivated.
|
||||
*/
|
||||
exports.ondeactivate = function () {};
|
||||
|
||||
/**
|
||||
* Called when the background mode could not been activated.
|
||||
*
|
||||
* @param {Integer} errorCode
|
||||
* Error code which describes the error
|
||||
*/
|
||||
exports.onfailure = function () {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Merge settings with default values.
|
||||
*
|
||||
* @param {Object} options
|
||||
* The custom options
|
||||
*
|
||||
* @return {Object}
|
||||
* Default values merged
|
||||
* with custom values
|
||||
*/
|
||||
exports.mergeWithDefaults = function (options) {
|
||||
var defaults = this.getDefaults();
|
||||
|
||||
for (var key in defaults) {
|
||||
if (!options.hasOwnProperty(key)) {
|
||||
options[key] = defaults[key];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
};
|
Reference in New Issue
Block a user