remove the plugin tree for testing
This commit is contained in:
parent
892cb0e141
commit
afa50236e2
424 changed files with 0 additions and 82953 deletions
|
@ -1,55 +0,0 @@
|
||||||
{
|
|
||||||
"prepare_queue": {
|
|
||||||
"installed": [],
|
|
||||||
"uninstalled": []
|
|
||||||
},
|
|
||||||
"config_munge": {
|
|
||||||
"files": {}
|
|
||||||
},
|
|
||||||
"installed_plugins": {
|
|
||||||
"cordova-plugin-filechooser": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-share-content": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"ionic-plugin-keyboard": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-file": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-file-transfer": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"com-darryncampbell-cordova-plugin-intent": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-inappbrowser": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-whitelist": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-statusbar": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-splashscreen": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-device": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-console": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-android-support-gradle-release": {
|
|
||||||
"ANDROID_SUPPORT_VERSION": "27.+",
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
},
|
|
||||||
"cordova-plugin-filepath": {
|
|
||||||
"PACKAGE_NAME": "com.monkeystew.goober_m"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dependent_plugins": {}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2017 Darryn
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -1,271 +0,0 @@
|
||||||
*This plugin is provided without guarantee or warranty*
|
|
||||||
=========================================================
|
|
||||||
|
|
||||||
[![npm version](http://img.shields.io/npm/v/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View this project on npm")
|
|
||||||
[![npm downloads](http://img.shields.io/npm/dm/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View this project on npm")
|
|
||||||
[![npm downloads](http://img.shields.io/npm/dt/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View this project on npm")
|
|
||||||
[![npm licence](http://img.shields.io/npm/l/com-darryncampbell-cordova-plugin-intent.svg?style=flat-square)](https://npmjs.org/package/com-darryncampbell-cordova-plugin-intent "View this project on npm")
|
|
||||||
|
|
||||||
Note: this is the current underlying implementation for https://www.npmjs.com/package/@ionic-native/web-intent and https://ionicframework.com/docs/native/web-intent/
|
|
||||||
|
|
||||||
# Interaction with Camera Plugin
|
|
||||||
If you are installing this plugin along with cordova-plugin-camera you **MUST install cordova-plugin-camera first.**
|
|
||||||
|
|
||||||
# Overview
|
|
||||||
This Cordova plugin provides a general purpose shim layer for the Android intent mechanism, exposing various ways to handle sending and receiving intents.
|
|
||||||
|
|
||||||
## Credits
|
|
||||||
This project uses code released under the following MIT projects:
|
|
||||||
- https://github.com/napolitano/cordova-plugin-intent (marked as no longer maintained)
|
|
||||||
- https://github.com/Initsogar/cordova-webintent.git (no longer available on github but the project is forked here: https://github.com/darryncampbell/cordova-webintent)
|
|
||||||
This project is also released under MIT. Credit is given in the code where appropriate
|
|
||||||
|
|
||||||
## IntentShim
|
|
||||||
This plugin defines a `window.plugins.intentShim` object which provides an API for interacting with the Android intent mechanism on any Android device.
|
|
||||||
|
|
||||||
## Testing / Example
|
|
||||||
An example application is available at https://github.com/darryncampbell/plugin-intent-api-exerciser to demonstrate the API and can be used to test the functionality.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
### Cordova Version < 7
|
|
||||||
cordova plugin add https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent.git
|
|
||||||
|
|
||||||
### Cordova Version >= 7
|
|
||||||
cordova plugin add com-darryncampbell-cordova-plugin-intent
|
|
||||||
|
|
||||||
## Supported Platforms
|
|
||||||
- Android
|
|
||||||
|
|
||||||
## intentShim.registerBroadcastReceiver
|
|
||||||
|
|
||||||
Registers a broadcast receiver for the specified filters
|
|
||||||
|
|
||||||
window.plugins.intentShim.registerBroadcastReceiver(filters, callback);
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The `intentShim.registerBroadcastReceiver` function registers a dynamic broadcast receiver for the specified list of filters and invokes the specified callback when any of those filters are received
|
|
||||||
|
|
||||||
### Android Quirks
|
|
||||||
|
|
||||||
Any existing broadcast receiver is unregistered when this method is called. To register for multiple types of broadcast, specify multiple filters.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
Register a broadcast receiver for two filters:
|
|
||||||
|
|
||||||
window.plugins.intentShim.registerBroadcastReceiver({
|
|
||||||
filterActions: [
|
|
||||||
'com.darryncampbell.cordova.plugin.broadcastIntent.ACTION',
|
|
||||||
'com.darryncampbell.cordova.plugin.broadcastIntent.ACTION_2'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
function(intent) {
|
|
||||||
console.log('Received broadcast intent: ' + JSON.stringify(intent.extras));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## intentShim.unregisterBroadcastReceiver
|
|
||||||
|
|
||||||
Unregisters the broadcast receiver
|
|
||||||
|
|
||||||
window.plugins.intentShim.unregisterBroadcastReceiver();
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The `intentShim.unregisterBroadcastReceiver` function unregisters the broadcast receiver registered with `intentShim.registerBroadcastReceiver(filters, callback);`. No further broadcasts will be received for any registered filter after this call.
|
|
||||||
|
|
||||||
### Android Quirks
|
|
||||||
|
|
||||||
The developer is responsible for calling unregister / register when their application goes into the background or comes back to the foreground, if desired.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
Unregister the broadcast receiver when the application receives an onPause event:
|
|
||||||
|
|
||||||
bindEvents: function() {
|
|
||||||
document.addEventListener('pause', this.onPause, false);
|
|
||||||
},
|
|
||||||
onPause: function()
|
|
||||||
{
|
|
||||||
window.plugins.intentShim.unregisterBroadcastReceiver();
|
|
||||||
}
|
|
||||||
|
|
||||||
## intentShim.sendBroadcast
|
|
||||||
|
|
||||||
Sends a broadcast intent
|
|
||||||
|
|
||||||
window.plugins.intentShim.sendBroadcast(action, extras, successCallback, failureCallback);
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The `intentShim.sendBroadcast` function sends an Android broadcast intent with a specified action
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
Send a broadcast intent to a specified action that contains a random number in the extras
|
|
||||||
|
|
||||||
window.plugins.intentShim.startActivity(
|
|
||||||
{
|
|
||||||
action: "com.darryncampbell.cordova.plugin.intent.ACTION",
|
|
||||||
extras: {
|
|
||||||
'random.number': Math.floor((Math.random() * 1000) + 1)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function() {},
|
|
||||||
function() {alert('Failed to open URL via Android Intent')}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## intentShim.onIntent
|
|
||||||
|
|
||||||
Returns the content of the intent used whenever the application activity is launched
|
|
||||||
|
|
||||||
window.plugins.intentShim.onIntent(callback);
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The `intentShim.onIntent` function returns the intent which launched the Activity and maps to the Android Activity's onNewIntent() method, https://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent). The registered callback is invoked whenever the activity is launched
|
|
||||||
|
|
||||||
### Android Quirks
|
|
||||||
|
|
||||||
By default the android application will be created with launch mode set to 'SingleTop'. If you wish to change this to 'SingleTask' you can do so by modifying `config.xml` as follows:
|
|
||||||
|
|
||||||
<platform name="android">
|
|
||||||
...
|
|
||||||
<preference name="AndroidLaunchMode" value="singleTask"/>
|
|
||||||
</platform>
|
|
||||||
See https://www.mobomo.com/2011/06/android-understanding-activity-launchmode/ for more information on the differences between the two.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
Registers a callback to be invoked
|
|
||||||
|
|
||||||
window.plugins.intentShim.onIntent(function (intent) {
|
|
||||||
console.log('Received Intent: ' + JSON.stringify(intent.extras));
|
|
||||||
});
|
|
||||||
|
|
||||||
## intentShim.startActivity
|
|
||||||
|
|
||||||
Starts a new activity using an intent built from action, url, type, extras or some subset of those parameters
|
|
||||||
|
|
||||||
window.plugins.intentShim.startActivity(params, successCallback, failureCallback);
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The `intentShim.startActivity` function maps to Android's activity method startActivity, https://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent) to launch a new activity.
|
|
||||||
|
|
||||||
### Android Quirks
|
|
||||||
|
|
||||||
Some common actions are defined as constants in the plugin, see below.
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
Launch the maps activity
|
|
||||||
|
|
||||||
window.plugins.intentShim.startActivity(
|
|
||||||
{
|
|
||||||
action: window.plugins.intentShim.ACTION_VIEW,
|
|
||||||
url: 'geo:0,0?q=London'
|
|
||||||
},
|
|
||||||
function() {},
|
|
||||||
function() {alert('Failed to open URL via Android Intent')}
|
|
||||||
);
|
|
||||||
|
|
||||||
Launch the web browser
|
|
||||||
|
|
||||||
window.plugins.intentShim.startActivity(
|
|
||||||
{
|
|
||||||
action: window.plugins.intentShim.ACTION_VIEW,
|
|
||||||
url: 'http://www.google.co.uk'
|
|
||||||
},
|
|
||||||
function() {},
|
|
||||||
function() {alert('Failed to open URL via Android Intent')}
|
|
||||||
);
|
|
||||||
|
|
||||||
## intentShim.getIntent
|
|
||||||
|
|
||||||
Retrieves the intent that launched the activity
|
|
||||||
|
|
||||||
window.plugins.intentShim.getIntent(resultCallback, failureCallback);
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The `intentShim.getIntent` function maps to Android's activity method getIntent, https://developer.android.com/reference/android/app/Activity.html#getIntent() to return the intent that started this activity.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
window.plugins.intentShim.getIntent(
|
|
||||||
function(intent)
|
|
||||||
{
|
|
||||||
console.log('Action' + JSON.stringify(intent.action));
|
|
||||||
var intentExtras = intent.extras;
|
|
||||||
if (intentExtras == null)
|
|
||||||
intentExtras = "No extras in intent";
|
|
||||||
console.log('Launch Intent Extras: ' + JSON.stringify(intentExtras));
|
|
||||||
},
|
|
||||||
function()
|
|
||||||
{
|
|
||||||
console.log('Error getting launch intent');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
## intentShim.startActivityForResult
|
|
||||||
|
|
||||||
Starts a new activity and return the result to the application
|
|
||||||
|
|
||||||
window.plugins.intentShim.startActivityForResult(params, resultCallback, failureCallback);
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The `intentShim.startActivityForResult` function maps to Android's activity method startActivityForResult, https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int) to launch a new activity and the resulting data is returned via the resultCallback.
|
|
||||||
|
|
||||||
### Android Quirks
|
|
||||||
|
|
||||||
Some common actions are defined as constants in the plugin, see below.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
Pick an Android contact
|
|
||||||
|
|
||||||
window.plugins.intentShim.startActivityForResult(
|
|
||||||
{
|
|
||||||
action: window.plugins.intentShim.ACTION_PICK,
|
|
||||||
url: "content://com.android.contacts/contacts",
|
|
||||||
requestCode: 1
|
|
||||||
},
|
|
||||||
function(intent)
|
|
||||||
{
|
|
||||||
if (intent.extras.requestCode == 1)
|
|
||||||
{
|
|
||||||
console.log('Picked contact: ' + intent.data);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function()
|
|
||||||
{
|
|
||||||
console.log("StartActivityForResult failure");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
## Predefined Constants
|
|
||||||
|
|
||||||
The following constants are defined in the plugin for use in JavaScript
|
|
||||||
- window.plugins.intentShim.ACTION_SEND
|
|
||||||
- window.plugins.intentShim.ACTION_VIEW
|
|
||||||
- window.plugins.intentShim.EXTRA_TEXT
|
|
||||||
- window.plugins.intentShim.EXTRA_SUBJECT
|
|
||||||
- window.plugins.intentShim.EXTRA_STREAM
|
|
||||||
- window.plugins.intentShim.EXTRA_EMAIL
|
|
||||||
- window.plugins.intentShim.ACTION_CALL
|
|
||||||
- window.plugins.intentShim.ACTION_SENDTO
|
|
||||||
- window.plugins.intentShim.ACTION_GET_CONTENT
|
|
||||||
- window.plugins.intentShim.ACTION_PICK
|
|
||||||
|
|
||||||
## Tested Versions
|
|
||||||
|
|
||||||
Tested with Cordova version 6.5.0 and Cordova Android version 6.2.1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "com-darryncampbell-cordova-plugin-intent@^1.1.0",
|
|
||||||
"_id": "com-darryncampbell-cordova-plugin-intent@1.1.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-KPyU4RlOl1ofliMSyHms3eyyzIAvRCEpGda5T8j3XXmYeU0YdLG7UeHat84eJWByjv8K7XhMbVu841DnipPrLg==",
|
|
||||||
"_location": "/com-darryncampbell-cordova-plugin-intent",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "com-darryncampbell-cordova-plugin-intent@^1.1.0",
|
|
||||||
"name": "com-darryncampbell-cordova-plugin-intent",
|
|
||||||
"escapedName": "com-darryncampbell-cordova-plugin-intent",
|
|
||||||
"rawSpec": "^1.1.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^1.1.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/com-darryncampbell-cordova-plugin-intent/-/com-darryncampbell-cordova-plugin-intent-1.1.0.tgz",
|
|
||||||
"_shasum": "ab7506183a9d171d6448e79c9722f2526f8a7efc",
|
|
||||||
"_spec": "com-darryncampbell-cordova-plugin-intent@^1.1.0",
|
|
||||||
"_where": "/home/thrrgilag/workspace/cordova/Goober",
|
|
||||||
"author": {
|
|
||||||
"name": "Darryn Campbell"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"cordova": {
|
|
||||||
"id": "com-darryncampbell-cordova-plugin-intent",
|
|
||||||
"platforms": [
|
|
||||||
"android"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.",
|
|
||||||
"homepage": "https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent#readme",
|
|
||||||
"keywords": [
|
|
||||||
"ecosystem:cordova",
|
|
||||||
"cordova-android",
|
|
||||||
"Intent"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "intentShim.js",
|
|
||||||
"name": "com-darryncampbell-cordova-plugin-intent",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent.git"
|
|
||||||
},
|
|
||||||
"version": "1.1.0"
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<plugin id="com-darryncampbell-cordova-plugin-intent" version="1.1.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.androcordov.com/apk/res/android">
|
|
||||||
<name>Intent Shim</name>
|
|
||||||
<js-module name="IntentShim" src="www/IntentShim.js">
|
|
||||||
<clobbers target="intentShim" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<!-- android -->
|
|
||||||
<platform name="android">
|
|
||||||
<config-file target="res/xml/config.xml" parent="/*">
|
|
||||||
<feature name="IntentShim" >
|
|
||||||
<param name="android-package" value="com.darryncampbell.cordova.plugin.intent.IntentShim"/>
|
|
||||||
<param name="onload" value="true"/>
|
|
||||||
</feature>
|
|
||||||
</config-file>
|
|
||||||
<config-file target="AndroidManifest.xml" platform="android" parent="/manifest/application/activity" mode="merge">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="com.darryncampbell.cordova.plugin.intent.ACTION" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</config-file>
|
|
||||||
<config-file target="AndroidManifest.xml" platform="android" parent="/manifest" mode="merge">
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
||||||
</config-file>
|
|
||||||
<config-file target="AndroidManifest.xml" platform="android" parent="/manifest" mode="merge">
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
|
||||||
</config-file>
|
|
||||||
<config-file target="AndroidManifest.xml" platform="android" parent="/manifest/application" mode="merge">
|
|
||||||
<provider
|
|
||||||
android:name="android.support.v4.content.FileProvider"
|
|
||||||
android:authorities="${applicationId}.provider"
|
|
||||||
android:exported="false"
|
|
||||||
android:grantUriPermissions="true">
|
|
||||||
<meta-data
|
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
||||||
android:resource="@xml/provider_paths"/>
|
|
||||||
</provider>
|
|
||||||
</config-file>
|
|
||||||
<source-file src="src/android/IntentShim.java" target-dir="src/com/darryncampbell/plugin/intent" />
|
|
||||||
<resource-file src="src/android/res/xml/provider_paths.xml" target="res/xml/provider_paths.xml"/>
|
|
||||||
<framework src="com.android.support:support-v4:27.1.0" />
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
</plugin>
|
|
|
@ -1,794 +0,0 @@
|
||||||
package com.darryncampbell.cordova.plugin.intent;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.provider.DocumentsContract;
|
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.support.v4.content.FileProvider;
|
|
||||||
import android.text.Html;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.webkit.MimeTypeMap;
|
|
||||||
|
|
||||||
import org.apache.cordova.CallbackContext;
|
|
||||||
import org.apache.cordova.CordovaActivity;
|
|
||||||
import org.apache.cordova.CordovaPlugin;
|
|
||||||
import org.apache.cordova.CordovaResourceApi;
|
|
||||||
import org.apache.cordova.PluginResult;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static android.os.Environment.getExternalStorageDirectory;
|
|
||||||
import static android.os.Environment.getExternalStorageState;
|
|
||||||
|
|
||||||
public class IntentShim extends CordovaPlugin {
|
|
||||||
|
|
||||||
private static final String LOG_TAG = "Cordova Intents Shim";
|
|
||||||
private CallbackContext onNewIntentCallbackContext = null;
|
|
||||||
private CallbackContext onBroadcastCallbackContext = null;
|
|
||||||
private CallbackContext onActivityResultCallbackContext = null;
|
|
||||||
|
|
||||||
private Intent deferredIntent = null;
|
|
||||||
|
|
||||||
public IntentShim() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException
|
|
||||||
{
|
|
||||||
Log.d(LOG_TAG, "Action: " + action);
|
|
||||||
if (action.equals("startActivity") || action.equals("startActivityForResult"))
|
|
||||||
{
|
|
||||||
// Credit: https://github.com/chrisekelley/cordova-webintent
|
|
||||||
if (args.length() != 1) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject obj = args.getJSONObject(0);
|
|
||||||
Intent intent = populateIntent(obj, callbackContext);
|
|
||||||
int requestCode = obj.has("requestCode") ? obj.getInt("requestCode") : 1;
|
|
||||||
|
|
||||||
boolean bExpectResult = false;
|
|
||||||
if (action.equals("startActivityForResult"))
|
|
||||||
{
|
|
||||||
bExpectResult = true;
|
|
||||||
this.onActivityResultCallbackContext = callbackContext;
|
|
||||||
}
|
|
||||||
startActivity(intent, bExpectResult, requestCode, callbackContext);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (action.equals("sendBroadcast"))
|
|
||||||
{
|
|
||||||
// Credit: https://github.com/chrisekelley/cordova-webintent
|
|
||||||
if (args.length() != 1) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the arguments
|
|
||||||
JSONObject obj = args.getJSONObject(0);
|
|
||||||
Intent intent = populateIntent(obj, callbackContext);
|
|
||||||
|
|
||||||
sendBroadcast(intent);
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (action.equals("startService"))
|
|
||||||
{
|
|
||||||
if (args.length() != 1) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
JSONObject obj = args.getJSONObject(0);
|
|
||||||
Intent intent = populateIntent(obj, callbackContext);
|
|
||||||
startService(intent);
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (action.equals("registerBroadcastReceiver")) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Ensure we only have a single registered broadcast receiver
|
|
||||||
((CordovaActivity)this.cordova.getActivity()).unregisterReceiver(myBroadcastReceiver);
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e) {}
|
|
||||||
|
|
||||||
// No error callback
|
|
||||||
if(args.length() != 1) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expect an array of filterActions
|
|
||||||
JSONObject obj = args.getJSONObject(0);
|
|
||||||
JSONArray filterActions = obj.has("filterActions") ? obj.getJSONArray("filterActions") : null;
|
|
||||||
if (filterActions == null || filterActions.length() == 0)
|
|
||||||
{
|
|
||||||
// The arguments are not correct
|
|
||||||
Log.w(LOG_TAG, "filterActions argument is not in the expected format");
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onBroadcastCallbackContext = callbackContext;
|
|
||||||
|
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
|
|
||||||
result.setKeepCallback(true);
|
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
|
||||||
for (int i = 0; i < filterActions.length(); i++) {
|
|
||||||
Log.d(LOG_TAG, "Registering broadcast receiver for filter: " + filterActions.getString(i));
|
|
||||||
filter.addAction(filterActions.getString(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow an array of filterCategories
|
|
||||||
JSONArray filterCategories = obj.has("filterCategories") ? obj.getJSONArray("filterCategories") : null;
|
|
||||||
if (filterCategories != null) {
|
|
||||||
for (int i = 0; i < filterCategories.length(); i++) {
|
|
||||||
Log.d(LOG_TAG, "Registering broadcast receiver for category filter: " + filterCategories.getString(i));
|
|
||||||
filter.addCategory(filterCategories.getString(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add any specified Data Schemes
|
|
||||||
// https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/issues/24
|
|
||||||
JSONArray filterDataSchemes = obj.has("filterDataSchemes") ? obj.getJSONArray("filterDataSchemes") : null;
|
|
||||||
if (filterDataSchemes != null && filterDataSchemes.length() > 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < filterDataSchemes.length(); i++)
|
|
||||||
{
|
|
||||||
Log.d(LOG_TAG, "Associating data scheme to filter: " + filterDataSchemes.getString(i));
|
|
||||||
filter.addDataScheme(filterDataSchemes.getString(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
((CordovaActivity)this.cordova.getActivity()).registerReceiver(myBroadcastReceiver, filter);
|
|
||||||
|
|
||||||
callbackContext.sendPluginResult(result);
|
|
||||||
}
|
|
||||||
else if (action.equals("unregisterBroadcastReceiver"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
((CordovaActivity)this.cordova.getActivity()).unregisterReceiver(myBroadcastReceiver);
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e) {}
|
|
||||||
}
|
|
||||||
else if (action.equals("onIntent"))
|
|
||||||
{
|
|
||||||
// Credit: https://github.com/napolitano/cordova-plugin-intent
|
|
||||||
if(args.length() != 1) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onNewIntentCallbackContext = callbackContext;
|
|
||||||
|
|
||||||
if (this.deferredIntent != null) {
|
|
||||||
fireOnNewIntent(this.deferredIntent);
|
|
||||||
this.deferredIntent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
|
|
||||||
result.setKeepCallback(true);
|
|
||||||
callbackContext.sendPluginResult(result);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (action.equals("onActivityResult"))
|
|
||||||
{
|
|
||||||
if(args.length() != 1) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onActivityResultCallbackContext = callbackContext;
|
|
||||||
|
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
|
|
||||||
result.setKeepCallback(true);
|
|
||||||
callbackContext.sendPluginResult(result);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (action.equals("getIntent"))
|
|
||||||
{
|
|
||||||
// Credit: https://github.com/napolitano/cordova-plugin-intent
|
|
||||||
if(args.length() != 0) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent;
|
|
||||||
|
|
||||||
if (this.deferredIntent != null) {
|
|
||||||
intent = this.deferredIntent;
|
|
||||||
this.deferredIntent = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
intent = cordova.getActivity().getIntent();
|
|
||||||
}
|
|
||||||
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, getIntentJson(intent)));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (action.equals("sendResult"))
|
|
||||||
{
|
|
||||||
// Assuming this application was started with startActivityForResult, send the result back
|
|
||||||
// https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/issues/3
|
|
||||||
Intent result = new Intent();
|
|
||||||
if (args.length() > 0)
|
|
||||||
{
|
|
||||||
JSONObject json = args.getJSONObject(0);
|
|
||||||
JSONObject extras = (json.has("extras"))?json.getJSONObject("extras"):null;
|
|
||||||
|
|
||||||
// Populate the extras if any exist
|
|
||||||
if (extras != null) {
|
|
||||||
JSONArray extraNames = extras.names();
|
|
||||||
for (int i = 0; i < extraNames.length(); i++) {
|
|
||||||
String key = extraNames.getString(i);
|
|
||||||
String value = extras.getString(key);
|
|
||||||
result.putExtra(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//set result
|
|
||||||
cordova.getActivity().setResult(Activity.RESULT_OK, result);
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
|
|
||||||
|
|
||||||
//finish the activity
|
|
||||||
cordova.getActivity().finish();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (action.equals("realPathFromUri"))
|
|
||||||
{
|
|
||||||
if (args.length() != 1) {
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.INVALID_ACTION));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject obj = args.getJSONObject(0);
|
|
||||||
String realPath = getRealPathFromURI_API19(obj, callbackContext);
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, realPath));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Uri remapUriWithFileProvider(String uriAsString, final CallbackContext callbackContext)
|
|
||||||
{
|
|
||||||
// Create the URI via FileProvider Special case for N and above when installing apks
|
|
||||||
int permissionCheck = ContextCompat.checkSelfPermission(this.cordova.getActivity(),
|
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
||||||
if (permissionCheck != PackageManager.PERMISSION_GRANTED)
|
|
||||||
{
|
|
||||||
// Could do better here - if the app does not already have permission should
|
|
||||||
// only continue when we get the success callback from this.
|
|
||||||
ActivityCompat.requestPermissions(this.cordova.getActivity(),
|
|
||||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
|
|
||||||
callbackContext.error("Please grant read external storage permission");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String externalStorageState = getExternalStorageState();
|
|
||||||
if (externalStorageState.equals(Environment.MEDIA_MOUNTED) || externalStorageState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
|
|
||||||
String fileName = uriAsString.substring(uriAsString.indexOf('/') + 2, uriAsString.length());
|
|
||||||
File uriAsFile = new File(fileName);
|
|
||||||
boolean fileExists = uriAsFile.exists();
|
|
||||||
if (!fileExists)
|
|
||||||
{
|
|
||||||
Log.e(LOG_TAG, "File at path " + uriAsFile.getPath() + " with name " + uriAsFile.getName() + "does not exist");
|
|
||||||
callbackContext.error("File not found: " + uriAsFile.toString());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String PACKAGE_NAME = this.cordova.getActivity().getPackageName() + ".provider";
|
|
||||||
Uri uri = FileProvider.getUriForFile(this.cordova.getActivity().getApplicationContext(), PACKAGE_NAME, uriAsFile);
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.e(LOG_TAG, "Storage directory is not mounted. Please ensure the device is not connected via USB for file transfer");
|
|
||||||
callbackContext.error("Storage directory is returning not mounted");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(StringIndexOutOfBoundsException e)
|
|
||||||
{
|
|
||||||
Log.e(LOG_TAG, "URL is not well formed");
|
|
||||||
callbackContext.error("URL is not well formed");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getRealPathFromURI_API19(JSONObject obj, CallbackContext callbackContext) throws JSONException
|
|
||||||
{
|
|
||||||
// Credit: https://stackoverflow.com/questions/2789276/android-get-real-path-by-uri-getpath/2790688
|
|
||||||
Uri uri = obj.has("uri") ? Uri.parse(obj.getString("uri")) : null;
|
|
||||||
if (uri == null)
|
|
||||||
{
|
|
||||||
Log.w(LOG_TAG, "URI is not a specified parameter");
|
|
||||||
throw new JSONException("URI is not a specified parameter");
|
|
||||||
}
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
|
||||||
String filePath = "";
|
|
||||||
if (uri.getHost().contains("com.android.providers.media")) {
|
|
||||||
int permissionCheck = ContextCompat.checkSelfPermission(this.cordova.getActivity(),
|
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
||||||
if (permissionCheck != PackageManager.PERMISSION_GRANTED)
|
|
||||||
{
|
|
||||||
// Could do better here - if the app does not already have permission should
|
|
||||||
// only continue when we get the success callback from this.
|
|
||||||
ActivityCompat.requestPermissions(this.cordova.getActivity(),
|
|
||||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
|
|
||||||
callbackContext.error("Please grant read external storage permission");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Image pick from recent
|
|
||||||
String wholeID = DocumentsContract.getDocumentId(uri);
|
|
||||||
|
|
||||||
// Split at colon, use second item in the array
|
|
||||||
String id = wholeID.split(":")[1];
|
|
||||||
|
|
||||||
String[] column = {MediaStore.Images.Media.DATA};
|
|
||||||
|
|
||||||
// where id is equal to
|
|
||||||
String sel = MediaStore.Images.Media._ID + "=?";
|
|
||||||
|
|
||||||
// This line requires read storage permission
|
|
||||||
|
|
||||||
Cursor cursor = this.cordova.getActivity().getApplicationContext().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
|
||||||
column, sel, new String[]{id}, null);
|
|
||||||
|
|
||||||
int columnIndex = cursor.getColumnIndex(column[0]);
|
|
||||||
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
filePath = cursor.getString(columnIndex);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
return filePath;
|
|
||||||
} else {
|
|
||||||
// image pick from gallery
|
|
||||||
String[] proj = {MediaStore.Images.Media.DATA};
|
|
||||||
Cursor cursor = this.cordova.getActivity().getApplicationContext().getContentResolver().query(uri, proj, null, null, null);
|
|
||||||
int column_index
|
|
||||||
= cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
||||||
cursor.moveToFirst();
|
|
||||||
return cursor.getString(column_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Requires KK or higher";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startActivity(Intent i, boolean bExpectResult, int requestCode, CallbackContext callbackContext) {
|
|
||||||
|
|
||||||
if (i.resolveActivityInfo(this.cordova.getActivity().getPackageManager(), 0) != null)
|
|
||||||
{
|
|
||||||
if (bExpectResult)
|
|
||||||
{
|
|
||||||
cordova.setActivityResultCallback(this);
|
|
||||||
((CordovaActivity) this.cordova.getActivity()).startActivityForResult(i, requestCode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
((CordovaActivity)this.cordova.getActivity()).startActivity(i);
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Return an error as there is no app to handle this intent
|
|
||||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendBroadcast(Intent intent) {
|
|
||||||
((CordovaActivity)this.cordova.getActivity()).sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startService(Intent intent)
|
|
||||||
{
|
|
||||||
((CordovaActivity)this.cordova.getActivity()).startService(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Intent populateIntent(JSONObject obj, CallbackContext callbackContext) throws JSONException
|
|
||||||
{
|
|
||||||
// Credit: https://github.com/chrisekelley/cordova-webintent
|
|
||||||
// Credit: https://github.com/chrisekelley/cordova-webintent
|
|
||||||
String type = obj.has("type") ? obj.getString("type") : null;
|
|
||||||
String packageAssociated = obj.has("package") ? obj.getString("package") : null;
|
|
||||||
|
|
||||||
//Uri uri = obj.has("url") ? resourceApi.remapUri(Uri.parse(obj.getString("url"))) : null;
|
|
||||||
Uri uri = null;
|
|
||||||
final CordovaResourceApi resourceApi = webView.getResourceApi();
|
|
||||||
if (obj.has("url"))
|
|
||||||
{
|
|
||||||
String uriAsString = obj.getString("url");
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && uriAsString.startsWith("file://"))
|
|
||||||
{
|
|
||||||
uri = remapUriWithFileProvider(uriAsString, callbackContext);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uri = resourceApi.remapUri(Uri.parse(obj.getString("url")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject extras = obj.has("extras") ? obj.getJSONObject("extras") : null;
|
|
||||||
Map<String, Object> extrasMap = new HashMap<String, Object>();
|
|
||||||
Bundle bundle = null;
|
|
||||||
String bundleKey = "";
|
|
||||||
if (extras != null) {
|
|
||||||
JSONArray extraNames = extras.names();
|
|
||||||
for (int i = 0; i < extraNames.length(); i++) {
|
|
||||||
String key = extraNames.getString(i);
|
|
||||||
Object extrasObj = extras.get(key);
|
|
||||||
if (extrasObj instanceof JSONObject) {
|
|
||||||
// The extra is a bundle
|
|
||||||
bundleKey = key;
|
|
||||||
bundle = toBundle((JSONObject) extras.get(key));
|
|
||||||
} else {
|
|
||||||
extrasMap.put(key, extras.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String action = obj.has("action") ? obj.getString("action") : null;
|
|
||||||
Intent i = new Intent();
|
|
||||||
if (action != null)
|
|
||||||
i.setAction(action);
|
|
||||||
|
|
||||||
if (type != null && uri != null) {
|
|
||||||
i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
|
|
||||||
} else {
|
|
||||||
if (type != null) {
|
|
||||||
i.setType(type);
|
|
||||||
}
|
|
||||||
if (uri != null)
|
|
||||||
{
|
|
||||||
i.setData(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject component = obj.has("component") ? obj.getJSONObject("component") : null;
|
|
||||||
if (component != null)
|
|
||||||
{
|
|
||||||
// User has specified an explicit intent
|
|
||||||
String componentPackage = component.has("package") ? component.getString("package") : null;
|
|
||||||
String componentClass = component.has("class") ? component.getString("class") : null;
|
|
||||||
if (componentPackage == null || componentClass == null)
|
|
||||||
{
|
|
||||||
Log.w(LOG_TAG, "Component specified but missing corresponding package or class");
|
|
||||||
throw new JSONException("Component specified but missing corresponding package or class");
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ComponentName componentName = new ComponentName(componentPackage, componentClass);
|
|
||||||
i.setComponent(componentName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packageAssociated != null)
|
|
||||||
i.setPackage(packageAssociated);
|
|
||||||
|
|
||||||
JSONArray flags = obj.has("flags") ? obj.getJSONArray("flags") : null;
|
|
||||||
if (flags != null)
|
|
||||||
{
|
|
||||||
int length = flags.length();
|
|
||||||
for (int k = 0; k < length; k++)
|
|
||||||
{
|
|
||||||
i.addFlags(flags.getInt(k));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bundle != null)
|
|
||||||
i.putExtra(bundleKey, bundle);
|
|
||||||
|
|
||||||
for (String key : extrasMap.keySet()) {
|
|
||||||
Object value = extrasMap.get(key);
|
|
||||||
String valueStr = String.valueOf(value);
|
|
||||||
// If type is text html, the extra text must sent as HTML
|
|
||||||
if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
|
|
||||||
i.putExtra(key, Html.fromHtml(valueStr));
|
|
||||||
} else if (key.equals(Intent.EXTRA_STREAM)) {
|
|
||||||
// allows sharing of images as attachments.
|
|
||||||
// value in this case should be a URI of a file
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && valueStr.startsWith("file://"))
|
|
||||||
{
|
|
||||||
Uri uriOfStream = remapUriWithFileProvider(valueStr, callbackContext);
|
|
||||||
if (uriOfStream != null)
|
|
||||||
i.putExtra(key, uriOfStream);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//final CordovaResourceApi resourceApi = webView.getResourceApi();
|
|
||||||
i.putExtra(key, resourceApi.remapUri(Uri.parse(valueStr)));
|
|
||||||
}
|
|
||||||
} else if (key.equals(Intent.EXTRA_EMAIL)) {
|
|
||||||
// allows to add the email address of the receiver
|
|
||||||
i.putExtra(Intent.EXTRA_EMAIL, new String[] { valueStr });
|
|
||||||
} else {
|
|
||||||
if (value instanceof Boolean) {
|
|
||||||
i.putExtra(key, Boolean.valueOf(valueStr));
|
|
||||||
} else if(value instanceof Integer) {
|
|
||||||
i.putExtra(key, Integer.valueOf(valueStr));
|
|
||||||
} else if(value instanceof Long) {
|
|
||||||
i.putExtra(key, Long.valueOf(valueStr));
|
|
||||||
} else if(value instanceof Double) {
|
|
||||||
i.putExtra(key, Double.valueOf(valueStr));
|
|
||||||
} else {
|
|
||||||
i.putExtra(key, valueStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNewIntent(Intent intent) {
|
|
||||||
if (this.onNewIntentCallbackContext != null) {
|
|
||||||
fireOnNewIntent(intent);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// save the intent for use when onIntent action is called in the execute method
|
|
||||||
this.deferredIntent = intent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent intent)
|
|
||||||
{
|
|
||||||
super.onActivityResult(requestCode, resultCode, intent);
|
|
||||||
if (onActivityResultCallbackContext != null && intent != null)
|
|
||||||
{
|
|
||||||
intent.putExtra("requestCode", requestCode);
|
|
||||||
intent.putExtra("resultCode", resultCode);
|
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
|
|
||||||
result.setKeepCallback(true);
|
|
||||||
onActivityResultCallbackContext.sendPluginResult(result);
|
|
||||||
}
|
|
||||||
else if (onActivityResultCallbackContext != null)
|
|
||||||
{
|
|
||||||
Intent canceledIntent = new Intent();
|
|
||||||
canceledIntent.putExtra("requestCode", requestCode);
|
|
||||||
canceledIntent.putExtra("resultCode", resultCode);
|
|
||||||
PluginResult canceledResult = new PluginResult(PluginResult.Status.OK, getIntentJson(canceledIntent));
|
|
||||||
canceledResult.setKeepCallback(true);
|
|
||||||
onActivityResultCallbackContext.sendPluginResult(canceledResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (onBroadcastCallbackContext != null)
|
|
||||||
{
|
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
|
|
||||||
result.setKeepCallback(true);
|
|
||||||
onBroadcastCallbackContext.sendPluginResult(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the provided Intent to the onNewIntentCallbackContext.
|
|
||||||
*
|
|
||||||
* @param intent This is the intent to send to the JS layer.
|
|
||||||
*/
|
|
||||||
private void fireOnNewIntent(Intent intent) {
|
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
|
|
||||||
result.setKeepCallback(true);
|
|
||||||
this.onNewIntentCallbackContext.sendPluginResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return JSON representation of intent attributes
|
|
||||||
*
|
|
||||||
* @param intent
|
|
||||||
* Credit: https://github.com/napolitano/cordova-plugin-intent
|
|
||||||
*/
|
|
||||||
private JSONObject getIntentJson(Intent intent) {
|
|
||||||
JSONObject intentJSON = null;
|
|
||||||
ClipData clipData = null;
|
|
||||||
JSONObject[] items = null;
|
|
||||||
ContentResolver cR = this.cordova.getActivity().getApplicationContext().getContentResolver();
|
|
||||||
MimeTypeMap mime = MimeTypeMap.getSingleton();
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
||||||
clipData = intent.getClipData();
|
|
||||||
if(clipData != null) {
|
|
||||||
int clipItemCount = clipData.getItemCount();
|
|
||||||
items = new JSONObject[clipItemCount];
|
|
||||||
|
|
||||||
for (int i = 0; i < clipItemCount; i++) {
|
|
||||||
|
|
||||||
ClipData.Item item = clipData.getItemAt(i);
|
|
||||||
|
|
||||||
try {
|
|
||||||
items[i] = new JSONObject();
|
|
||||||
items[i].put("htmlText", item.getHtmlText());
|
|
||||||
items[i].put("intent", item.getIntent());
|
|
||||||
items[i].put("text", item.getText());
|
|
||||||
items[i].put("uri", item.getUri());
|
|
||||||
|
|
||||||
if (item.getUri() != null) {
|
|
||||||
String type = cR.getType(item.getUri());
|
|
||||||
String extension = mime.getExtensionFromMimeType(cR.getType(item.getUri()));
|
|
||||||
|
|
||||||
items[i].put("type", type);
|
|
||||||
items[i].put("extension", extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.d(LOG_TAG, " Error thrown during intent > JSON conversion");
|
|
||||||
Log.d(LOG_TAG, e.getMessage());
|
|
||||||
Log.d(LOG_TAG, Arrays.toString(e.getStackTrace()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
intentJSON = new JSONObject();
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
||||||
if(items != null) {
|
|
||||||
intentJSON.put("clipItems", new JSONArray(items));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
intentJSON.put("type", intent.getType());
|
|
||||||
intentJSON.put("extras", toJsonObject(intent.getExtras()));
|
|
||||||
intentJSON.put("action", intent.getAction());
|
|
||||||
intentJSON.put("categories", intent.getCategories());
|
|
||||||
intentJSON.put("flags", intent.getFlags());
|
|
||||||
intentJSON.put("component", intent.getComponent());
|
|
||||||
intentJSON.put("data", intent.getData());
|
|
||||||
intentJSON.put("package", intent.getPackage());
|
|
||||||
|
|
||||||
return intentJSON;
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.d(LOG_TAG, " Error thrown during intent > JSON conversion");
|
|
||||||
Log.d(LOG_TAG, e.getMessage());
|
|
||||||
Log.d(LOG_TAG, Arrays.toString(e.getStackTrace()));
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JSONObject toJsonObject(Bundle bundle) {
|
|
||||||
// Credit: https://github.com/napolitano/cordova-plugin-intent
|
|
||||||
try {
|
|
||||||
return (JSONObject) toJsonValue(bundle);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
throw new IllegalArgumentException("Cannot convert bundle to JSON: " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Object toJsonValue(final Object value) throws JSONException {
|
|
||||||
// Credit: https://github.com/napolitano/cordova-plugin-intent
|
|
||||||
if (value == null) {
|
|
||||||
return null;
|
|
||||||
} else if (value instanceof Bundle) {
|
|
||||||
final Bundle bundle = (Bundle) value;
|
|
||||||
final JSONObject result = new JSONObject();
|
|
||||||
for (final String key : bundle.keySet()) {
|
|
||||||
result.put(key, toJsonValue(bundle.get(key)));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
} else if ((value.getClass().isArray())) {
|
|
||||||
final JSONArray result = new JSONArray();
|
|
||||||
int length = Array.getLength(value);
|
|
||||||
for (int i = 0; i < length; ++i) {
|
|
||||||
result.put(i, toJsonValue(Array.get(value, i)));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else if (value instanceof ArrayList<?>) {
|
|
||||||
final ArrayList arrayList = (ArrayList<?>)value;
|
|
||||||
final JSONArray result = new JSONArray();
|
|
||||||
for (int i = 0; i < arrayList.size(); i++)
|
|
||||||
result.put(toJsonValue(arrayList.get(i)));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else if (
|
|
||||||
value instanceof String
|
|
||||||
|| value instanceof Boolean
|
|
||||||
|| value instanceof Integer
|
|
||||||
|| value instanceof Long
|
|
||||||
|| value instanceof Double) {
|
|
||||||
return value;
|
|
||||||
} else {
|
|
||||||
return String.valueOf(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Bundle toBundle(final JSONObject obj) {
|
|
||||||
Bundle returnBundle = new Bundle();
|
|
||||||
if (obj == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Iterator<?> keys = obj.keys();
|
|
||||||
while(keys.hasNext())
|
|
||||||
{
|
|
||||||
String key = (String)keys.next();
|
|
||||||
Object compare = obj.get(key);
|
|
||||||
if (obj.get(key) instanceof String)
|
|
||||||
returnBundle.putString(key, obj.getString(key));
|
|
||||||
else if (obj.get(key) instanceof Boolean)
|
|
||||||
returnBundle.putBoolean(key, obj.getBoolean(key));
|
|
||||||
else if (obj.get(key) instanceof Integer)
|
|
||||||
returnBundle.putInt(key, obj.getInt(key));
|
|
||||||
else if (obj.get(key) instanceof Long)
|
|
||||||
returnBundle.putLong(key, obj.getLong(key));
|
|
||||||
else if (obj.get(key) instanceof Double)
|
|
||||||
returnBundle.putDouble(key, obj.getDouble(key));
|
|
||||||
else if (obj.get(key).getClass().isArray() || obj.get(key) instanceof JSONArray)
|
|
||||||
{
|
|
||||||
JSONArray jsonArray = obj.getJSONArray(key);
|
|
||||||
int length = jsonArray.length();
|
|
||||||
if (jsonArray.get(0) instanceof String)
|
|
||||||
{
|
|
||||||
String[] stringArray = new String[length];
|
|
||||||
for (int j = 0; j < length; j++)
|
|
||||||
stringArray[j] = jsonArray.getString(j);
|
|
||||||
returnBundle.putStringArray(key, stringArray);
|
|
||||||
//returnBundle.putParcelableArray(key, obj.get);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Bundle[] bundleArray = new Bundle[length];
|
|
||||||
for (int k = 0; k < length ; k++)
|
|
||||||
bundleArray[k] = toBundle(jsonArray.getJSONObject(k));
|
|
||||||
returnBundle.putParcelableArray(key, bundleArray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (obj.get(key) instanceof JSONObject)
|
|
||||||
returnBundle.putBundle(key, toBundle((JSONObject)obj.get(key)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return returnBundle;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
<paths xmlns:android='http://schemas.android.com/apk/res/android'>
|
|
||||||
<external-path name='external_files' path='.' />
|
|
||||||
</paths>
|
|
|
@ -1,172 +0,0 @@
|
||||||
cordova-android-support-gradle-release
|
|
||||||
======================================
|
|
||||||
|
|
||||||
This Cordova/Phonegap plugin for Android aligns various versions of the Android Support libraries specified by other plugins to a specific version.
|
|
||||||
|
|
||||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
||||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
||||||
**Table of Contents**
|
|
||||||
|
|
||||||
- [Purpose](#purpose)
|
|
||||||
- [Installation](#installation)
|
|
||||||
- [Library versions](#library-versions)
|
|
||||||
- [Default version](#default-version)
|
|
||||||
- [Other versions](#other-versions)
|
|
||||||
- [Example cases](#example-cases)
|
|
||||||
- [Example 1](#example-1)
|
|
||||||
- [Example 2](#example-2)
|
|
||||||
- [Credits](#credits)
|
|
||||||
- [License](#license)
|
|
||||||
|
|
||||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
||||||
|
|
||||||
# Purpose
|
|
||||||
|
|
||||||
**TL;DR**: To prevent build failures caused by including different versions of the support libraries.
|
|
||||||
|
|
||||||
Some Cordova plugins include [Android Support Libraries](https://developer.android.com/topic/libraries/support-library/index.html) to faciliate them.
|
|
||||||
Most commonly, these are now included into the Cordova project by specifying them as Gradle dependencies (see the [Cordova plugin spec documentation](https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#framework)).
|
|
||||||
|
|
||||||
Example plugins:
|
|
||||||
- [cordova-diagnostic-plugin](https://github.com/dpa99c/cordova-diagnostic-plugin)
|
|
||||||
- [Telerik ImagePicker plugin](https://github.com/Telerik-Verified-Plugins/ImagePicker)
|
|
||||||
- [cordova-plugin-local-notifications](https://github.com/katzer/cordova-plugin-local-notifications/)
|
|
||||||
- [cordova-plugin-facebook4](https://github.com/jeduan/cordova-plugin-facebook4)
|
|
||||||
|
|
||||||
The problem arises when these plugins specify different versions of the support libraries. This can cause build failures to occur, which are not easy to resolve without changes by the plugin authors to align the specified versions. See these issues:
|
|
||||||
|
|
||||||
- [phonegap-plugin-barcodescanner#480](https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/480)
|
|
||||||
- [cordova-plugin-facebook4#507](https://github.com/jeduan/cordova-plugin-facebook4/issues/507)
|
|
||||||
- [cordova-plugin-local-notifications#1322](https://github.com/katzer/cordova-plugin-local-notifications/issues/1322)
|
|
||||||
- [cordova-diagnostic-plugin#211](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/211)
|
|
||||||
|
|
||||||
To resolve these version collisions, this plugin injects a Gradle configuration file into the native Android platform project, which overrides any versions specified by other plugins, and forces them to the version specified in its Gradle file.
|
|
||||||
|
|
||||||
If you're encountering similar problems with the Play Services and/or Firebase libraries, checkout the sister plugins:
|
|
||||||
- [cordova-android-play-services-gradle-release](https://github.com/dpa99c/cordova-android-play-services-gradle-release)
|
|
||||||
- [cordova-android-firebase-gradle-release](https://github.com/dpa99c/cordova-android-firebase-gradle-release)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
$ cordova plugin add cordova-android-support-gradle-release
|
|
||||||
$ cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION={required version}
|
|
||||||
|
|
||||||
The plugin needs to be installed with the [`cordova-fetch`](https://cordova.apache.org/news/2016/05/24/tools-release.html) mechanism in order to satisfy its [package dependencies](https://github.com/dpa99c/cordova-android-support-gradle-release/blob/master/package.json#L8) by installing it via npm.
|
|
||||||
|
|
||||||
Therefore if you're installing with `cordova@6`, you'll need to explicitly specify the `--fetch` option:
|
|
||||||
|
|
||||||
$ cordova plugin add cordova-android-support-gradle-release --fetch
|
|
||||||
|
|
||||||
# Library versions
|
|
||||||
|
|
||||||
## Default version
|
|
||||||
By default, this plugin will use the major version of the most recent release of the support libraries - [see here](https://developer.android.com/topic/libraries/support-library/revisions.html) for a list recent versions. "Most recent release" means the highest major version that will not result in an Alpha or Beta version being included.
|
|
||||||
|
|
||||||
$ cordova plugin add cordova-android-support-gradle-release
|
|
||||||
|
|
||||||
For example, if the most recent versions are:
|
|
||||||
- `26.0.0 Beta 2`
|
|
||||||
- `25.4.0`
|
|
||||||
|
|
||||||
Then this plugin will default to `25.+` because `26` is still in Beta.
|
|
||||||
|
|
||||||
## Other versions
|
|
||||||
|
|
||||||
In some cases, you may want to specify a different version of the support libraries. For example, [Telerik ImagePicker plugin v2.1.7](https://github.com/Telerik-Verified-Plugins/ImagePicker/tree/2.1.7) specifies `v23` because it contains code that is incompatible with `v24+`.
|
|
||||||
|
|
||||||
In this case, including the default version of this plugin will still result in a build error. So this plugin enables you to specify other versions of the support library using the `ANDROID_SUPPORT_VERSION` plugin variable.
|
|
||||||
|
|
||||||
In the above case, you'd want to install v23 of the support library. To so, you'd specify the version via the variable:
|
|
||||||
|
|
||||||
cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=23.+
|
|
||||||
|
|
||||||
# Example cases
|
|
||||||
|
|
||||||
## Example 1
|
|
||||||
|
|
||||||
Uses v25 of the support libraries to fix the build issue.
|
|
||||||
|
|
||||||
1. `cordova create test1 && cd test1/`
|
|
||||||
2. `cordova platform add android@latest`
|
|
||||||
3. `cordova plugin add cordova-plugin-facebook4@1.9.1 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"`
|
|
||||||
4. `cordova compile`
|
|
||||||
|
|
||||||
Observe the build succeeds and in the console output is `v25.3.1` of Android Support Library:
|
|
||||||
|
|
||||||
:prepareComAndroidSupportSupportV42531Library
|
|
||||||
|
|
||||||
5. `cordova plugin add de.appplant.cordova.plugin.local-notification@0.8.5`
|
|
||||||
6. `cordova compile`
|
|
||||||
|
|
||||||
Observe the build failed and in the console output is higher than `v25.3.1` (e.g `v26.0.0-alpha1`) of Android Support Library:
|
|
||||||
|
|
||||||
:prepareComAndroidSupportSupportV42600Alpha1Library
|
|
||||||
|
|
||||||
7. `cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=25.+`
|
|
||||||
8. `cordova prepare && cordova compile`
|
|
||||||
|
|
||||||
Observe the build succeeds and in the console output is `v25` of Android Support Library.
|
|
||||||
|
|
||||||
## Example 2
|
|
||||||
|
|
||||||
Uses v23 of the support libraries to fix the build issue, because v2.1.7 of the ImagePicker only works with v23.
|
|
||||||
|
|
||||||
1. `cordova create test2 && cd test2/`
|
|
||||||
2. `cordova platform add android@latest`
|
|
||||||
3. `cordova plugin add https://github.com/Telerik-Verified-Plugins/ImagePicker.git#2.1.7`
|
|
||||||
4. `cordova compile`
|
|
||||||
|
|
||||||
Observe the build succeeds and in the console output is `v23.4.0` of Android Support Library:
|
|
||||||
|
|
||||||
:prepareComAndroidSupportSupportV42340Library
|
|
||||||
|
|
||||||
5. `cordova plugin add cordova.plugins.diagnostic@3.6.5`
|
|
||||||
|
|
||||||
Observe the build failed and in the console output is higher than `v23.4.0` (e.g `v26.0.0-alpha1`) of Android Support Library:
|
|
||||||
|
|
||||||
:prepareComAndroidSupportSupportV42600Alpha1Library
|
|
||||||
|
|
||||||
7. `cordova plugin add cordova-android-support-gradle-release`
|
|
||||||
8. `cordova compile`
|
|
||||||
|
|
||||||
Observe the build still failed and in the console output is still higher than `v23.4.0` (e.g `v25.3.1`) of Android Support Library:
|
|
||||||
|
|
||||||
:prepareComAndroidSupportSupportV42531Library
|
|
||||||
|
|
||||||
9. `cordova plugin rm cordova-android-support-gradle-release`
|
|
||||||
10. `cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=23.+`
|
|
||||||
11. `cordova prepare && cordova compile`
|
|
||||||
|
|
||||||
Observe the build succeeds and in the console output is v23 of Android Support Library.
|
|
||||||
|
|
||||||
|
|
||||||
# Credits
|
|
||||||
|
|
||||||
Thanks to [**Chris Scott, Transistor Software**](https://github.com/christocracy) for his idea of extending the initial implementation to support dynamic specification of the library version via a plugin variable in [cordova-google-api-version](https://github.com/transistorsoft/cordova-google-api-version)
|
|
||||||
|
|
||||||
License
|
|
||||||
================
|
|
||||||
|
|
||||||
The MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2017 Dave Alden / Working Edge Ltd.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
|
@ -1,31 +0,0 @@
|
||||||
repositories{
|
|
||||||
// Google APIs are now hosted at Maven
|
|
||||||
maven {
|
|
||||||
url 'https://maven.google.com'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def PLUGIN_NAME = "cordova-android-support-gradle-release"
|
|
||||||
|
|
||||||
// Fetch ANDROID_SUPPORT_VERSION var from properties.gradle
|
|
||||||
apply from: PLUGIN_NAME + '/properties.gradle'
|
|
||||||
|
|
||||||
// List of libs to search for.
|
|
||||||
def LIBS = [
|
|
||||||
'com.android.support'
|
|
||||||
]
|
|
||||||
|
|
||||||
def IGNORED = [
|
|
||||||
'multidex',
|
|
||||||
'multidex-instrumentation'
|
|
||||||
]
|
|
||||||
|
|
||||||
println("+-----------------------------------------------------------------");
|
|
||||||
println("| " + PLUGIN_NAME + ": " + ANDROID_SUPPORT_VERSION);
|
|
||||||
println("+-----------------------------------------------------------------");
|
|
||||||
|
|
||||||
configurations.all {
|
|
||||||
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
|
|
||||||
if (details.requested.group in LIBS && !(details.requested.name in IGNORED)) { details.useVersion ANDROID_SUPPORT_VERSION }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "cordova-android-support-gradle-release@^1.4.4",
|
|
||||||
"_id": "cordova-android-support-gradle-release@1.4.4",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-DOwZ+MX0CBoagXV6cHqfQacVjsrDea8z2wuM427AIvi2eAFvojw85o1XMCdJ4kSDMbsUUaNPw12h7uY0m+rcvg==",
|
|
||||||
"_location": "/cordova-android-support-gradle-release",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "cordova-android-support-gradle-release@^1.4.4",
|
|
||||||
"name": "cordova-android-support-gradle-release",
|
|
||||||
"escapedName": "cordova-android-support-gradle-release",
|
|
||||||
"rawSpec": "^1.4.4",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^1.4.4"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/cordova-android-support-gradle-release/-/cordova-android-support-gradle-release-1.4.4.tgz",
|
|
||||||
"_shasum": "6a64db69f36c332727d95b421d53c25dfe99684d",
|
|
||||||
"_spec": "cordova-android-support-gradle-release@^1.4.4",
|
|
||||||
"_where": "/home/thrrgilag/workspace/cordova/Goober",
|
|
||||||
"author": {
|
|
||||||
"name": "Dave Alden"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"xml2js": "~0.4.19"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Cordova/Phonegap plugin to align various versions of the Android Support libraries specified by other plugins to a specific version",
|
|
||||||
"devDependencies": {},
|
|
||||||
"license": "MIT",
|
|
||||||
"name": "cordova-android-support-gradle-release",
|
|
||||||
"version": "1.4.4"
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
id="cordova-android-support-gradle-release"
|
|
||||||
version="1.4.4">
|
|
||||||
|
|
||||||
<name>cordova-android-support-gradle-release</name>
|
|
||||||
<description>Cordova/Phonegap plugin to align various versions of the Android Support libraries specified by other plugins to a specific version</description>
|
|
||||||
<author>Dave Alden</author>
|
|
||||||
|
|
||||||
<engines>
|
|
||||||
<engine name="cordova" version=">=6.2.0" />
|
|
||||||
<engine name="cordova-android" version=">=6.0.0" />
|
|
||||||
</engines>
|
|
||||||
|
|
||||||
<platform name="android">
|
|
||||||
<hook type="after_prepare" src="scripts/apply-changes.js" />
|
|
||||||
<hook type="before_build" src="scripts/apply-changes.js" />
|
|
||||||
<hook type="after_plugin_install" src="scripts/apply-changes.js" />
|
|
||||||
<preference name="ANDROID_SUPPORT_VERSION" default="27.+" />
|
|
||||||
<framework src="cordova-android-support-gradle-release.gradle" custom="true" type="gradleReference" />
|
|
||||||
<source-file src="properties.gradle" target-dir="cordova-android-support-gradle-release" /> <!-- cordova-android@6-->
|
|
||||||
<source-file src="properties.gradle" target-dir="app/cordova-android-support-gradle-release" /> <!-- cordova-android@7-->
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
</plugin>
|
|
|
@ -1 +0,0 @@
|
||||||
ext {ANDROID_SUPPORT_VERSION = "27.+"}
|
|
|
@ -1,90 +0,0 @@
|
||||||
const PLUGIN_NAME = "cordova-android-support-gradle-release";
|
|
||||||
const V6 = "cordova-android@6";
|
|
||||||
const V7 = "cordova-android@7";
|
|
||||||
const PACKAGE_PATTERN = /(compile "com.android.support:[^:]+:)([^"]+)"/g;
|
|
||||||
const PROPERTIES_TEMPLATE = 'ext {ANDROID_SUPPORT_VERSION = "<VERSION>"}';
|
|
||||||
|
|
||||||
var FILE_PATHS = {};
|
|
||||||
FILE_PATHS[V6] = {
|
|
||||||
"build.gradle": "platforms/android/build.gradle",
|
|
||||||
"properties.gradle": "platforms/android/"+PLUGIN_NAME+"/properties.gradle"
|
|
||||||
};
|
|
||||||
FILE_PATHS[V7] = {
|
|
||||||
"build.gradle": "platforms/android/app/build.gradle",
|
|
||||||
"properties.gradle": "platforms/android/app/"+PLUGIN_NAME+"/properties.gradle"
|
|
||||||
};
|
|
||||||
|
|
||||||
var deferral, fs, path, parser, platformVersion;
|
|
||||||
|
|
||||||
|
|
||||||
function log(message) {
|
|
||||||
console.log(PLUGIN_NAME + ": " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onError(error) {
|
|
||||||
log("ERROR: " + error);
|
|
||||||
deferral.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCordovaAndroidVersion(){
|
|
||||||
var cordovaVersion = require(path.resolve(process.cwd(),'platforms/android/cordova/version'));
|
|
||||||
return parseInt(cordovaVersion.version) === 7 ? V7 : V6;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function run() {
|
|
||||||
try {
|
|
||||||
fs = require('fs');
|
|
||||||
path = require('path');
|
|
||||||
parser = require('xml2js');
|
|
||||||
} catch (e) {
|
|
||||||
throw("Failed to load dependencies. If using cordova@6 CLI, ensure this plugin is installed with the --fetch option: " + e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
platformVersion = getCordovaAndroidVersion();
|
|
||||||
log("Android platform: " + platformVersion);
|
|
||||||
|
|
||||||
var data = fs.readFileSync(path.resolve(process.cwd(), 'config.xml'));
|
|
||||||
parser.parseString(data, attempt(function (err, result) {
|
|
||||||
if (err) throw err;
|
|
||||||
var version, plugins = result.widget.plugin;
|
|
||||||
for (var n = 0, len = plugins.length; n < len; n++) {
|
|
||||||
var plugin = plugins[n];
|
|
||||||
if (plugin.$.name === PLUGIN_NAME && plugin.variable && plugin.variable.length > 0) {
|
|
||||||
version = plugin.variable.pop().$.value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
// build.gradle
|
|
||||||
var buildGradlePath = path.resolve(process.cwd(), FILE_PATHS[platformVersion]["build.gradle"]);
|
|
||||||
var contents = fs.readFileSync(buildGradlePath).toString();
|
|
||||||
fs.writeFileSync(buildGradlePath, contents.replace(PACKAGE_PATTERN, "$1" + version + '"'), 'utf8');
|
|
||||||
log("Wrote custom version '" + version + "' to " + buildGradlePath);
|
|
||||||
|
|
||||||
// properties.gradle
|
|
||||||
var propertiesGradlePath = path.resolve(process.cwd(), FILE_PATHS[platformVersion]["properties.gradle"]);
|
|
||||||
fs.writeFileSync(propertiesGradlePath, PROPERTIES_TEMPLATE.replace(/<VERSION>/, version), 'utf8');
|
|
||||||
log("Wrote custom version '" + version + "' to " + propertiesGradlePath);
|
|
||||||
} else {
|
|
||||||
log("No custom version found in config.xml - using plugin default");
|
|
||||||
}
|
|
||||||
deferral.resolve();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
function attempt(fn) {
|
|
||||||
return function () {
|
|
||||||
try {
|
|
||||||
fn.apply(this, arguments);
|
|
||||||
} catch (e) {
|
|
||||||
onError("EXCEPTION: " + e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = function (ctx) {
|
|
||||||
deferral = ctx.requireCordovaModule('q').defer();
|
|
||||||
attempt(run)();
|
|
||||||
return deferral.promise;
|
|
||||||
};
|
|
|
@ -1,37 +0,0 @@
|
||||||
<!--
|
|
||||||
#
|
|
||||||
# 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!
|
|
|
@ -1,202 +0,0 @@
|
||||||
|
|
||||||
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.
|
|
|
@ -1,5 +0,0 @@
|
||||||
Apache Cordova
|
|
||||||
Copyright 2012 The Apache Software Foundation
|
|
||||||
|
|
||||||
This product includes software developed at
|
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
|
|
@ -1,116 +0,0 @@
|
||||||
---
|
|
||||||
title: Console
|
|
||||||
description: Get JavaScript logs in your native logs.
|
|
||||||
---
|
|
||||||
<!---
|
|
||||||
# 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|AppVeyor|Travis CI|
|
|
||||||
|:-:|:-:|
|
|
||||||
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-console?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-console)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-console)|
|
|
||||||
|
|
||||||
# cordova-plugin-console
|
|
||||||
|
|
||||||
## Deprecated
|
|
||||||
|
|
||||||
> This plugin is no longer being worked on as the functionality provided by this plugin is now included in cordova-ios 4.5.0 or greater, and support is already built in to cordova-windows > 5.0.0. You should upgrade your application to use version 2.0.0 of this plugin. It will detect whether or not the plugin is required based on the version of cordova-ios and cordova-windows your app uses.
|
|
||||||
> Please file issues for this plugin against their respective platforms (cordova-ios, cordova-windows).
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This plugin is meant to ensure that console.log() is as useful as it can be.
|
|
||||||
It adds additional function for iOS, Ubuntu, Windows Phone 8, and Windows. If
|
|
||||||
you are happy with how console.log() works for you, then you probably
|
|
||||||
don't need this plugin.
|
|
||||||
|
|
||||||
This plugin defines a global `console` object.
|
|
||||||
|
|
||||||
Although the object is in the global scope, features provided by this plugin
|
|
||||||
are not available until after the `deviceready` event.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
: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%20Console%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
### Android Quirks
|
|
||||||
|
|
||||||
On some platforms other than Android, console.log() will act on multiple
|
|
||||||
arguments, such as console.log("1", "2", "3"). However, Android will act only
|
|
||||||
on the first argument. Subsequent arguments to console.log() will be ignored.
|
|
||||||
This plugin is not the cause of that, it is a limitation of Android itself.
|
|
||||||
|
|
||||||
## Supported Methods
|
|
||||||
|
|
||||||
The plugin support following methods of the `console` object:
|
|
||||||
|
|
||||||
- `console.log`
|
|
||||||
- `console.error`
|
|
||||||
- `console.exception`
|
|
||||||
- `console.warn`
|
|
||||||
- `console.info`
|
|
||||||
- `console.debug`
|
|
||||||
- `console.assert`
|
|
||||||
- `console.dir`
|
|
||||||
- `console.dirxml`
|
|
||||||
- `console.time`
|
|
||||||
- `console.timeEnd`
|
|
||||||
- `console.table`
|
|
||||||
|
|
||||||
## Partially supported Methods
|
|
||||||
|
|
||||||
Methods of the `console` object which implemented, but behave different from browser implementation:
|
|
||||||
|
|
||||||
- `console.group`
|
|
||||||
- `console.groupCollapsed`
|
|
||||||
|
|
||||||
The grouping methods are just log name of the group and don't actually indicate grouping for later
|
|
||||||
calls to `console` object methods.
|
|
||||||
|
|
||||||
## Not supported Methods
|
|
||||||
|
|
||||||
Methods of the `console` object which are implemented, but do nothing:
|
|
||||||
|
|
||||||
- `console.clear`
|
|
||||||
- `console.trace`
|
|
||||||
- `console.groupEnd`
|
|
||||||
- `console.timeStamp`
|
|
||||||
- `console.profile`
|
|
||||||
- `console.profileEnd`
|
|
||||||
- `console.count`
|
|
||||||
|
|
||||||
## Supported formatting
|
|
||||||
|
|
||||||
The following formatting options available:
|
|
||||||
|
|
||||||
Format chars:
|
|
||||||
|
|
||||||
* `%j` - format arg as JSON
|
|
||||||
* `%o` - format arg as JSON
|
|
||||||
* `%c` - format arg as `''`. No color formatting could be done.
|
|
||||||
* `%%` - replace with `'%'`
|
|
||||||
|
|
||||||
Any other char following `%` will format its arg via `toString()`.
|
|
|
@ -1,126 +0,0 @@
|
||||||
<!--
|
|
||||||
#
|
|
||||||
# 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 (Sep 18, 2017)
|
|
||||||
* [CB-13170](https://issues.apache.org/jira/browse/CB-13170) Integrated this plugin into `cordova-ios@4.5.0`. This plugin will not install for `cordova-ios >= 4.5.0`.
|
|
||||||
* [CB-13028](https://issues.apache.org/jira/browse/CB-13028) (CI) **Browser** builds on `Travis` and `AppVeyor`
|
|
||||||
* [CB-13000](https://issues.apache.org/jira/browse/CB-13000) (CI) Speed up **Android** builds
|
|
||||||
* [CB-12991](https://issues.apache.org/jira/browse/CB-12991) (CI) Updated CI badges
|
|
||||||
* [CB-12935](https://issues.apache.org/jira/browse/CB-12935) (**windows**) Enable paramedic builds on AppVeyor
|
|
||||||
* [CB-12935](https://issues.apache.org/jira/browse/CB-12935) (**ios**, **Android**) Run `paramedic` builds on `Travis`
|
|
||||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
|
||||||
|
|
||||||
### 1.0.7 (Apr 27, 2017)
|
|
||||||
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README`
|
|
||||||
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
|
|
||||||
|
|
||||||
### 1.0.6 (Feb 28, 2017)
|
|
||||||
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
|
|
||||||
* [CB-12230](https://issues.apache.org/jira/browse/CB-12230) Removed **Windows 8.1** build badges
|
|
||||||
|
|
||||||
### 1.0.5 (Dec 07, 2016)
|
|
||||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 1.0.5
|
|
||||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
|
|
||||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
|
||||||
|
|
||||||
### 1.0.4 (Sep 08, 2016)
|
|
||||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to `cordovaDependencies`
|
|
||||||
* add `JIRA` issue tracker link
|
|
||||||
* Add badges for paramedic builds on Jenkins
|
|
||||||
* Add pull request template.
|
|
||||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
|
|
||||||
|
|
||||||
### 1.0.3 (Apr 15, 2016)
|
|
||||||
* [CB-10720](https://issues.apache.org/jira/browse/CB-10720) Minor spelling/formatting changes.
|
|
||||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
|
|
||||||
|
|
||||||
### 1.0.2 (Nov 18, 2015)
|
|
||||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
|
||||||
* Fixing contribute link.
|
|
||||||
* Document formatting options for the console object
|
|
||||||
* [CB-5089](https://issues.apache.org/jira/browse/CB-5089) Document supported methods for console object
|
|
||||||
* reverted `d58f218b9149d362ebb0b8ce697cf403569d14cd` because `logger` is not needed on **Android**
|
|
||||||
|
|
||||||
### 1.0.1 (Jun 17, 2015)
|
|
||||||
* move logger.js and console-via-logger.js to common modules, instead of the numerous repeats that were there.
|
|
||||||
* clean up tests, info is below log level so it does not exist by default.
|
|
||||||
* add a couple tests
|
|
||||||
* [CB-9191](https://issues.apache.org/jira/browse/CB-9191) Add basic test
|
|
||||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-console documentation translation: cordova-plugin-console
|
|
||||||
* attempt to fix 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) updated translated docs to use new id
|
|
||||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
|
||||||
* docs: renamed Windows8 to Windows
|
|
||||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
|
|
||||||
* [CB-8560](https://issues.apache.org/jira/browse/CB-8560) Integrate TravisCI
|
|
||||||
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-console documentation translation: cordova-plugin-console
|
|
||||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
|
||||||
* [CB-8362](https://issues.apache.org/jira/browse/CB-8362) Add Windows platform section to Console plugin
|
|
||||||
|
|
||||||
### 0.2.13 (Feb 04, 2015)
|
|
||||||
* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension
|
|
||||||
|
|
||||||
### 0.2.12 (Dec 02, 2014)
|
|
||||||
* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs
|
|
||||||
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-console documentation translation: cordova-plugin-console
|
|
||||||
|
|
||||||
### 0.2.11 (Sep 17, 2014)
|
|
||||||
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-console documentation translation
|
|
||||||
|
|
||||||
### 0.2.10 (Aug 06, 2014)
|
|
||||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
|
|
||||||
|
|
||||||
### 0.2.9 (Jun 05, 2014)
|
|
||||||
* [CB-6848](https://issues.apache.org/jira/browse/CB-6848) Add Android quirk, list applicable platforms
|
|
||||||
* [CB-6796](https://issues.apache.org/jira/browse/CB-6796) Add license
|
|
||||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
|
||||||
|
|
||||||
### 0.2.8 (Apr 17, 2014)
|
|
||||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
|
|
||||||
* Add NOTICE file
|
|
||||||
|
|
||||||
### 0.2.7 (Feb 05, 2014)
|
|
||||||
* Native console needs to be called DebugConsole to avoid ambiguous reference. This commit requires the 3.4.0 version of the native class factory
|
|
||||||
* [CB-4718](https://issues.apache.org/jira/browse/CB-4718) fixed Console plugin not working on wp
|
|
||||||
|
|
||||||
### 0.2.6 (Jan 02, 2014)
|
|
||||||
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Console plugin
|
|
||||||
|
|
||||||
### 0.2.5 (Dec 4, 2013)
|
|
||||||
* add ubuntu platform
|
|
||||||
|
|
||||||
### 0.2.4 (Oct 28, 2013)
|
|
||||||
* [CB-5154](https://issues.apache.org/jira/browse/CB-5154) log formatting incorrectly to native
|
|
||||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for console plugin
|
|
||||||
* [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
|
|
||||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.console to org.apache.cordova.console
|
|
||||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
|
||||||
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
|
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
Dieses Plugin stellt sicher, dass der Befehl console.log() so hilfreich ist, wie er sein kann. Es fügt zusätzliche Funktion für iOS, Ubuntu, Windows Phone 8 und Windows. Teilweise kann es vorkommen, dass der Befehl console.log() nicht korrekt erkannt wird, und es zu Fehlern bzw. zu nicht angezeigten Logs in der Console kommt. Wenn Sie mit der derzeitigen Funktionsweise zufrieden sind, kann es sein, dass Sie dieses Plugin nicht benötigen.
|
|
||||||
|
|
||||||
Dieses Plugin wird ein global-`console`-Objekt definiert.
|
|
||||||
|
|
||||||
Obwohl das Objekt im globalen Gültigkeitsbereich ist, stehen Features von diesem Plugin nicht bis nach dem `deviceready`-Ereignis.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Android Eigenarten
|
|
||||||
|
|
||||||
Auf einigen Plattformen als Android fungieren console.log() auf mehrere Argumente wie console.log ("1", "2", "3"). Android wird jedoch nur auf das erste Argument fungieren. Nachfolgende Argumente zu console.log() werden ignoriert. Dieses Plugin ist nicht die Verantwortung dafür, es ist eine Einschränkung von Android selbst.
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
Dieses Plugin stellt sicher, dass der Befehl console.log() so hilfreich ist, wie er sein kann. Es fügt zusätzliche Funktion für iOS, Ubuntu, Windows Phone 8 und Windows 8 hinzu. Teilweise kann es vorkommen, dass der Befehl console.log() nicht korrekt erkannt wird, und es zu Fehlern bzw. zu nicht angezeigten Logs in der Console kommt. Wenn Sie mit der derzeitigen Funktionsweise zufrieden sind, kann es sein, dass Sie dieses Plugin nicht benötigen.
|
|
||||||
|
|
||||||
Dieses Plugin wird ein global-`console`-Objekt definiert.
|
|
||||||
|
|
||||||
Obwohl das Objekt im globalen Gültigkeitsbereich ist, stehen Features von diesem Plugin nicht bis nach dem `deviceready`-Ereignis.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Android Eigenarten
|
|
||||||
|
|
||||||
Auf einigen Plattformen als Android fungieren console.log() auf mehrere Argumente wie console.log ("1", "2", "3"). Android wird jedoch nur auf das erste Argument fungieren. Nachfolgende Argumente zu console.log() werden ignoriert. Dieses Plugin ist nicht die Verantwortung dafür, es ist eine Einschränkung von Android selbst.
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
Este plugin es para asegurarse de que console.log() es tan útil como puede ser. Agrega la función adicional para iOS, Ubuntu, Windows Phone 8 y Windows. Si estás contento con cómo funciona console.log() para ti, entonces probablemente no necesitas este plugin.
|
|
||||||
|
|
||||||
Este plugin define un global `console` objeto.
|
|
||||||
|
|
||||||
Aunque el objeto está en el ámbito global, características proporcionadas por este plugin no están disponibles hasta después de la `deviceready` evento.
|
|
||||||
|
|
||||||
document.addEventListener ("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {console.log ("console.log funciona bien");}
|
|
||||||
|
|
||||||
|
|
||||||
## Instalación
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Rarezas Android
|
|
||||||
|
|
||||||
En algunas plataformas que no sean Android, console.log() actuará en varios argumentos, como console.log ("1", "2", "3"). Sin embargo, Android actuará sólo en el primer argumento. Se omitirá posteriores argumentos para console.log(). Este plugin no es la causa de eso, es una limitación propia de Android.
|
|
|
@ -1,39 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
Este plugin es para asegurarse de que console.log() es tan útil como puede ser. Añade función adicional para iOS, Windows Phone 8, Ubuntu y Windows 8. Si estás contento con cómo funciona console.log() para ti, entonces probablemente no necesitas este plugin.
|
|
||||||
|
|
||||||
Este plugin define un global `console` objeto.
|
|
||||||
|
|
||||||
Aunque el objeto está en el ámbito global, características proporcionadas por este plugin no están disponibles hasta después de la `deviceready` evento.
|
|
||||||
|
|
||||||
document.addEventListener ("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {console.log ("console.log funciona bien");}
|
|
||||||
|
|
||||||
|
|
||||||
## Instalación
|
|
||||||
|
|
||||||
Cordova plugin agregar cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Rarezas Android
|
|
||||||
|
|
||||||
En algunas plataformas que no sean Android, console.log() actuará en varios argumentos, como console.log ("1", "2", "3"). Sin embargo, Android actuará sólo en el primer argumento. Se omitirá posteriores argumentos para console.log(). Este plugin no es la causa de eso, es una limitación propia de Android.
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
Ce plugin est destiné à faire en sorte que console.log() est aussi utile que possible. Il ajoute une fonction supplémentaire pour iOS, Ubuntu, Windows Phone 8 et Windows. Si vous êtes satisfait du fonctionnement de console.log() pour vous, alors vous avez probablement pas besoin ce plugin.
|
|
||||||
|
|
||||||
Ce plugin définit un global `console` objet.
|
|
||||||
|
|
||||||
Bien que l'objet est dans la portée globale, les fonctions offertes par ce plugin ne sont pas disponibles jusqu'après la `deviceready` événement.
|
|
||||||
|
|
||||||
document.addEventListener (« deviceready », onDeviceReady, false) ;
|
|
||||||
function onDeviceReady() {console.log ("console.log fonctionne bien");}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Quirks Android
|
|
||||||
|
|
||||||
Sur certaines plateformes autres que Android, console.log() va agir sur plusieurs arguments, tels que console.log ("1", "2", "3"). Toutefois, Android doit agir uniquement sur le premier argument. Les arguments suivants à console.log() seront ignorées. Ce plugin n'est pas la cause de cela, il s'agit d'une limitation d'Android lui-même.
|
|
|
@ -1,39 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
Ce plugin est destiné à faire en sorte que console.log() est aussi utile que possible. Il ajoute une fonction supplémentaire pour iOS, Ubuntu, Windows Phone 8 et Windows 8. Si vous êtes satisfait du fonctionnement de console.log() pour vous, alors vous avez probablement pas besoin ce plugin.
|
|
||||||
|
|
||||||
Ce plugin définit un global `console` objet.
|
|
||||||
|
|
||||||
Bien que l'objet est dans la portée globale, les fonctions offertes par ce plugin ne sont pas disponibles jusqu'après la `deviceready` événement.
|
|
||||||
|
|
||||||
document.addEventListener (« deviceready », onDeviceReady, false) ;
|
|
||||||
function onDeviceReady() {console.log ("console.log fonctionne bien");}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Cordova plugin ajouter cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Quirks Android
|
|
||||||
|
|
||||||
Sur certaines plateformes autres que Android, console.log() va agir sur plusieurs arguments, tels que console.log ("1", "2", "3"). Toutefois, Android doit agir uniquement sur le premier argument. Les arguments suivants à console.log() seront ignorées. Ce plugin n'est pas la cause de cela, il s'agit d'une limitation d'Android lui-même.
|
|
|
@ -1,43 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
Questo plugin è intesa a garantire che console.log() è tanto utile quanto può essere. Aggiunge una funzione aggiuntiva per iOS, Ubuntu, Windows Phone 8 e Windows. Se sei soddisfatto di come console.log() funziona per voi, quindi probabilmente non è necessario questo plugin.
|
|
||||||
|
|
||||||
Questo plugin definisce un oggetto globale `console`.
|
|
||||||
|
|
||||||
Sebbene l'oggetto sia in ambito globale, funzionalità fornite da questo plugin non sono disponibili fino a dopo l'evento `deviceready`.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installazione
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Stranezze Android
|
|
||||||
|
|
||||||
Su alcune piattaforme diverse da Android, console.log() agirà su più argomenti, come ad esempio console ("1", "2", "3"). Tuttavia, Android agirà solo sul primo argomento. Argomenti successivi a console.log() verranno ignorati. Questo plugin non è la causa di ciò, è una limitazione di Android stesso.
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
Questo plugin è intesa a garantire che console.log() è tanto utile quanto può essere. Aggiunge una funzione aggiuntiva per iOS, Ubuntu, Windows 8 e Windows Phone 8. Se sei soddisfatto di come console.log() funziona per voi, quindi probabilmente non è necessario questo plugin.
|
|
||||||
|
|
||||||
Questo plugin definisce un oggetto globale `console`.
|
|
||||||
|
|
||||||
Sebbene l'oggetto sia in ambito globale, funzionalità fornite da questo plugin non sono disponibili fino a dopo l'evento `deviceready`.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installazione
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Stranezze Android
|
|
||||||
|
|
||||||
Su alcune piattaforme diverse da Android, console.log() agirà su più argomenti, come ad esempio console ("1", "2", "3"). Tuttavia, Android agirà solo sul primo argomento. Argomenti successivi a console.log() verranno ignorati. Questo plugin non è la causa di ciò, è una limitazione di Android stesso.
|
|
|
@ -1,43 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
このプラグインは、その console.log() がすることができます便利なことを確認するものです。 それは iOS、Ubuntu、Windows Phone 8 は、Windows に追加の関数を追加します。 場合はあなたのための console.log() の作品に満足しているし、おそらく必要はありませんこのプラグイン。
|
|
||||||
|
|
||||||
このプラグインでは、グローバル ・ `console` オブジェクトを定義します。
|
|
||||||
|
|
||||||
オブジェクトは、グローバル スコープでですが、このプラグインによって提供される機能は、`deviceready` イベントの後まで使用できません。
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## インストール
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Android の癖
|
|
||||||
|
|
||||||
アンドロイド以外のいくつかのプラットフォームで console.log() は console.log (「1」、「2」、「3」) など、複数の引数に動作します。 しかし、アンドロイドは、最初の引数でのみ動作します。 console.log() に後続の引数は無視されます。 このプラグインが原因ではない、それは Android の自体の制限です。
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
このプラグインは、その console.log() がすることができます便利なことを確認するものです。 それは、iOS、Ubuntu、Windows Phone 8 および Windows 8 の追加関数を追加します。 場合はあなたのための console.log() の作品に満足しているし、おそらく必要はありませんこのプラグイン。
|
|
||||||
|
|
||||||
このプラグインでは、グローバル ・ `console` オブジェクトを定義します。
|
|
||||||
|
|
||||||
オブジェクトは、グローバル スコープでですが、このプラグインによって提供される機能は、`deviceready` イベントの後まで使用できません。
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## インストール
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Android の癖
|
|
||||||
|
|
||||||
アンドロイド以外のいくつかのプラットフォームで console.log() は console.log (「1」、「2」、「3」) など、複数の引数に動作します。 しかし、アンドロイドは、最初の引数でのみ動作します。 console.log() に後続の引数は無視されます。 このプラグインが原因ではない、それは Android の自体の制限です。
|
|
|
@ -1,43 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
이 플러그인을 console.log()로 수 유용 되도록 의미입니다. 그것은 iOS, 우분투, Windows Phone 8, 및 창에 대 한 추가 기능을 추가합니다. Console.log() 당신을 위해 작동 하는 어떻게 행복 한 경우에, 그때 당신은 아마 필요 하지 않습니다이 플러그인.
|
|
||||||
|
|
||||||
이 플러그인 글로벌 `console` 개체를 정의합니다.
|
|
||||||
|
|
||||||
개체가 전역 범위에 있지만,이 플러그인에 의해 제공 되는 기능 하지 사용할 수 있습니다까지 `deviceready` 이벤트 후.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## 설치
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### 안 드 로이드 단점
|
|
||||||
|
|
||||||
안 드 로이드 이외의 일부 플랫폼에서 console.log() console.log ("1", "2", "3")와 같이 여러 인수에 작동할 것 이다. 그러나, 안 드 로이드는 첫 번째 인수에만 작동할 것 이다. Console.log() 후속 인수는 무시 됩니다. 이 플러그인의 원인이 되지 않습니다, 그리고 그것은 안 드 로이드 자체의 한계입니다.
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
이 플러그인을 console.log()로 수 유용 되도록 의미입니다. IOS, 우분투, Windows Phone 8 및 윈도우 8에 대 한 추가 기능을 추가 하 고 합니다. Console.log() 당신을 위해 작동 하는 어떻게 행복 한 경우에, 그때 당신은 아마 필요 하지 않습니다이 플러그인.
|
|
||||||
|
|
||||||
이 플러그인 글로벌 `console` 개체를 정의합니다.
|
|
||||||
|
|
||||||
개체가 전역 범위에 있지만,이 플러그인에 의해 제공 되는 기능 하지 사용할 수 있습니다까지 `deviceready` 이벤트 후.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## 설치
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### 안 드 로이드 단점
|
|
||||||
|
|
||||||
안 드 로이드 이외의 일부 플랫폼에서 console.log() console.log ("1", "2", "3")와 같이 여러 인수에 작동할 것 이다. 그러나, 안 드 로이드는 첫 번째 인수에만 작동할 것 이다. Console.log() 후속 인수는 무시 됩니다. 이 플러그인의 원인이 되지 않습니다, 그리고 그것은 안 드 로이드 자체의 한계입니다.
|
|
|
@ -1,43 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
Ten plugin jest przeznaczona do zapewnienia, że console.log() jest tak przydatne, jak to może być. To dodaje dodatkową funkcję dla iOS, Ubuntu, Windows Phone 8 i Windows. Jeśli jesteś zadowolony z jak console.log() pracuje dla Ciebie, wtedy prawdopodobnie nie potrzebują tej wtyczki.
|
|
||||||
|
|
||||||
Ten plugin definiuje obiekt globalny `console`.
|
|
||||||
|
|
||||||
Mimo, że obiekt jest w globalnym zasięgu, funkcji oferowanych przez ten plugin nie są dostępne dopiero po turnieju `deviceready`.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Instalacja
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Dziwactwa Androida
|
|
||||||
|
|
||||||
Na niektórych platformach innych niż Android console.log() będzie działać na wielu argumentów, takich jak console.log ("1", "2", "3"). Jednak Android będzie działać tylko na pierwszy argument. Kolejne argumenty do console.log() będą ignorowane. Ten plugin nie jest przyczyną, że, jest to ograniczenie Androida, sam.
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
Ten plugin jest przeznaczona do zapewnienia, że console.log() jest tak przydatne, jak to może być. To dodaje dodatkową funkcję dla iOS, Ubuntu, Windows Phone 8 i Windows 8. Jeśli jesteś zadowolony z jak console.log() pracuje dla Ciebie, wtedy prawdopodobnie nie potrzebują tej wtyczki.
|
|
||||||
|
|
||||||
Ten plugin definiuje obiekt globalny `console`.
|
|
||||||
|
|
||||||
Mimo, że obiekt jest w globalnym zasięgu, funkcji oferowanych przez ten plugin nie są dostępne dopiero po turnieju `deviceready`.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Instalacja
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Dziwactwa Androida
|
|
||||||
|
|
||||||
Na niektórych platformach innych niż Android console.log() będzie działać na wielu argumentów, takich jak console.log ("1", "2", "3"). Jednak Android będzie działać tylko na pierwszy argument. Kolejne argumenty do console.log() będą ignorowane. Ten plugin nie jest przyczyną, że, jest to ograniczenie Androida, sam.
|
|
|
@ -1,31 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
Этот плагин предназначен для обеспечения как полезным, поскольку это может быть что console.log(). Он добавляет дополнительные функции для iOS, Ubuntu, Windows Phone 8 и Windows 8. Если вы не довольны как console.log() работает для вас, то вы вероятно не нужен этот плагин.
|
|
||||||
|
|
||||||
## Установка
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Особенности Android
|
|
||||||
|
|
||||||
На некоторых платформах, отличных от Android console.log() будет действовать на нескольких аргументов, например console.log («1», «2», «3»). Тем не менее Android будет действовать только на первого аргумента. Последующие аргументы для console.log() будет игнорироваться. Этот плагин не является причиной этого, это ограничение Android сам.
|
|
|
@ -1,43 +0,0 @@
|
||||||
<!---
|
|
||||||
# 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-console
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg)](https://travis-ci.org/apache/cordova-plugin-console)
|
|
||||||
|
|
||||||
這個外掛程式是為了確保該 console.log() 是一樣有用,它可以是。 它將添加附加功能的 iOS,Ubuntu,Windows Phone 8 和視窗。 如果你是快樂與 console.log() 是如何為你工作,那麼可能不需要這個外掛程式。
|
|
||||||
|
|
||||||
這個外掛程式定義了一個全域 `console` 物件。
|
|
||||||
|
|
||||||
儘管物件是在全球範圍內,提供這個外掛程式的功能不可用直到 `deviceready` 事件之後。
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## 安裝
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Android 的怪癖
|
|
||||||
|
|
||||||
在一些平臺上除了 Android,console.log() 亦會根據多個參數,如 console.log ("1"、"2"、"3")。 然而,安卓系統只亦會根據第一個參數。 對 console.log() 的後續參數將被忽略。 這個外掛程式不是的原因,它是一個 android 作業系統本身的限制。
|
|
|
@ -1,41 +0,0 @@
|
||||||
<!---
|
|
||||||
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-console
|
|
||||||
|
|
||||||
這個外掛程式是為了確保該 console.log() 是一樣有用,它可以是。 它將添加附加功能的 iOS、 Ubuntu,Windows Phone 8 和 Windows 8。 如果你是快樂與 console.log() 是如何為你工作,那麼可能不需要這個外掛程式。
|
|
||||||
|
|
||||||
這個外掛程式定義了一個全域 `console` 物件。
|
|
||||||
|
|
||||||
儘管物件是在全球範圍內,提供這個外掛程式的功能不可用直到 `deviceready` 事件之後。
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log("console.log works well");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## 安裝
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-console
|
|
||||||
|
|
||||||
|
|
||||||
### Android 的怪癖
|
|
||||||
|
|
||||||
在一些平臺上除了 Android,console.log() 亦會根據多個參數,如 console.log ("1"、"2"、"3")。 然而,安卓系統只亦會根據第一個參數。 對 console.log() 的後續參數將被忽略。 這個外掛程式不是的原因,它是一個 android 作業系統本身的限制。
|
|
|
@ -1,80 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "cordova-plugin-console@^1.1.0",
|
|
||||||
"_id": "cordova-plugin-console@1.1.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-4vusECkBeeRMtyxf28QQpTHBzW0=",
|
|
||||||
"_location": "/cordova-plugin-console",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "cordova-plugin-console@^1.1.0",
|
|
||||||
"name": "cordova-plugin-console",
|
|
||||||
"escapedName": "cordova-plugin-console",
|
|
||||||
"rawSpec": "^1.1.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^1.1.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/cordova-plugin-console/-/cordova-plugin-console-1.1.0.tgz",
|
|
||||||
"_shasum": "e2fbac10290179e44cb72c5fdbc410a531c1cd6d",
|
|
||||||
"_spec": "cordova-plugin-console@^1.1.0",
|
|
||||||
"_where": "/home/thrrgilag/workspace/cordova/Goober",
|
|
||||||
"author": {
|
|
||||||
"name": "Apache Software Foundation"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://issues.apache.org/jira/browse/CB"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"cordova": {
|
|
||||||
"id": "cordova-plugin-console",
|
|
||||||
"platforms": [
|
|
||||||
"ios",
|
|
||||||
"ubuntu",
|
|
||||||
"wp7",
|
|
||||||
"wp8",
|
|
||||||
"windows8",
|
|
||||||
"windows"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"deprecated": "This plugin has been deprecated since it is now included in the latest versions of cordova-ios",
|
|
||||||
"description": "Cordova Console Plugin",
|
|
||||||
"devDependencies": {
|
|
||||||
"jshint": "^2.6.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"cordovaDependencies": {
|
|
||||||
">=2.0.0": {
|
|
||||||
"cordova-ios": "<4.5.0",
|
|
||||||
"cordova-windows": "<=5.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/apache/cordova-plugin-console#readme",
|
|
||||||
"keywords": [
|
|
||||||
"cordova",
|
|
||||||
"console",
|
|
||||||
"ecosystem:cordova",
|
|
||||||
"cordova-ios",
|
|
||||||
"cordova-ubuntu",
|
|
||||||
"cordova-wp7",
|
|
||||||
"cordova-wp8",
|
|
||||||
"cordova-windows8",
|
|
||||||
"cordova-windows"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"name": "cordova-plugin-console",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/apache/cordova-plugin-console.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests",
|
|
||||||
"test": "npm run jshint"
|
|
||||||
},
|
|
||||||
"version": "1.1.0"
|
|
||||||
}
|
|
|
@ -1,132 +0,0 @@
|
||||||
<?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"
|
|
||||||
id="cordova-plugin-console"
|
|
||||||
version="1.1.0">
|
|
||||||
|
|
||||||
<name>Console</name>
|
|
||||||
<description>Cordova Console Plugin</description>
|
|
||||||
<license>Apache 2.0</license>
|
|
||||||
<keywords>cordova,console</keywords>
|
|
||||||
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git</repo>
|
|
||||||
<issue>https://issues.apache.org/jira/browse/CB/component/12320644</issue>
|
|
||||||
|
|
||||||
<engines>
|
|
||||||
<engine name="cordova-windows" version="<=5.0.0"/>
|
|
||||||
<engine name="cordova-ios" version="<4.5.0"/>
|
|
||||||
</engines>
|
|
||||||
|
|
||||||
<!-- ios -->
|
|
||||||
<platform name="ios">
|
|
||||||
|
|
||||||
<config-file target="config.xml" parent="/*">
|
|
||||||
<feature name="Console">
|
|
||||||
<param name="ios-package" value="CDVLogger"/>
|
|
||||||
</feature>
|
|
||||||
</config-file>
|
|
||||||
|
|
||||||
<js-module src="www/console-via-logger.js" name="console">
|
|
||||||
<clobbers target="console" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<js-module src="www/logger.js" name="logger">
|
|
||||||
<clobbers target="cordova.logger" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<header-file src="src/ios/CDVLogger.h" />
|
|
||||||
<source-file src="src/ios/CDVLogger.m" />
|
|
||||||
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
<!-- ubuntu -->
|
|
||||||
<platform name="ubuntu">
|
|
||||||
<js-module src="www/console-via-logger.js" name="console">
|
|
||||||
<clobbers target="console" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<js-module src="www/logger.js" name="logger">
|
|
||||||
<clobbers target="cordova.logger" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<header-file src="src/ubuntu/console.h" />
|
|
||||||
<source-file src="src/ubuntu/console.cpp" />
|
|
||||||
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
<!-- wp7 -->
|
|
||||||
<platform name="wp7">
|
|
||||||
<config-file target="config.xml" parent="/*">
|
|
||||||
<feature name="Console">
|
|
||||||
<param name="wp-package" value="DebugConsole"/>
|
|
||||||
</feature>
|
|
||||||
</config-file>
|
|
||||||
|
|
||||||
<js-module src="www/console-via-logger.js" name="console">
|
|
||||||
<clobbers target="console" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<js-module src="www/logger.js" name="logger">
|
|
||||||
<clobbers target="cordova.logger" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<source-file src="src/wp/DebugConsole.cs" />
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
<!-- wp8 -->
|
|
||||||
<platform name="wp8">
|
|
||||||
<config-file target="config.xml" parent="/*">
|
|
||||||
<feature name="Console">
|
|
||||||
<param name="wp-package" value="DebugConsole"/>
|
|
||||||
</feature>
|
|
||||||
</config-file>
|
|
||||||
|
|
||||||
<js-module src="www/console-via-logger.js" name="console">
|
|
||||||
<clobbers target="console" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<js-module src="www/logger.js" name="logger">
|
|
||||||
<clobbers target="cordova.logger" />
|
|
||||||
</js-module>
|
|
||||||
|
|
||||||
<source-file src="src/wp/DebugConsole.cs" />
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
<!-- windows8 -->
|
|
||||||
<platform name="windows8">
|
|
||||||
<js-module src="www/logger.js" name="logger">
|
|
||||||
<clobbers target="cordova.logger" />
|
|
||||||
</js-module>
|
|
||||||
<js-module src="www/console-via-logger.js" name="console">
|
|
||||||
<clobbers target="console" />
|
|
||||||
</js-module>
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
<!-- Windows universal platform -->
|
|
||||||
<platform name="windows">
|
|
||||||
<js-module src="www/logger.js" name="logger">
|
|
||||||
<clobbers target="cordova.logger" />
|
|
||||||
</js-module>
|
|
||||||
<js-module src="www/console-via-logger.js" name="console">
|
|
||||||
<clobbers target="console" />
|
|
||||||
</js-module>
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
</plugin>
|
|
|
@ -1,26 +0,0 @@
|
||||||
/*
|
|
||||||
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 <Cordova/CDVPlugin.h>
|
|
||||||
|
|
||||||
@interface CDVLogger : CDVPlugin
|
|
||||||
|
|
||||||
- (void)logLevel:(CDVInvokedUrlCommand*)command;
|
|
||||||
|
|
||||||
@end
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
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 "CDVLogger.h"
|
|
||||||
#import <Cordova/CDV.h>
|
|
||||||
|
|
||||||
@implementation CDVLogger
|
|
||||||
|
|
||||||
/* log a message */
|
|
||||||
- (void)logLevel:(CDVInvokedUrlCommand*)command
|
|
||||||
{
|
|
||||||
id level = [command argumentAtIndex:0];
|
|
||||||
id message = [command argumentAtIndex:1];
|
|
||||||
|
|
||||||
if ([level isEqualToString:@"LOG"]) {
|
|
||||||
NSLog(@"%@", message);
|
|
||||||
} else {
|
|
||||||
NSLog(@"%@: %@", level, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 "console.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
Console::Console(Cordova *cordova) : CPlugin(cordova) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Console::logLevel(int scId, int ecId, QString level, QString message) {
|
|
||||||
Q_UNUSED(scId)
|
|
||||||
Q_UNUSED(ecId)
|
|
||||||
|
|
||||||
if (level != "LOG")
|
|
||||||
std::cout << "[" << level.toStdString() << "] ";
|
|
||||||
std::cout << message.toStdString() << std::endl;
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 CONSOLE_H_FDSVCXGFRS
|
|
||||||
#define CONSOLE_H_FDSVCXGFRS
|
|
||||||
|
|
||||||
#include <cplugin.h>
|
|
||||||
|
|
||||||
#include <QtCore>
|
|
||||||
|
|
||||||
class Console : public CPlugin {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit Console(Cordova *cordova);
|
|
||||||
|
|
||||||
virtual const QString fullName() override {
|
|
||||||
return Console::fullID();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual const QString shortName() override {
|
|
||||||
return "Console";
|
|
||||||
}
|
|
||||||
|
|
||||||
static const QString fullID() {
|
|
||||||
return "Console";
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void logLevel(int scId, int ecId, QString level, QString message);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
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 System;
|
|
||||||
using System.Net;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Ink;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Animation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace WPCordovaClassLib.Cordova.Commands
|
|
||||||
{
|
|
||||||
public class DebugConsole : BaseCommand
|
|
||||||
{
|
|
||||||
public void logLevel(string options)
|
|
||||||
{
|
|
||||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
|
||||||
string level = args[0];
|
|
||||||
string msg = args[1];
|
|
||||||
|
|
||||||
if (level.Equals("LOG"))
|
|
||||||
{
|
|
||||||
Debug.WriteLine(msg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.WriteLine(level + ": " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"name": "cordova-plugin-console-tests",
|
|
||||||
"version": "1.0.7-dev",
|
|
||||||
"description": "",
|
|
||||||
"cordova": {
|
|
||||||
"id": "cordova-plugin-console-tests",
|
|
||||||
"platforms": []
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"ecosystem:cordova"
|
|
||||||
],
|
|
||||||
"author": "",
|
|
||||||
"license": "Apache 2.0"
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?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-console-tests"
|
|
||||||
version="2.0.1-dev">
|
|
||||||
<name>Cordova Console Plugin Tests</name>
|
|
||||||
<license>Apache 2.0</license>
|
|
||||||
|
|
||||||
<js-module src="tests.js" name="tests">
|
|
||||||
</js-module>
|
|
||||||
</plugin>
|
|
43
plugins/cordova-plugin-console/tests/tests.js
vendored
43
plugins/cordova-plugin-console/tests/tests.js
vendored
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* jshint jasmine: true */
|
|
||||||
|
|
||||||
exports.defineAutoTests = function () {
|
|
||||||
describe("Console", function () {
|
|
||||||
it("console.spec.1 should exist", function() {
|
|
||||||
expect(window.console).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("console.spec.2 has required methods log|warn|error", function(){
|
|
||||||
expect(window.console.log).toBeDefined();
|
|
||||||
expect(typeof window.console.log).toBe('function');
|
|
||||||
|
|
||||||
expect(window.console.warn).toBeDefined();
|
|
||||||
expect(typeof window.console.warn).toBe('function');
|
|
||||||
|
|
||||||
expect(window.console.error).toBeDefined();
|
|
||||||
expect(typeof window.console.error).toBe('function');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.defineManualTests = function (contentEl, createActionButton) {};
|
|
|
@ -1,37 +0,0 @@
|
||||||
<!--
|
|
||||||
#
|
|
||||||
# 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!
|
|
|
@ -1,202 +0,0 @@
|
||||||
|
|
||||||
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.
|
|
|
@ -1,5 +0,0 @@
|
||||||
Apache Cordova
|
|
||||||
Copyright 2012 The Apache Software Foundation
|
|
||||||
|
|
||||||
This product includes software developed at
|
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
|
|
@ -1,267 +0,0 @@
|
||||||
---
|
|
||||||
title: Device
|
|
||||||
description: Get device information.
|
|
||||||
---
|
|
||||||
<!--
|
|
||||||
# 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|AppVeyor|Travis CI|
|
|
||||||
|:-:|:-:|
|
|
||||||
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-device?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-device)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device)|
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
```js
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(device.cordova);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Report issues with this plugin 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.manufacturer
|
|
||||||
- device.isVirtual
|
|
||||||
- device.serial
|
|
||||||
|
|
||||||
## device.cordova
|
|
||||||
|
|
||||||
Get the version of Cordova running on the device.
|
|
||||||
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android
|
|
||||||
- Browser
|
|
||||||
- iOS
|
|
||||||
- Windows
|
|
||||||
- OSX
|
|
||||||
|
|
||||||
## device.model
|
|
||||||
|
|
||||||
The `device.model` returns the name of the device's model or
|
|
||||||
product. The value is set by the device manufacturer and may be
|
|
||||||
different across versions of the same product.
|
|
||||||
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android
|
|
||||||
- Browser
|
|
||||||
- iOS
|
|
||||||
- Windows
|
|
||||||
- OSX
|
|
||||||
|
|
||||||
### Quick Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// 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
|
|
||||||
// OSX: returns "x86_64"
|
|
||||||
//
|
|
||||||
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`.
|
|
||||||
|
|
||||||
## device.platform
|
|
||||||
|
|
||||||
Get the device's operating system name.
|
|
||||||
|
|
||||||
```js
|
|
||||||
var string = device.platform;
|
|
||||||
```
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android
|
|
||||||
- Browser
|
|
||||||
- iOS
|
|
||||||
- Windows
|
|
||||||
- OSX
|
|
||||||
|
|
||||||
### Quick Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Depending on the device, a few examples are:
|
|
||||||
// - "Android"
|
|
||||||
// - "BlackBerry 10"
|
|
||||||
// - "browser"
|
|
||||||
// - "iOS"
|
|
||||||
// - "WinCE"
|
|
||||||
// - "Tizen"
|
|
||||||
// - "Mac OS X"
|
|
||||||
var devicePlatform = device.platform;
|
|
||||||
```
|
|
||||||
|
|
||||||
## device.uuid
|
|
||||||
|
|
||||||
Get the device's Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
|
||||||
|
|
||||||
```js
|
|
||||||
var string = device.uuid;
|
|
||||||
```
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
The details of how a UUID is generated are determined by the device manufacturer and are specific to the device's platform or model.
|
|
||||||
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android
|
|
||||||
- iOS
|
|
||||||
- Windows
|
|
||||||
- OSX
|
|
||||||
|
|
||||||
### Quick Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// 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.
|
|
||||||
// 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.
|
|
||||||
Refer [here](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor) for details.
|
|
||||||
The UUID will be the same if app is restored from a backup or iCloud as it is saved in preferences. Users using older versions of this plugin will still receive the same previous UUID generated by another means as it will be retrieved from preferences.
|
|
||||||
|
|
||||||
### OSX Quirk
|
|
||||||
|
|
||||||
The `uuid` on OSX is generated automatically if it does not exist yet and is stored in the `standardUserDefaults` in the `CDVUUID` property.
|
|
||||||
|
|
||||||
## device.version
|
|
||||||
|
|
||||||
Get the operating system version.
|
|
||||||
|
|
||||||
var string = device.version;
|
|
||||||
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android 2.1+
|
|
||||||
- Browser
|
|
||||||
- iOS
|
|
||||||
- Windows
|
|
||||||
- OSX
|
|
||||||
|
|
||||||
### Quick Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// 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"
|
|
||||||
// OSX: El Capitan would return "10.11.2"
|
|
||||||
//
|
|
||||||
var deviceVersion = device.version;
|
|
||||||
```
|
|
||||||
|
|
||||||
## device.manufacturer
|
|
||||||
|
|
||||||
Get the device's manufacturer.
|
|
||||||
|
|
||||||
var string = device.manufacturer;
|
|
||||||
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android
|
|
||||||
- iOS
|
|
||||||
- Windows
|
|
||||||
|
|
||||||
### Quick Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Android: Motorola XT1032 would return "motorola"
|
|
||||||
// BlackBerry: returns "BlackBerry"
|
|
||||||
// iPhone: returns "Apple"
|
|
||||||
//
|
|
||||||
var deviceManufacturer = device.manufacturer;
|
|
||||||
```
|
|
||||||
|
|
||||||
## device.isVirtual
|
|
||||||
|
|
||||||
whether the device is running on a simulator.
|
|
||||||
|
|
||||||
```js
|
|
||||||
var isSim = device.isVirtual;
|
|
||||||
```
|
|
||||||
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android 2.1+
|
|
||||||
- Browser
|
|
||||||
- iOS
|
|
||||||
- Windows
|
|
||||||
- OSX
|
|
||||||
|
|
||||||
### OSX and Browser Quirk
|
|
||||||
|
|
||||||
The `isVirtual` property on OS X and Browser always returns false.
|
|
||||||
|
|
||||||
## device.serial
|
|
||||||
|
|
||||||
Get the device hardware serial number ([SERIAL](http://developer.android.com/reference/android/os/Build.html#SERIAL)).
|
|
||||||
|
|
||||||
```js
|
|
||||||
var string = device.serial;
|
|
||||||
```
|
|
||||||
|
|
||||||
### Supported Platforms
|
|
||||||
|
|
||||||
- Android
|
|
||||||
- OSX
|
|
||||||
|
|
|
@ -1,181 +0,0 @@
|
||||||
<!--
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
|
|
||||||
### 2.0.2 (Apr 12, 2018)
|
|
||||||
* [CB-13893](https://issues.apache.org/jira/browse/CB-13893) **iOS** delete `libz.tbd` from device plugin
|
|
||||||
|
|
||||||
### 2.0.1 (Dec 27, 2017)
|
|
||||||
* [CB-13702](https://issues.apache.org/jira/browse/CB-13702) Fix to allow 2.0.0 version install
|
|
||||||
|
|
||||||
### 2.0.0 (Dec 15, 2017)
|
|
||||||
* [CB-13670](https://issues.apache.org/jira/browse/CB-13670) Remove deprecated platforms
|
|
||||||
|
|
||||||
### 1.1.7 (Nov 06, 2017)
|
|
||||||
* [CB-13472](https://issues.apache.org/jira/browse/CB-13472) (CI) Fixed Travis **Android** builds again
|
|
||||||
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) setup `eslint` and removed `jshint`
|
|
||||||
* [CB-13113](https://issues.apache.org/jira/browse/CB-13113) (browser) `device.isVirtual` is always false
|
|
||||||
* [CB-13028](https://issues.apache.org/jira/browse/CB-13028) (CI) **Browser** builds on Travis and AppVeyor
|
|
||||||
* [CB-13000](https://issues.apache.org/jira/browse/CB-13000) (CI) Speed up **Android** builds
|
|
||||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
|
||||||
|
|
||||||
### 1.1.6 (Apr 27, 2017)
|
|
||||||
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README`
|
|
||||||
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
|
|
||||||
* [CB-12105](https://issues.apache.org/jira/browse/CB-12105) (browser) Properly detect Edge
|
|
||||||
|
|
||||||
### 1.1.5 (Feb 28, 2017)
|
|
||||||
* [CB-12353](https://issues.apache.org/jira/browse/CB-12353) Corrected merges usage in `plugin.xml`
|
|
||||||
* [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped`
|
|
||||||
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
|
|
||||||
* [CB-12230](https://issues.apache.org/jira/browse/CB-12230) Removed **Windows 8.1** build badges
|
|
||||||
|
|
||||||
### 1.1.4 (Dec 07, 2016)
|
|
||||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 1.1.4
|
|
||||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
|
|
||||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
|
||||||
|
|
||||||
### 1.1.3 (Sep 08, 2016)
|
|
||||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
|
|
||||||
* Add badges for paramedic builds on Jenkins
|
|
||||||
* Add pull request template.
|
|
||||||
* Readme: Add fenced code blocks with langauage hints
|
|
||||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to `README.md`
|
|
||||||
|
|
||||||
### 1.1.2 (Apr 15, 2016)
|
|
||||||
* Use passed device, follow create policy forf `CFUUIDCreate`
|
|
||||||
* [CB-10631](https://issues.apache.org/jira/browse/CB-10631) Fix for `device.uuid` in **iOS 5.1.1**
|
|
||||||
* Updating the comment to exclude URL
|
|
||||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
|
|
||||||
* Refactored `deviceInfo` on **iOS** for better readability.
|
|
||||||
|
|
||||||
### 1.1.1 (Jan 15, 2016)
|
|
||||||
* [CB-10238](https://issues.apache.org/jira/browse/CB-10238) **OSX** Move `device-plugin` out from `cordovalib` to the plugin repository
|
|
||||||
* [CB-9923](https://issues.apache.org/jira/browse/CB-9923) Update `device.platform` documentation for **Browser** platform
|
|
||||||
|
|
||||||
### 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
|
|
|
@ -1,203 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,206 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,216 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,220 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,215 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,218 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,203 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,206 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,203 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,206 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,203 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,206 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,214 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,206 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,219 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,203 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](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;
|
|
|
@ -1,206 +0,0 @@
|
||||||
<!---
|
|
||||||
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;
|
|
|
@ -1,84 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "cordova-plugin-device@^2.0.2",
|
|
||||||
"_id": "cordova-plugin-device@2.0.2",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-/Ajzci5n7ve2xnv8mag99q3Quro=",
|
|
||||||
"_location": "/cordova-plugin-device",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "cordova-plugin-device@^2.0.2",
|
|
||||||
"name": "cordova-plugin-device",
|
|
||||||
"escapedName": "cordova-plugin-device",
|
|
||||||
"rawSpec": "^2.0.2",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^2.0.2"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.2.tgz",
|
|
||||||
"_shasum": "fc08f3722e67eef7b6c67bfc99a83df6add0baba",
|
|
||||||
"_spec": "cordova-plugin-device@^2.0.2",
|
|
||||||
"_where": "/home/thrrgilag/workspace/cordova/Goober",
|
|
||||||
"author": {
|
|
||||||
"name": "Apache Software Foundation"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://issues.apache.org/jira/browse/CB"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"cordova": {
|
|
||||||
"id": "cordova-plugin-device",
|
|
||||||
"platforms": [
|
|
||||||
"android",
|
|
||||||
"ios",
|
|
||||||
"windows",
|
|
||||||
"browser",
|
|
||||||
"osx"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Cordova Device Plugin",
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^3.19.0",
|
|
||||||
"eslint-config-semistandard": "^11.0.0",
|
|
||||||
"eslint-config-standard": "^10.2.1",
|
|
||||||
"eslint-plugin-import": "^2.3.0",
|
|
||||||
"eslint-plugin-node": "^5.0.0",
|
|
||||||
"eslint-plugin-promise": "^3.5.0",
|
|
||||||
"eslint-plugin-standard": "^3.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"cordovaDependencies": {
|
|
||||||
"3.0.0": {
|
|
||||||
"cordova": ">100"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/apache/cordova-plugin-device#readme",
|
|
||||||
"keywords": [
|
|
||||||
"cordova",
|
|
||||||
"device",
|
|
||||||
"ecosystem:cordova",
|
|
||||||
"cordova-android",
|
|
||||||
"cordova-ios",
|
|
||||||
"cordova-windows",
|
|
||||||
"cordova-browser",
|
|
||||||
"cordova-osx"
|
|
||||||
],
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"name": "cordova-plugin-device",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/apache/cordova-plugin-device.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests",
|
|
||||||
"test": "npm run eslint"
|
|
||||||
},
|
|
||||||
"types": "./types/index.d.ts",
|
|
||||||
"version": "2.0.2"
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
<?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="2.0.2">
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<!-- 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>
|
|
||||||
|
|
||||||
<!-- 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>
|
|
||||||
|
|
||||||
<!-- windows -->
|
|
||||||
<platform name="windows">
|
|
||||||
<js-module src="src/windows/DeviceProxy.js" name="DeviceProxy">
|
|
||||||
<runs />
|
|
||||||
</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>
|
|
||||||
|
|
||||||
<!-- osx -->
|
|
||||||
<platform name="osx">
|
|
||||||
<config-file target="config.xml" parent="/*">
|
|
||||||
<feature name="Device">
|
|
||||||
<param name="ios-package" value="CDVDevice"/>
|
|
||||||
</feature>
|
|
||||||
</config-file>
|
|
||||||
|
|
||||||
<header-file src="src/osx/CDVDevice.h" />
|
|
||||||
<source-file src="src/osx/CDVDevice.m" />
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
|
|
||||||
</plugin>
|
|
|
@ -1,174 +0,0 @@
|
||||||
/*
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* 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');
|
|
||||||
|
|
||||||
function getPlatform () {
|
|
||||||
return 'browser';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getModel () {
|
|
||||||
return getBrowserInfo(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVersion () {
|
|
||||||
return getBrowserInfo(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getBrowserInfo (getModel) {
|
|
||||||
var userAgent = navigator.userAgent;
|
|
||||||
var returnVal = '';
|
|
||||||
var offset;
|
|
||||||
|
|
||||||
if ((offset = userAgent.indexOf('Edge')) !== -1) {
|
|
||||||
returnVal = (getModel) ? 'Edge' : userAgent.substring(offset + 5);
|
|
||||||
} else if ((offset = userAgent.indexOf('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,
|
|
||||||
isVirtual: false
|
|
||||||
});
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
require('cordova/exec/proxy').add('Device', module.exports);
|
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
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
|
|
|
@ -1,112 +0,0 @@
|
||||||
/*
|
|
||||||
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) {
|
|
||||||
if ([device respondsToSelector:@selector(identifierForVendor)]) {
|
|
||||||
app_uuid = [[device identifierForVendor] UUIDString];
|
|
||||||
} else {
|
|
||||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
|
||||||
app_uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid);
|
|
||||||
CFRelease(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
[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];
|
|
||||||
|
|
||||||
return @{
|
|
||||||
@"manufacturer": @"Apple",
|
|
||||||
@"model": [device modelVersion],
|
|
||||||
@"platform": @"iOS",
|
|
||||||
@"version": [device systemVersion],
|
|
||||||
@"uuid": [self uniqueAppInstanceIdentifier:device],
|
|
||||||
@"cordova": [[self class] cordovaVersion],
|
|
||||||
@"isVirtual": @([self isVirtual])
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSString*)cordovaVersion
|
|
||||||
{
|
|
||||||
return CDV_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isVirtual
|
|
||||||
{
|
|
||||||
#if TARGET_OS_SIMULATOR
|
|
||||||
return true;
|
|
||||||
#elif TARGET_IPHONE_SIMULATOR
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
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 <Cordova/CDVPlugin.h>
|
|
||||||
|
|
||||||
@interface CDVDevice : CDVPlugin
|
|
||||||
|
|
||||||
+ (NSString*) cordovaVersion;
|
|
||||||
|
|
||||||
- (void) getDeviceInfo:(CDVInvokedUrlCommand*)command;
|
|
||||||
|
|
||||||
@end
|
|
|
@ -1,113 +0,0 @@
|
||||||
/*
|
|
||||||
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/sysctl.h>
|
|
||||||
|
|
||||||
#import "CDVDevice.h"
|
|
||||||
|
|
||||||
#define SYSTEM_VERSION_PLIST @"/System/Library/CoreServices/SystemVersion.plist"
|
|
||||||
|
|
||||||
@implementation CDVDevice
|
|
||||||
|
|
||||||
- (NSString*) modelVersion {
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
|
|
||||||
char* machine = malloc(size);
|
|
||||||
sysctlbyname("hw.machine", machine, &size, NULL, 0);
|
|
||||||
NSString* modelVersion = [NSString stringWithUTF8String:machine];
|
|
||||||
free(machine);
|
|
||||||
|
|
||||||
return modelVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (NSString*) getSerialNr {
|
|
||||||
NSString* serialNr;
|
|
||||||
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
|
|
||||||
if (platformExpert) {
|
|
||||||
CFTypeRef serialNumberAsCFString =
|
|
||||||
IORegistryEntryCreateCFProperty(platformExpert,
|
|
||||||
CFSTR(kIOPlatformSerialNumberKey),
|
|
||||||
kCFAllocatorDefault, 0);
|
|
||||||
if (serialNumberAsCFString) {
|
|
||||||
serialNr = (__bridge NSString*) serialNumberAsCFString;
|
|
||||||
}
|
|
||||||
IOObjectRelease(platformExpert);
|
|
||||||
}
|
|
||||||
return serialNr;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString*) uniqueAppInstanceIdentifier {
|
|
||||||
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
|
|
||||||
static NSString* UUID_KEY = @"CDVUUID";
|
|
||||||
|
|
||||||
NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
|
|
||||||
|
|
||||||
if (app_uuid == nil) {
|
|
||||||
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
|
|
||||||
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
|
|
||||||
|
|
||||||
app_uuid = [NSString stringWithString:(__bridge NSString*) uuidString];
|
|
||||||
[userDefaults setObject:app_uuid forKey:UUID_KEY];
|
|
||||||
[userDefaults synchronize];
|
|
||||||
|
|
||||||
CFRelease(uuidString);
|
|
||||||
CFRelease(uuidRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
return app_uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString*) platform {
|
|
||||||
return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductName"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString*) systemVersion {
|
|
||||||
return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductVersion"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (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 {
|
|
||||||
NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
|
|
||||||
|
|
||||||
devProps[@"manufacturer"] = @"Apple";
|
|
||||||
devProps[@"model"] = [self modelVersion];
|
|
||||||
devProps[@"platform"] = [self platform];
|
|
||||||
devProps[@"version"] = [self systemVersion];
|
|
||||||
devProps[@"uuid"] = [self uniqueAppInstanceIdentifier];
|
|
||||||
devProps[@"cordova"] = [[self class] cordovaVersion];
|
|
||||||
devProps[@"serial"] = [self getSerialNr];
|
|
||||||
devProps[@"isVirtual"] = @NO;
|
|
||||||
|
|
||||||
NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
|
|
||||||
return devReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSString*) cordovaVersion {
|
|
||||||
return CDV_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
|
@ -1,96 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* global Windows, createUUID */
|
|
||||||
|
|
||||||
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);
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"name": "cordova-plugin-device-tests",
|
|
||||||
"version": "1.1.6-dev",
|
|
||||||
"description": "",
|
|
||||||
"cordova": {
|
|
||||||
"id": "cordova-plugin-device-tests",
|
|
||||||
"platforms": []
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"ecosystem:cordova"
|
|
||||||
],
|
|
||||||
"author": "",
|
|
||||||
"license": "Apache 2.0"
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?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="2.0.2">
|
|
||||||
<name>Cordova Device Plugin Tests</name>
|
|
||||||
<license>Apache 2.0</license>
|
|
||||||
|
|
||||||
<js-module src="tests.js" name="tests">
|
|
||||||
</js-module>
|
|
||||||
</plugin>
|
|
113
plugins/cordova-plugin-device/tests/tests.js
vendored
113
plugins/cordova-plugin-device/tests/tests.js
vendored
|
@ -1,113 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* eslint-env jasmine */
|
|
||||||
|
|
||||||
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((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((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((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((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((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((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((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((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');
|
|
||||||
};
|
|
36
plugins/cordova-plugin-device/types/index.d.ts
vendored
36
plugins/cordova-plugin-device/types/index.d.ts
vendored
|
@ -1,36 +0,0 @@
|
||||||
// Type definitions for Apache Cordova Device plugin
|
|
||||||
// Project: https://github.com/apache/cordova-plugin-device
|
|
||||||
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Open Technologies Inc
|
|
||||||
// Licensed under the MIT license
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
interface Device {
|
|
||||||
/** Get the version of Cordova running on the device. */
|
|
||||||
cordova: string;
|
|
||||||
/** Indicates that Cordova initialize successfully. */
|
|
||||||
available: boolean;
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
model: string;
|
|
||||||
/** Get the device's operating system name. */
|
|
||||||
platform: string;
|
|
||||||
/** Get the device's Universally Unique Identifier (UUID). */
|
|
||||||
uuid: string;
|
|
||||||
/** Get the operating system version. */
|
|
||||||
version: string;
|
|
||||||
/** Get the device's manufacturer. */
|
|
||||||
manufacturer: string;
|
|
||||||
/** Whether the device is running on a simulator. */
|
|
||||||
isVirtual: boolean;
|
|
||||||
/** Get the device hardware serial number. */
|
|
||||||
serial: string;}
|
|
||||||
|
|
||||||
declare var device: Device;
|
|
|
@ -1,37 +0,0 @@
|
||||||
<!--
|
|
||||||
#
|
|
||||||
# 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!
|
|
|
@ -1,202 +0,0 @@
|
||||||
|
|
||||||
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.
|
|
|
@ -1,8 +0,0 @@
|
||||||
Apache Cordova
|
|
||||||
Copyright 2012 The Apache Software Foundation
|
|
||||||
|
|
||||||
This product includes software developed at
|
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
|
||||||
|
|
||||||
This product includes a copy of OkHttp from:
|
|
||||||
https://github.com/square/okhttp
|
|
|
@ -1,598 +0,0 @@
|
||||||
---
|
|
||||||
title: File Transfer
|
|
||||||
description: Upload and download files.
|
|
||||||
---
|
|
||||||
<!--
|
|
||||||
# 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|AppVeyor|Travis CI|
|
|
||||||
|:-:|:-:|
|
|
||||||
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-file-transfer?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-file-transfer)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-file-transfer)|
|
|
||||||
|
|
||||||
# cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
This plugin allows you to upload and download files.
|
|
||||||
|
|
||||||
This plugin defines global `FileTransfer`, `FileUploadOptions` constructors. Although in the global scope, they are not available until after the `deviceready` event.
|
|
||||||
|
|
||||||
```js
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
> To get a few ideas, check out the [sample](#sample) at the bottom of this page.
|
|
||||||
|
|
||||||
Report issues with this plugin 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%20File%20Transfer%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
|
||||||
|
|
||||||
## Deprecated
|
|
||||||
|
|
||||||
With the new features introduced in [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), this plugin is not needed any more. Migrating from this plugin to using the new features of [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), is explained in this [Cordova blog post](https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html).
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
```
|
|
||||||
|
|
||||||
## Supported Platforms
|
|
||||||
|
|
||||||
- Amazon Fire OS
|
|
||||||
- Android
|
|
||||||
- BlackBerry 10
|
|
||||||
- Browser
|
|
||||||
- Firefox OS**
|
|
||||||
- iOS
|
|
||||||
- Windows Phone 7 and 8*
|
|
||||||
- Windows
|
|
||||||
|
|
||||||
\* _Do not support `onprogress` nor `abort()`_
|
|
||||||
|
|
||||||
\** _Do not support `onprogress`_
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
The `FileTransfer` object provides a way to upload files using an HTTP
|
|
||||||
multi-part POST or PUT request, and to download files.
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
- __onprogress__: Called with a `ProgressEvent` whenever a new chunk of data is transferred. _(Function)_
|
|
||||||
|
|
||||||
## Methods
|
|
||||||
|
|
||||||
- __upload__: Sends a file to a server.
|
|
||||||
|
|
||||||
- __download__: Downloads a file from server.
|
|
||||||
|
|
||||||
- __abort__: Aborts an in-progress transfer.
|
|
||||||
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
__Parameters__:
|
|
||||||
|
|
||||||
- __fileURL__: Filesystem URL representing the file on the device or a [data URI](https://en.wikipedia.org/wiki/Data_URI_scheme). For backwards compatibility, this can also be the full path of the file on the device. (See [Backwards Compatibility Notes](#backwards-compatibility-notes) below)
|
|
||||||
|
|
||||||
- __server__: URL of the server to receive the file, as encoded by `encodeURI()`.
|
|
||||||
|
|
||||||
- __successCallback__: A callback that is passed a `FileUploadResult` object. _(Function)_
|
|
||||||
|
|
||||||
- __errorCallback__: A callback that executes if an error occurs retrieving the `FileUploadResult`. Invoked with a `FileTransferError` object. _(Function)_
|
|
||||||
|
|
||||||
- __options__: Optional parameters _(Object)_. Valid keys:
|
|
||||||
- __fileKey__: The name of the form element. Defaults to `file`. (DOMString)
|
|
||||||
- __fileName__: The file name to use when saving the file on the server. Defaults to `image.jpg`. (DOMString)
|
|
||||||
- __httpMethod__: The HTTP method to use - either `PUT` or `POST`. Defaults to `POST`. (DOMString)
|
|
||||||
- __mimeType__: The mime type of the data to upload. Defaults to `image/jpeg`. (DOMString)
|
|
||||||
- __params__: A set of optional key/value pairs to pass in the HTTP request. (Object, key/value - DOMString)
|
|
||||||
- __chunkedMode__: Whether to upload the data in chunked streaming mode. Defaults to `true`. (Boolean)
|
|
||||||
- __headers__: A map of header name/header values. Use a hash to specify one or more than one value. On iOS, FireOS, and Android, if a header named Content-Type is present, multipart form data will NOT be used. (Object)
|
|
||||||
|
|
||||||
- __trustAllHosts__: Optional parameter, defaults to `false`. If set to `true`, it accepts all security certificates. Not recommended for production use. Supported on iOS. _(boolean)_
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example with Upload Headers and Progress Events (Android and iOS only)
|
|
||||||
|
|
||||||
```js
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue', 'headerParam2':'headerValue2'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
```
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
A `FileUploadResult` object is passed to the success callback of the
|
|
||||||
`FileTransfer` object's `upload()` method.
|
|
||||||
|
|
||||||
### Properties
|
|
||||||
|
|
||||||
- __bytesSent__: The number of bytes sent to the server as part of the upload. (long)
|
|
||||||
|
|
||||||
- __responseCode__: The HTTP response code returned by the server. (long)
|
|
||||||
|
|
||||||
- __response__: The HTTP response returned by the server. (DOMString)
|
|
||||||
|
|
||||||
- __headers__: The HTTP response headers by the server. (Object)
|
|
||||||
- Currently supported on iOS only.
|
|
||||||
|
|
||||||
### iOS Quirks
|
|
||||||
|
|
||||||
- Does not support `responseCode` or `bytesSent`.
|
|
||||||
|
|
||||||
- Does not support uploads of an empty file with __chunkedMode=true__ and `multipartMode=false`.
|
|
||||||
|
|
||||||
### Browser Quirks
|
|
||||||
|
|
||||||
- __withCredentials__: _boolean_ that tells the browser to set the withCredentials flag on the XMLHttpRequest
|
|
||||||
|
|
||||||
### Windows Quirks
|
|
||||||
|
|
||||||
- An option parameter with empty/null value is excluded in the upload operation due to the Windows API design.
|
|
||||||
|
|
||||||
- __chunkedMode__ is not supported and all uploads are set to non-chunked mode.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
__Parameters__:
|
|
||||||
|
|
||||||
- __source__: URL of the server to download the file, as encoded by `encodeURI()`.
|
|
||||||
|
|
||||||
- __target__: Filesystem url representing the file on the device. For backwards compatibility, this can also be the full path of the file on the device. (See [Backwards Compatibility Notes](#backwards-compatibility-notes) below)
|
|
||||||
|
|
||||||
- __successCallback__: A callback that is passed a `FileEntry` object. _(Function)_
|
|
||||||
|
|
||||||
- __errorCallback__: A callback that executes if an error occurs when retrieving the `FileEntry`. Invoked with a `FileTransferError` object. _(Function)_
|
|
||||||
|
|
||||||
- __trustAllHosts__: Optional parameter, defaults to `false`. If set to `true`, it accepts all security certificates. Not recommended for production use. Supported on iOS. _(boolean)_
|
|
||||||
|
|
||||||
- __options__: Optional parameters, currently only supports headers (such as Authorization (Basic Authentication), etc).
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("download error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
### WP8 Quirks
|
|
||||||
|
|
||||||
- Download requests is being cached by native implementation. To avoid caching, pass `if-Modified-Since` header to download method.
|
|
||||||
|
|
||||||
### Browser Quirks
|
|
||||||
|
|
||||||
- __withCredentials__: _boolean_ that tells the browser to set the withCredentials flag on the XMLHttpRequest
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object which has an error code of `FileTransferError.ABORT_ERR`.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
```
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
A `FileTransferError` object is passed to an error callback when an error occurs.
|
|
||||||
|
|
||||||
### Properties
|
|
||||||
|
|
||||||
- __code__: One of the predefined error codes listed below. (Number)
|
|
||||||
|
|
||||||
- __source__: URL to the source. (String)
|
|
||||||
|
|
||||||
- __target__: URL to the target. (String)
|
|
||||||
|
|
||||||
- __http_status__: HTTP status code. This attribute is only available when a response code is received from the HTTP connection. (Number)
|
|
||||||
|
|
||||||
- __body__ Response body. This attribute is only available when a response is received from the HTTP connection. (String)
|
|
||||||
|
|
||||||
- __exception__: Either e.getMessage or e.toString (String)
|
|
||||||
|
|
||||||
### iOS Quirks
|
|
||||||
|
|
||||||
__exception__ is never defined.
|
|
||||||
|
|
||||||
### Constants
|
|
||||||
|
|
||||||
- 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
- 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
- 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
- 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
- 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Windows Quirks
|
|
||||||
|
|
||||||
- The plugin implementation is based on [BackgroundDownloader](https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.backgroundtransfer.backgrounddownloader.aspx)/[BackgroundUploader](https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.backgroundtransfer.backgrounduploader.aspx), which entails the latency issues on Windows devices (creation/starting of an operation can take up to a few seconds). You can use XHR or [HttpClient](https://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.httpclient.aspx) as a quicker alternative for small downloads.
|
|
||||||
|
|
||||||
## Backwards Compatibility Notes
|
|
||||||
|
|
||||||
Previous versions of this plugin would only accept device-absolute-file-paths as the source for uploads, or as the target for downloads. These paths would typically be of the form:
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
For backwards compatibility, these paths are still accepted, and if your application has recorded paths like these in persistent storage, then they can continue to be used.
|
|
||||||
|
|
||||||
These paths were previously exposed in the `fullPath` property of `FileEntry` and `DirectoryEntry` objects returned by the File plugin. New versions of the File plugin however, no longer expose these paths to JavaScript.
|
|
||||||
|
|
||||||
If you are upgrading to a new (1.0.0 or newer) version of File, and you have previously been using `entry.fullPath` as arguments to `download()` or `upload()`, then you will need to change your code to use filesystem URLs instead.
|
|
||||||
|
|
||||||
`FileEntry.toURL()` and `DirectoryEntry.toURL()` return a filesystem URL of the form:
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
which can be used in place of the absolute file path in both `download()` and `upload()` methods.
|
|
||||||
|
|
||||||
## Sample: Download and Upload Files <a name="sample"></a>
|
|
||||||
|
|
||||||
Use the File-Transfer plugin to upload and download files. In these examples, we demonstrate several tasks like:
|
|
||||||
|
|
||||||
* [Downloading a binary file to the application cache](#binaryFile)
|
|
||||||
* [Uploading a file created in your application's root](#uploadFile)
|
|
||||||
* [Downloading the uploaded file](#downloadFile)
|
|
||||||
|
|
||||||
## Download a Binary File to the application cache <a name="binaryFile"></a>
|
|
||||||
|
|
||||||
Use the File plugin with the File-Transfer plugin to provide a target for the files that you download (the target must be a FileEntry object). Before you download the file, create a DirectoryEntry object by using `resolveLocalFileSystemURL` and calling `fs.root` in the success callback. Use the `getFile` method of DirectoryEntry to create the target file.
|
|
||||||
|
|
||||||
```js
|
|
||||||
window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs) {
|
|
||||||
|
|
||||||
console.log('file system open: ' + fs.name);
|
|
||||||
|
|
||||||
// Make sure you add the domain name to the Content-Security-Policy <meta> element.
|
|
||||||
var url = 'http://cordova.apache.org/static/img/cordova_bot.png';
|
|
||||||
// Parameters passed to getFile create a new file or return the file if it already exists.
|
|
||||||
fs.root.getFile('downloaded-image.png', { create: true, exclusive: false }, function (fileEntry) {
|
|
||||||
download(fileEntry, url, true);
|
|
||||||
|
|
||||||
}, onErrorCreateFile);
|
|
||||||
|
|
||||||
}, onErrorLoadFs);
|
|
||||||
```
|
|
||||||
|
|
||||||
>*Note* For persistent storage, pass LocalFileSystem.PERSISTENT to requestFileSystem.
|
|
||||||
|
|
||||||
When you have the FileEntry object, download the file using the `download` method of the FileTransfer object. The 3rd argument to the `download` function of FileTransfer is the success callback, which you can use to call the app's `readBinaryFile` function. In this code example, the `entry` variable is a new FileEntry object that receives the result of the download operation.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function download(fileEntry, uri, readBinaryData) {
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var fileURL = fileEntry.toURL();
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function (entry) {
|
|
||||||
console.log("Successful download...");
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
if (readBinaryData) {
|
|
||||||
// Read the file...
|
|
||||||
readBinaryFile(entry);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Or just display it.
|
|
||||||
displayImageByFileURL(entry);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
null, // or, pass false
|
|
||||||
{
|
|
||||||
//headers: {
|
|
||||||
// "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
If you just need to display the image, take the FileEntry to call its toURL() function.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function displayImageByFileURL(fileEntry) {
|
|
||||||
var elem = document.getElementById('imageElement');
|
|
||||||
elem.src = fileEntry.toURL();
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Depending on your app requirements, you may want to read the file. To support operations with binary files, FileReader supports two methods, `readAsBinaryString` and `readAsArrayBuffer`. In this example, use `readAsArrayBuffer` and pass the FileEntry object to the method. Once you read the file successfully, construct a Blob object using the result of the read.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function readBinaryFile(fileEntry) {
|
|
||||||
fileEntry.file(function (file) {
|
|
||||||
var reader = new FileReader();
|
|
||||||
|
|
||||||
reader.onloadend = function() {
|
|
||||||
|
|
||||||
console.log("Successful file read: " + this.result);
|
|
||||||
// displayFileData(fileEntry.fullPath + ": " + this.result);
|
|
||||||
|
|
||||||
var blob = new Blob([new Uint8Array(this.result)], { type: "image/png" });
|
|
||||||
displayImage(blob);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsArrayBuffer(file);
|
|
||||||
|
|
||||||
}, onErrorReadFile);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Once you read the file successfully, you can create a DOM URL string using `createObjectURL`, and then display the image.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function displayImage(blob) {
|
|
||||||
|
|
||||||
// Note: Use window.URL.revokeObjectURL when finished with image.
|
|
||||||
var objURL = window.URL.createObjectURL(blob);
|
|
||||||
|
|
||||||
// Displays image if result is a valid DOM string for an image.
|
|
||||||
var elem = document.getElementById('imageElement');
|
|
||||||
elem.src = objURL;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
As you saw previously, you can call FileEntry.toURL() instead to just display the downloaded image (skip the file read).
|
|
||||||
|
|
||||||
## Upload a File <a name="uploadFile"></a>
|
|
||||||
|
|
||||||
When you upload a File using the File-Transfer plugin, use the File plugin to provide files for upload (again, they must be FileEntry objects). Before you can upload anything, create a file for upload using the `getFile` method of DirectoryEntry. In this example, create the file in the application's cache (fs.root). Then call the app's writeFile function so you have some content to upload.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function onUploadFile() {
|
|
||||||
window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs) {
|
|
||||||
|
|
||||||
console.log('file system open: ' + fs.name);
|
|
||||||
var fileName = "uploadSource.txt";
|
|
||||||
var dirEntry = fs.root;
|
|
||||||
dirEntry.getFile(fileName, { create: true, exclusive: false }, function (fileEntry) {
|
|
||||||
|
|
||||||
// Write something to the file before uploading it.
|
|
||||||
writeFile(fileEntry);
|
|
||||||
|
|
||||||
}, onErrorCreateFile);
|
|
||||||
|
|
||||||
}, onErrorLoadFs);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example, create some simple content, and then call the app's upload function.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function writeFile(fileEntry, dataObj) {
|
|
||||||
// Create a FileWriter object for our FileEntry (log.txt).
|
|
||||||
fileEntry.createWriter(function (fileWriter) {
|
|
||||||
|
|
||||||
fileWriter.onwriteend = function () {
|
|
||||||
console.log("Successful file write...");
|
|
||||||
upload(fileEntry);
|
|
||||||
};
|
|
||||||
|
|
||||||
fileWriter.onerror = function (e) {
|
|
||||||
console.log("Failed file write: " + e.toString());
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!dataObj) {
|
|
||||||
dataObj = new Blob(['file data to upload'], { type: 'text/plain' });
|
|
||||||
}
|
|
||||||
|
|
||||||
fileWriter.write(dataObj);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Forward the FileEntry object to the upload function. To perform the actual upload, use the upload function of the FileTransfer object.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function upload(fileEntry) {
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
var fileURL = fileEntry.toURL();
|
|
||||||
|
|
||||||
var success = function (r) {
|
|
||||||
console.log("Successful upload...");
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
// displayFileData(fileEntry.fullPath + " (content uploaded to server)");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
// SERVER must be a URL that can handle the request, like
|
|
||||||
// http://some.server.com/upload.php
|
|
||||||
ft.upload(fileURL, encodeURI(SERVER), success, fail, options);
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Download the uploaded file <a name="downloadFile"></a>
|
|
||||||
|
|
||||||
To download the image you just uploaded, you will need a valid URL that can handle the request, for example, http://some.server.com/download.php. Again, the success handler for the FileTransfer.download method receives a FileEntry object. The main difference here from previous examples is that we call FileReader.readAsText to read the result of the download operation, because we uploaded a file with text content.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function download(fileEntry, uri) {
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var fileURL = fileEntry.toURL();
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function (entry) {
|
|
||||||
console.log("Successful download...");
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
readFile(entry);
|
|
||||||
},
|
|
||||||
function (error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
null, // or, pass false
|
|
||||||
{
|
|
||||||
//headers: {
|
|
||||||
// "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In the readFile function, call the `readAsText` method of the FileReader object.
|
|
||||||
|
|
||||||
```js
|
|
||||||
function readFile(fileEntry) {
|
|
||||||
fileEntry.file(function (file) {
|
|
||||||
var reader = new FileReader();
|
|
||||||
|
|
||||||
reader.onloadend = function () {
|
|
||||||
|
|
||||||
console.log("Successful file read: " + this.result);
|
|
||||||
// displayFileData(fileEntry.fullPath + ": " + this.result);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsText(file);
|
|
||||||
|
|
||||||
}, onErrorReadFile);
|
|
||||||
}
|
|
||||||
```
|
|
|
@ -1,319 +0,0 @@
|
||||||
<!--
|
|
||||||
#
|
|
||||||
# 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.7.1 (Jan 24, 2018)
|
|
||||||
* [CB-13749](https://issues.apache.org/jira/browse/CB-13749) Add build-tools-26.0.2 to travis
|
|
||||||
|
|
||||||
### 1.7.0 (Nov 06, 2017)
|
|
||||||
* Updated `README` with Deprecated Status
|
|
||||||
* [CB-13472](https://issues.apache.org/jira/browse/CB-13472) (CI) Fixed Travis **Android** builds again
|
|
||||||
* [CB-12809](https://issues.apache.org/jira/browse/CB-12809) Google Play Blocker: Unsafe SSL TrustManager Defined
|
|
||||||
* [CB-7995](https://issues.apache.org/jira/browse/CB-7995) document that `FileTransferError.exception` on **iOS** is never defined.
|
|
||||||
* [CB-13000](https://issues.apache.org/jira/browse/CB-13000) (CI) Speed up **Android** builds
|
|
||||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
|
||||||
|
|
||||||
### 1.6.3 (Apr 27, 2017)
|
|
||||||
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
|
|
||||||
* [CB-10696](https://issues.apache.org/jira/browse/CB-10696) **iOS**: Encode target path with spaces
|
|
||||||
|
|
||||||
### 1.6.2 (Feb 28, 2017)
|
|
||||||
* [CB-12353](https://issues.apache.org/jira/browse/CB-12353) Corrected merges usage in `plugin.xml`
|
|
||||||
* [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped`
|
|
||||||
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
|
|
||||||
* [CB-12230](https://issues.apache.org/jira/browse/CB-12230) Removed **Windows 8.1** build badges
|
|
||||||
|
|
||||||
### 1.6.1 (Dec 07, 2016)
|
|
||||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 1.6.1
|
|
||||||
* [CB-12154](https://issues.apache.org/jira/browse/CB-12154) file-transfer progressEvent.total = -1 on iOS
|
|
||||||
* [CB-10974](https://issues.apache.org/jira/browse/CB-10974) Cordova file transfer Content-Length header problem
|
|
||||||
* Don't crash on low memory devices
|
|
||||||
* [CB-12100](https://issues.apache.org/jira/browse/CB-12100) (ios) Fixed test plugin install at platform add on cordova@6.3.1
|
|
||||||
* [CB-11959](https://issues.apache.org/jira/browse/CB-11959) Fixed the jshint issues
|
|
||||||
* [CB-11959](https://issues.apache.org/jira/browse/CB-11959) Increased the array length for ios and winstore even more
|
|
||||||
* [CB-11959](https://issues.apache.org/jira/browse/CB-11959) Fixed filetransfer.spec.21 test failure on iOS and Windows Store when using local server
|
|
||||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
|
|
||||||
* [CB-11926](https://issues.apache.org/jira/browse/CB-11926) Tests can use local server
|
|
||||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
|
||||||
|
|
||||||
### 1.6.0 (Sep 08, 2016)
|
|
||||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
|
|
||||||
* [CB-9022](https://issues.apache.org/jira/browse/CB-9022) Fix exception thrown by call to `remapApi` on main thread
|
|
||||||
* Plugin uses `Android Log class` and not `Cordova LOG class`
|
|
||||||
* [CB-9022](https://issues.apache.org/jira/browse/CB-9022) Resolve source URI on background thread
|
|
||||||
* [CB-11316](https://issues.apache.org/jira/browse/CB-11316) **windows**: Added `content-type` for files
|
|
||||||
* Close invalid PRs
|
|
||||||
* [CB-11497](https://issues.apache.org/jira/browse/CB-11497) Use `cordova-vm` for testing 304 errors
|
|
||||||
* Add badges for paramedic builds on Jenkins
|
|
||||||
* documentation with a wrong log message in `fileTransfer.download` function
|
|
||||||
* added link to sample
|
|
||||||
* Add pull request template.
|
|
||||||
* [CB-10974](https://issues.apache.org/jira/browse/CB-10974) Cordova file transfer `Content-Length` header problem
|
|
||||||
* Add fenced code blocks to help code formatting
|
|
||||||
* [CB-11165](https://issues.apache.org/jira/browse/CB-11165) removed peer dependency
|
|
||||||
* [CB-11003](https://issues.apache.org/jira/browse/CB-11003) Adding sample section to documentation.
|
|
||||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
|
|
||||||
|
|
||||||
### 1.5.1 (Apr 15, 2016)
|
|
||||||
* [CB-10536](https://issues.apache.org/jira/browse/CB-10536) Removing flaky test assertions about abort callback latency
|
|
||||||
* Removing the expectation in `spec.34` for the transfer method to be called.
|
|
||||||
* [CB-10978](https://issues.apache.org/jira/browse/CB-10978) Fix `file-transfer.tests` JSHint issues
|
|
||||||
* [CB-10782](https://issues.apache.org/jira/browse/CB-10782) Occasional failure in file transfer tests causing mobilespec crash
|
|
||||||
* [CB-10771](https://issues.apache.org/jira/browse/CB-10771) Fixing failure when empty string passed as a value for option parameter in upload function
|
|
||||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
|
|
||||||
|
|
||||||
### 1.5.0 (Jan 15, 2016)
|
|
||||||
* [CB-10208](https://issues.apache.org/jira/browse/CB-10208) Fix `file-transfer` multipart form data upload format on **Windows**
|
|
||||||
* [CB-9837](https://issues.apache.org/jira/browse/CB-9837) Add data `URI` support to `file-transfer` upload on **iOS**
|
|
||||||
* [CB-9600](https://issues.apache.org/jira/browse/CB-9600) `FileUploadOptions` params not posted on **iOS**
|
|
||||||
* [CB-9840](https://issues.apache.org/jira/browse/CB-9840) Fallback `file-transfer` `uploadResponse` encoding to `latin1` in case not encoded with `UTF-8` on **iOS**
|
|
||||||
* [CB-9840](https://issues.apache.org/jira/browse/CB-9840) Fallback `file-transfer` upload/download response encoding to `latin1` in case not encoded with `UTF-8` on **iOS**
|
|
||||||
* [CB-8641](https://issues.apache.org/jira/browse/CB-8641) **Windows Phone 8.1** Some `file-transfer` plugin tests occasionally fail in `mobilespec`
|
|
||||||
* Adding linting and fixing linter warnings. Reducing timeouts to 7 seconds.
|
|
||||||
* [CB-10100](https://issues.apache.org/jira/browse/CB-10100) updated file dependency to not grab new majors
|
|
||||||
* [CB-7006](https://issues.apache.org/jira/browse/CB-7006) Empty file is created on file transfer if server response is 304
|
|
||||||
* [CB-10098](https://issues.apache.org/jira/browse/CB-10098) `filetransfer.spec.33` is faulty
|
|
||||||
* [CB-9969](https://issues.apache.org/jira/browse/CB-9969) Filetransfer upload error deletes original file
|
|
||||||
* [CB-10088](https://issues.apache.org/jira/browse/CB-10088) `filetransfer spec.10` and `spec.11` test is faulty
|
|
||||||
* [CB-9969](https://issues.apache.org/jira/browse/CB-9969) Filetransfer upload error deletes original file
|
|
||||||
* [CB-10086](https://issues.apache.org/jira/browse/CB-10086) There are two `spec.31` tests for `file-transfer` tests
|
|
||||||
* [CB-10037](https://issues.apache.org/jira/browse/CB-10037) Add progress indicator to file-transfer manual tests
|
|
||||||
* [CB-9563](https://issues.apache.org/jira/browse/CB-9563) Mulptipart form data is used even a header named `Content-Type` is present
|
|
||||||
* [CB-8863](https://issues.apache.org/jira/browse/CB-8863) fix block usage of self
|
|
||||||
|
|
||||||
### 1.4.0 (Nov 18, 2015)
|
|
||||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
|
||||||
* [CB-9879](https://issues.apache.org/jira/browse/CB-9879) `getCookie`s can cause unhandled `NullPointerException`
|
|
||||||
* [CB-6928](https://issues.apache.org/jira/browse/CB-6928) Wrong behaviour transferring cacheable content
|
|
||||||
* [CB-51](https://issues.apache.org/jira/browse/CB-51) FileTransfer - Support `PUT` Method
|
|
||||||
* [CB-9906](https://issues.apache.org/jira/browse/CB-9906) cleanup duplicate code, removed 2nd `isWP8` declaration.
|
|
||||||
* [CB-9950](https://issues.apache.org/jira/browse/CB-9950) Unpend Filetransfer spec.27 on **wp8** as custom headers are now supported
|
|
||||||
* [CB-9843](https://issues.apache.org/jira/browse/CB-9843) Added **wp8** quirk to test spec 12
|
|
||||||
* Fixing contribute link.
|
|
||||||
* [CB-8431](https://issues.apache.org/jira/browse/CB-8431) File Transfer tests crash on **Android Lolipop**
|
|
||||||
* [CB-9790](https://issues.apache.org/jira/browse/CB-9790) Align `FileUploadOptions` `fileName` and `mimeType` default parameter values to the docs on **iOS**
|
|
||||||
* [CB-9385](https://issues.apache.org/jira/browse/CB-9385) Return `FILE_NOT_FOUND_ERR` when receiving `404` code on **iOS**
|
|
||||||
* [CB-9791](https://issues.apache.org/jira/browse/CB-9791) Decreased download and upload tests timeout
|
|
||||||
|
|
||||||
### 1.3.0 (Sep 18, 2015)
|
|
||||||
* Found issue where : is accepted as a valid header, this is obviously wrong
|
|
||||||
* [CB-9562](https://issues.apache.org/jira/browse/CB-9562) Fixed incorrect headers handling on Android
|
|
||||||
* Fixing headers so they don't accept non-ASCII
|
|
||||||
* updated tests to use cordova apache vm
|
|
||||||
* [CB-9493](https://issues.apache.org/jira/browse/CB-9493) Fix file paths in file-transfer manual tests
|
|
||||||
* [CB-8816](https://issues.apache.org/jira/browse/CB-8816) Add cdvfile:// support on windows
|
|
||||||
* [CB-9376](https://issues.apache.org/jira/browse/CB-9376) Fix FileTransfer plugin manual tests issue - 'undefined' in paths
|
|
||||||
|
|
||||||
### 1.2.1 (Jul 7, 2015)
|
|
||||||
* [CB-9275](https://issues.apache.org/jira/browse/CB-9275) [WP8] Fix build failure on WP8 by using reflection to detect presence of JSON.NET based serialization
|
|
||||||
* Updated code per code review.
|
|
||||||
* Updated documentation for browser
|
|
||||||
* Added option to allow for passing cookies automatically in the browser
|
|
||||||
|
|
||||||
### 1.2.0 (Jun 17, 2015)
|
|
||||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-file-transfer documentation translation: cordova-plugin-file-transfer
|
|
||||||
* [CB-6503](https://issues.apache.org/jira/browse/CB-6503): Null pointer check for headers in upload (This closes #27)
|
|
||||||
* [CB-6503](https://issues.apache.org/jira/browse/CB-6503): Allow payload content-types other than multipart/form-data to be used for upload
|
|
||||||
* Fix NoSuchMethodException looking up cookies.
|
|
||||||
* fix npm md issue
|
|
||||||
* [CB-8951](https://issues.apache.org/jira/browse/CB-8951) (wp8) Handle exceptions in download() and upload() again
|
|
||||||
* [wp8] Relaxed engine version requirement, using reflection to see if methods are available
|
|
||||||
* Check for the existence of Json.net assembly to determin how we deserialize our headers.
|
|
||||||
* relax engine requirement to allow -dev versions
|
|
||||||
* Remove verbose console log messages
|
|
||||||
* fix bad commit (mine) for cordova-wp8@4.0.0 engine req
|
|
||||||
* bump required cordova-wp8 version to 4.0.0
|
|
||||||
* This closes #80, This closes #12
|
|
||||||
* fix failing test resulting from overlapping async calls
|
|
||||||
* [CB-8721](https://issues.apache.org/jira/browse/CB-8721) Fixes incorrect headers and upload params parsing on wp8
|
|
||||||
* Replace all slashes in windows path
|
|
||||||
|
|
||||||
### 1.1.0 (May 06, 2015)
|
|
||||||
* [CB-8951](https://issues.apache.org/jira/browse/CB-8951) Fixed crash related to headers parsing on **wp8**
|
|
||||||
* [CB-8933](https://issues.apache.org/jira/browse/CB-8933) Increased download and upload test timeout
|
|
||||||
* [CB-6313](https://issues.apache.org/jira/browse/CB-6313) **wp8**: Extra boundary in upload
|
|
||||||
* [CB-8761](https://issues.apache.org/jira/browse/CB-8761) **wp8**: Copy cookies from WebBrowser
|
|
||||||
|
|
||||||
### 1.0.0 (Apr 15, 2015)
|
|
||||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) bumped version of file dependency
|
|
||||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
|
|
||||||
* [CB-8641](https://issues.apache.org/jira/browse/CB-8641) Fixed tests to pass on windows and wp8
|
|
||||||
* [CB-8583](https://issues.apache.org/jira/browse/CB-8583) Forces download to overwrite existing target file
|
|
||||||
* [CB-8589](https://issues.apache.org/jira/browse/CB-8589) Fixes upload failure when server's response doesn't contain any data
|
|
||||||
* [CB-8747](https://issues.apache.org/jira/browse/CB-8747) updated dependency, added peer dependency
|
|
||||||
* [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
|
|
||||||
* [CB-8654](https://issues.apache.org/jira/browse/CB-8654) Note WP8 download requests caching in docs
|
|
||||||
* [CB-8590](https://issues.apache.org/jira/browse/CB-8590) (Windows) Fixed download.onprogress.lengthComputable
|
|
||||||
* [CB-8566](https://issues.apache.org/jira/browse/CB-8566) Integrate TravisCI
|
|
||||||
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-file-transfer documentation translation: cordova-plugin-file-transfer
|
|
||||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
|
||||||
* [CB-8495](https://issues.apache.org/jira/browse/CB-8495) Fixed wp8 and wp81 test failures
|
|
||||||
* [CB-7957](https://issues.apache.org/jira/browse/CB-7957) Adds support for `browser` platform
|
|
||||||
* [CB-8429](https://issues.apache.org/jira/browse/CB-8429) Updated version and RELEASENOTES.md for release 0.5.0 (take 2)
|
|
||||||
* Fixes typo, introduced in https://github.com/apache/cordova-plugin-file-transfer/commit/bc43b46
|
|
||||||
* [CB-8407](https://issues.apache.org/jira/browse/CB-8407) Use File proxy to construct valid FileEntry for download success callback
|
|
||||||
* [CB-8407](https://issues.apache.org/jira/browse/CB-8407) Removes excess path to native path conversion in download method
|
|
||||||
* [CB-8429](https://issues.apache.org/jira/browse/CB-8429) Updated version and RELEASENOTES.md for release 0.5.0
|
|
||||||
* [CB-7957](https://issues.apache.org/jira/browse/CB-7957) Adds support for `browser` platform
|
|
||||||
* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) Fixes JSHint and formatting issues
|
|
||||||
* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) Updates tests and documentation
|
|
||||||
* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) Rewrite upload method to support progress events properly
|
|
||||||
* android: Fix error reporting for unknown uri type on sourceUri instead of targetUri
|
|
||||||
|
|
||||||
### 0.5.0 (Feb 04, 2015)
|
|
||||||
* [CB-8407](https://issues.apache.org/jira/browse/CB-8407) windows: Fix download of `ms-appdata:///` URIs
|
|
||||||
* [CB-8095](https://issues.apache.org/jira/browse/CB-8095) windows: Rewrite upload method to support progress events properly
|
|
||||||
* [CB-5059](https://issues.apache.org/jira/browse/CB-5059) android: Add a CookieManager abstraction for pluggable webviews
|
|
||||||
* ios: Fix compile warning about implicity int conversion
|
|
||||||
* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension
|
|
||||||
* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use a local copy of DLog macro rather than CordovaLib version
|
|
||||||
* [CB-8296](https://issues.apache.org/jira/browse/CB-8296) ios: Fix crash when upload fails and file is not yet created (close #57)
|
|
||||||
* Document "body" property on FileTransferError
|
|
||||||
* [CB-7912](https://issues.apache.org/jira/browse/CB-7912) ios, android: Update to work with whitelist plugins in Cordova 4.x
|
|
||||||
* Error callback should always be called with the FileTransferError object, and not just the code
|
|
||||||
* windows: alias appData to Windows.Storage.ApplicationData.current
|
|
||||||
* [CB-8093](https://issues.apache.org/jira/browse/CB-8093) Fixes incorrect FileTransferError returned in case of download failure
|
|
||||||
|
|
||||||
### 0.4.8 (Dec 02, 2014)
|
|
||||||
* [CB-8021](https://issues.apache.org/jira/browse/CB-8021) - adds documentation for `httpMethod` to `doc/index.md`. However, translations still need to be addressed.
|
|
||||||
* [CB-7223](https://issues.apache.org/jira/browse/CB-7223) spec.27 marked pending for **wp8**
|
|
||||||
* [CB-6900](https://issues.apache.org/jira/browse/CB-6900) fixed `spec.7` for **wp8**
|
|
||||||
* [CB-7944](https://issues.apache.org/jira/browse/CB-7944) Pended unsupported auto tests for *Windows*
|
|
||||||
* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs
|
|
||||||
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-file-transfer documentation translation: cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
### 0.4.7 (Oct 03, 2014)
|
|
||||||
* Construct proper FileEntry with nativeURL property set
|
|
||||||
* [CB-7532](https://issues.apache.org/jira/browse/CB-7532) Handle non-existent download dirs properly
|
|
||||||
* [CB-7529](https://issues.apache.org/jira/browse/CB-7529) Adds support for 'ms-appdata' URIs for windows
|
|
||||||
|
|
||||||
### 0.4.6 (Sep 17, 2014)
|
|
||||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-file-transfer documentation translation
|
|
||||||
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-file-transfer documentation translation
|
|
||||||
* [CB-7423](https://issues.apache.org/jira/browse/CB-7423) fix spec28,29 lastProgressEvent not visible to afterEach function
|
|
||||||
* Amazon related changes.
|
|
||||||
* Remove dupe file windows+windows8 both use the same one
|
|
||||||
* [CB-7316](https://issues.apache.org/jira/browse/CB-7316) Updates docs with actual information.
|
|
||||||
* [CB-7316](https://issues.apache.org/jira/browse/CB-7316) Adds support for Windows platform, moves \*Proxy files to proper directory.
|
|
||||||
* [CB-7316](https://issues.apache.org/jira/browse/CB-7316) Improves current specs compatibility:
|
|
||||||
* added documentation for new test
|
|
||||||
* [CB-6466](https://issues.apache.org/jira/browse/CB-6466) Fix failing test due to recent url change
|
|
||||||
* [CB-6466](https://issues.apache.org/jira/browse/CB-6466) created mobile-spec test
|
|
||||||
* Renamed test dir, added nested plugin.xml and test
|
|
||||||
* Fixed failing spec.19 on wp8
|
|
||||||
* added documentation to manual tests
|
|
||||||
* [CB-6961](https://issues.apache.org/jira/browse/CB-6961) port file-transfer tests to framework
|
|
||||||
|
|
||||||
### 0.4.5 (Aug 06, 2014)
|
|
||||||
* Upload parameters out of order
|
|
||||||
* **FirefoxOS** initial implementation
|
|
||||||
* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): Expose FileTransferError.exception to application
|
|
||||||
* [CB-6928](https://issues.apache.org/jira/browse/CB-6928): Add new error code to documentation
|
|
||||||
* [CB-6928](https://issues.apache.org/jira/browse/CB-6928): Handle 304 status code
|
|
||||||
* [CB-6928](https://issues.apache.org/jira/browse/CB-6928): Open output stream only if it's necessary.
|
|
||||||
* [BlackBerry10] Minor doc correction
|
|
||||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
|
|
||||||
* [Windows8] upload uses the provided fileName or the actual fileName
|
|
||||||
* [CB-2420](https://issues.apache.org/jira/browse/CB-2420) [Windows8] honor fileKey and param options. This closes #15
|
|
||||||
* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): Update new docs to match AlexNennker's changes in PR30
|
|
||||||
* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): Continue previous commit with one new instance (This closes #30)
|
|
||||||
* [CB-6781](https://issues.apache.org/jira/browse/CB-6781): add the exception text to the error object
|
|
||||||
* [CB-6890](https://issues.apache.org/jira/browse/CB-6890): Fix pluginManager access for 4.0.x branch
|
|
||||||
|
|
||||||
### 0.4.4 (Jun 05, 2014)
|
|
||||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #21
|
|
||||||
* ubuntu: support 'cdvfile' URI
|
|
||||||
* [CB-6802](https://issues.apache.org/jira/browse/CB-6802) Add license
|
|
||||||
* Upload progress now works also for second file
|
|
||||||
* [CB-6706](https://issues.apache.org/jira/browse/CB-6706): Relax dependency on file plugin
|
|
||||||
* [CB-3440](https://issues.apache.org/jira/browse/CB-3440) [BlackBerry10] Update implementation to use modules from file plugin
|
|
||||||
* [CB-6378](https://issues.apache.org/jira/browse/CB-6378) Use connection.disconnect() instead of stream.close() for thread-safety
|
|
||||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
|
||||||
* [CB-6466](https://issues.apache.org/jira/browse/CB-6466) Auto-create directories in download
|
|
||||||
* [CB-6494](https://issues.apache.org/jira/browse/CB-6494) android: Fix upload of KitKat content URIs
|
|
||||||
* Upleveled from android port with following commits: 3c1ff16 Andrew Grieve - [CB-5762](https://issues.apache.org/jira/browse/CB-5762) android: Fix lengthComputable set wrong for gzip downloads 8374b3d Colin Mahoney - [CB-5631](https://issues.apache.org/jira/browse/CB-5631) Removed SimpleTrackingInputStream.read(byte[] buffer) 6f91ac3 Bas Bosman - [CB-4907](https://issues.apache.org/jira/browse/CB-4907) Close stream when we're finished with it 651460f Christoph Neumann - [CB-6000](https://issues.apache.org/jira/browse/CB-6000) Nginx rejects Content-Type without a space before "boundary". 35f80e4 Ian Clelland - [CB-6050](https://issues.apache.org/jira/browse/CB-6050): Use instance method on actual file plugin object to get FileEntry to return on download
|
|
||||||
* [CB-5980](https://issues.apache.org/jira/browse/CB-5980) Updated version and RELEASENOTES.md for release 0.4.1
|
|
||||||
|
|
||||||
### 0.4.3 (Apr 17, 2014)
|
|
||||||
* [CB-6422](https://issues.apache.org/jira/browse/CB-6422) [windows8] use cordova/exec/proxy
|
|
||||||
* iOS: Fix error where files were not removed on abort
|
|
||||||
* [CB-5175](https://issues.apache.org/jira/browse/CB-5175): [ios] CDVFileTransfer asynchronous download (Fixes #24)
|
|
||||||
* [ios] Cast id references to NSURL to avoid compiler warnings (Fixes: apache/cordova-plugin-file-transfer#18)
|
|
||||||
* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit
|
|
||||||
* [CB-5762](https://issues.apache.org/jira/browse/CB-5762): [FireOS] android: Fix lengthComputable set wrong for gzip downloads
|
|
||||||
* [CB-5631](https://issues.apache.org/jira/browse/CB-5631): [FireOS] Removed SimpleTrackingInputStream.read(byte[] buffer)
|
|
||||||
* [CB-4907](https://issues.apache.org/jira/browse/CB-4907): [FireOS] Close stream when we're finished with it
|
|
||||||
* [CB-6000](https://issues.apache.org/jira/browse/CB-6000): [FireOS] Nginx rejects Content-Type without a space before "boundary".
|
|
||||||
* [CB-6050](https://issues.apache.org/jira/browse/CB-6050): [FireOS] Use instance method on actual file plugin object to get FileEntry to return on download
|
|
||||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
|
|
||||||
|
|
||||||
### 0.4.2 (Feb 28, 2014)
|
|
||||||
* [CB-6106](https://issues.apache.org/jira/browse/CB-6106) Ensure that nativeURL is used by file transfer download
|
|
||||||
* iOS: Fix default value for trustAllHosts on iOS (YES->NO)
|
|
||||||
* [CB-6059](https://issues.apache.org/jira/browse/CB-6059) iOS: Stop FileTransfer.download doing IO on the UI thread.
|
|
||||||
* [CB-5588](https://issues.apache.org/jira/browse/CB-5588) iOS: Add response headers to upload result
|
|
||||||
* [CB-2190](https://issues.apache.org/jira/browse/CB-2190) iOS: Make backgroundTaskId apply to downloads as well. Move backgroundTaskId to the delegate.
|
|
||||||
* [CB-6050](https://issues.apache.org/jira/browse/CB-6050) Android: Use instance method on actual file plugin object to get FileEntry to return on download
|
|
||||||
* [CB-6000](https://issues.apache.org/jira/browse/CB-6000) Android: Nginx rejects Content-Type without a space before "boundary".
|
|
||||||
* [CB-4907](https://issues.apache.org/jira/browse/CB-4907) Android: Close stream when we're finished with it
|
|
||||||
* [CB-6022](https://issues.apache.org/jira/browse/CB-6022) Add backwards-compatibility notes to doc
|
|
||||||
|
|
||||||
### 0.4.1 (Feb 05, 2014)
|
|
||||||
* [CB-5365](https://issues.apache.org/jira/browse/CB-5365) Remove unused exception var to prevent warnings?
|
|
||||||
* [CB-2421](https://issues.apache.org/jira/browse/CB-2421) explicitly write the bytesSent,responseCode,result to the FileUploadResult pending release of cordova-plugin-file dependency, added some sanity checks for callbacks
|
|
||||||
* iOS: Update for new file plugin api
|
|
||||||
* [CB-5631](https://issues.apache.org/jira/browse/CB-5631) Removed SimpleTrackingInputStream.read(byte[] buffer)
|
|
||||||
* [CB-5762](https://issues.apache.org/jira/browse/CB-5762) android: Fix lengthComputable set wrong for gzip downloads
|
|
||||||
* [CB-4899](https://issues.apache.org/jira/browse/CB-4899) [BlackBerry10] Improve binary file transfer download
|
|
||||||
* Delete stale test/ directory
|
|
||||||
* [CB-5722](https://issues.apache.org/jira/browse/CB-5722) [BlackBerry10] Update upload function to use native file object
|
|
||||||
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Delete stale snapshot of plugin docs
|
|
||||||
* Remove @1 designation from file plugin dependency until pushed to npm
|
|
||||||
* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Update to work with filesystem URLs
|
|
||||||
|
|
||||||
### 0.4.0 (Dec 4, 2013)
|
|
||||||
* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Partial revert; we're not ready yet for FS urls
|
|
||||||
* add ubuntu platform
|
|
||||||
* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Minor version bump
|
|
||||||
* [CB-5466](https://issues.apache.org/jira/browse/CB-5466): Update FileTransfer plugin to accept filesystem urls
|
|
||||||
* Added amazon-fireos platform. Change to use amazon-fireos as the platform if the user agen string contains 'cordova-amazon-fireos'
|
|
||||||
|
|
||||||
### 0.3.4 (Oct 28, 2013)
|
|
||||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for file transfer plugin
|
|
||||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch.
|
|
||||||
|
|
||||||
### 0.3.3 (Oct 9, 2013)
|
|
||||||
* removed un-needed undef check
|
|
||||||
* Fix missing headers in Windows 8 upload proxy
|
|
||||||
* Fix missing headers in Windows 8 Proxy
|
|
||||||
* Fix Windows 8 HTMLAnchorElement return host:80 which force Basic Auth Header to replace options Auth Header
|
|
||||||
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
|
|
||||||
|
|
||||||
### 0.3.2 (Sept 25, 2013)
|
|
||||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
|
|
||||||
* [windows8] commandProxy was moved
|
|
||||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) updating core references
|
|
||||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.file-transfer to org.apache.cordova.file-transfer and updating dependency
|
|
||||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
|
|
@ -1,311 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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-file-transfer
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer)
|
|
||||||
|
|
||||||
Plugin-Dokumentation: <doc/index.md>
|
|
||||||
|
|
||||||
Dieses Plugin ermöglicht Ihnen zum Hochladen und Herunterladen von Dateien.
|
|
||||||
|
|
||||||
Dieses Plugin wird global `FileTransfer`, `FileUploadOptions` Konstruktoren definiert.
|
|
||||||
|
|
||||||
Obwohl im globalen Gültigkeitsbereich, sind sie nicht bis nach dem `deviceready`-Ereignis.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Unterstützte Plattformen
|
|
||||||
|
|
||||||
* Amazon Fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Browser
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 und 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
\ * *Unterstützen keine `Onprogress` noch `abort()` *
|
|
||||||
|
|
||||||
\ ** * `Onprogress` nicht unterstützt*
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
Das `FileTransfer` -Objekt stellt eine Möglichkeit zum Hochladen von Dateien, die mithilfe einer HTTP-mehrteiligen POST oder PUT-Anforderung, und auch Dateien herunterladen.
|
|
||||||
|
|
||||||
## Eigenschaften
|
|
||||||
|
|
||||||
* **OnProgress**: aufgerufen, wobei ein `ProgressEvent` wann wird eine neue Datenmenge übertragen. *(Funktion)*
|
|
||||||
|
|
||||||
## Methoden
|
|
||||||
|
|
||||||
* **Upload**: sendet eine Datei an einen Server.
|
|
||||||
|
|
||||||
* **Download**: lädt eine Datei vom Server.
|
|
||||||
|
|
||||||
* **abort**: Abbruch eine Übertragung in Bearbeitung.
|
|
||||||
|
|
||||||
## Upload
|
|
||||||
|
|
||||||
**Parameter**:
|
|
||||||
|
|
||||||
* **FileURL**: Dateisystem-URL, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten)
|
|
||||||
|
|
||||||
* **Server**: URL des Servers, die Datei zu empfangen, wie kodiert`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: ein Rückruf, der ein `FileUploadResult`-Objekt übergeben wird. *(Funktion)*
|
|
||||||
|
|
||||||
* **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileUploadResult`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)*
|
|
||||||
|
|
||||||
* **Optionen**: optionale Parameter *(Objekt)*. Gültige Schlüssel:
|
|
||||||
|
|
||||||
* **FileKey**: der Name des Form-Elements. Wird standardmäßig auf `file` . (DOM-String und enthält)
|
|
||||||
* **Dateiname**: der Dateiname beim Speichern der Datei auf dem Server verwendet. Wird standardmäßig auf `image.jpg` . (DOM-String und enthält)
|
|
||||||
* **httpMethod**: die HTTP-Methode, die-entweder `PUT` oder `POST`. Der Standardwert ist `POST`. (DOM-String und enthält)
|
|
||||||
* **mimeType**: den Mime-Typ der Daten hochzuladen. Standardwerte auf `Image/Jpeg`. (DOM-String und enthält)
|
|
||||||
* **params**: eine Reihe von optionalen Schlüssel/Wert-Paaren in der HTTP-Anforderung übergeben. (Objekt)
|
|
||||||
* **chunkedMode**: ob die Daten in "Chunked" streaming-Modus hochladen. Der Standardwert ist `true`. (Boolean)
|
|
||||||
* **headers**: eine Karte von Header-Name-Header-Werte. Verwenden Sie ein Array, um mehr als einen Wert anzugeben. Auf iOS, FireOS und Android wenn ein Content-Type-Header vorhanden ist, werden mehrteilige Formulardaten nicht verwendet werden. (Object)
|
|
||||||
* **httpMethod**: die HTTP-Methode zu verwenden, z.B. POST oder PUT. Der Standardwert ist `POST`. (DOM-String enthält)
|
|
||||||
|
|
||||||
* **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)*
|
|
||||||
|
|
||||||
### Beispiel
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Beispiel mit hochladen Kopf- und Progress-Ereignisse (Android und iOS nur)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
Ein `FileUploadResult`-Objekt wird an den Erfolg-Rückruf des `Objekts <code>FileTransfer`-Upload()-Methode</code> übergeben.
|
|
||||||
|
|
||||||
### Eigenschaften
|
|
||||||
|
|
||||||
* **BytesSent**: die Anzahl der Bytes, die als Teil des Uploads an den Server gesendet. (lange)
|
|
||||||
|
|
||||||
* **ResponseCode**: die HTTP-Response-Code vom Server zurückgegeben. (lange)
|
|
||||||
|
|
||||||
* **response**: der HTTP-Antwort vom Server zurückgegeben. (DOM-String und enthält)
|
|
||||||
|
|
||||||
* **Header**: die HTTP-Response-Header vom Server. (Objekt)
|
|
||||||
|
|
||||||
* Derzeit unterstützt auf iOS nur.
|
|
||||||
|
|
||||||
### iOS Macken
|
|
||||||
|
|
||||||
* Unterstützt keine `responseCode` oder`bytesSent`.
|
|
||||||
|
|
||||||
## Download
|
|
||||||
|
|
||||||
**Parameter**:
|
|
||||||
|
|
||||||
* **source**: URL des Servers, um die Datei herunterzuladen, wie kodiert`encodeURI()`.
|
|
||||||
|
|
||||||
* **target**: Dateisystem-Url, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten)
|
|
||||||
|
|
||||||
* **SuccessCallback**: ein Rückruf, der übergeben wird ein `FileEntry` Objekt. *(Funktion)*
|
|
||||||
|
|
||||||
* **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileEntry`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)*
|
|
||||||
|
|
||||||
* **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)*
|
|
||||||
|
|
||||||
* **Options**: optionale Parameter, derzeit nur unterstützt Kopfzeilen (z. B. Autorisierung (Standardauthentifizierung), etc.).
|
|
||||||
|
|
||||||
### Beispiel
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
### WP8 Macken
|
|
||||||
|
|
||||||
* Downloaden anfordert, wird von native Implementierung zwischengespeichert wird. Um zu vermeiden, Zwischenspeicherung, übergeben `If-Modified-Since` Header Methode herunterladen.
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
Bricht einen in-Progress-Transfer. Der Onerror-Rückruf wird ein FileTransferError-Objekt übergeben, die einen Fehlercode FileTransferError.ABORT_ERR hat.
|
|
||||||
|
|
||||||
### Beispiel
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
Ein `FileTransferError`-Objekt wird an eine Fehler-Callback übergeben, wenn ein Fehler auftritt.
|
|
||||||
|
|
||||||
### Eigenschaften
|
|
||||||
|
|
||||||
* **Code**: einer der vordefinierten Fehlercodes aufgeführt. (Anzahl)
|
|
||||||
|
|
||||||
* **Quelle**: URL der Quelle. (String)
|
|
||||||
|
|
||||||
* **Ziel**: URL zum Ziel. (String)
|
|
||||||
|
|
||||||
* **HTTP_STATUS**: HTTP-Statuscode. Dieses Attribut ist nur verfügbar, wenn ein Response-Code aus der HTTP-Verbindung eingeht. (Anzahl)
|
|
||||||
|
|
||||||
* **body** Antworttext. Dieses Attribut ist nur verfügbar, wenn eine Antwort von der HTTP-Verbindung eingeht. (String)
|
|
||||||
|
|
||||||
* **exception**: entweder e.getMessage oder e.toString (String)
|
|
||||||
|
|
||||||
### Konstanten
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Hinweise rückwärts Kompatibilität
|
|
||||||
|
|
||||||
Frühere Versionen des Plugins würde nur Gerät-Absolute-Dateipfade als Quelle für Uploads oder als Ziel für Downloads übernehmen. Diese Pfade wäre in der Regel der form
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Für rückwärts Kompatibilität, diese Pfade noch akzeptiert werden, und wenn Ihre Anwendung Pfade wie diese im permanenten Speicher aufgezeichnet hat, dann sie können weiter verwendet werden.
|
|
||||||
|
|
||||||
Diese Pfade waren zuvor in der Eigenschaft `fullPath` `FileEntry` und `DirectoryEntry`-Objekte, die durch das Plugin Datei zurückgegeben ausgesetzt. Neue Versionen der die Datei-Erweiterung, jedoch nicht länger werden diese Pfade zu JavaScript.
|
|
||||||
|
|
||||||
Wenn Sie ein auf eine neue Upgrade (1.0.0 oder neuere) Version der Datei, und Sie haben zuvor mit `entry.fullPath` als Argumente `download()` oder `upload()`, dann ändern Sie den Code, um die Dateisystem-URLs verwenden müssen.
|
|
||||||
|
|
||||||
`FileEntry.toURL()` und `DirectoryEntry.toURL()` zurück, eine Dateisystem-URL in der form
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
die anstelle der absoluten Dateipfad in `download()` und `upload()` Methode verwendet werden kann.
|
|
|
@ -1,302 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
Dieses Plugin ermöglicht Ihnen zum Hochladen und Herunterladen von Dateien.
|
|
||||||
|
|
||||||
Dieses Plugin wird global `FileTransfer`, `FileUploadOptions` Konstruktoren definiert.
|
|
||||||
|
|
||||||
Obwohl im globalen Gültigkeitsbereich, sind sie nicht bis nach dem `deviceready`-Ereignis.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Unterstützte Plattformen
|
|
||||||
|
|
||||||
* Amazon Fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Browser
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 und 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
* *Unterstützen keine `onprogress` noch `abort()`*
|
|
||||||
|
|
||||||
* * *`onprogress` nicht unterstützt*
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
Das `FileTransfer`-Objekt bietet eine Möglichkeit zum Hochladen von Dateien, die mithilfe einer HTTP-Anforderung für mehrteiligen POST sowie Informationen zum Herunterladen von Dateien sowie.
|
|
||||||
|
|
||||||
## Eigenschaften
|
|
||||||
|
|
||||||
* **OnProgress**: aufgerufen, wobei ein `ProgressEvent` wann wird eine neue Datenmenge übertragen. *(Funktion)*
|
|
||||||
|
|
||||||
## Methoden
|
|
||||||
|
|
||||||
* **Upload**: sendet eine Datei an einen Server.
|
|
||||||
|
|
||||||
* **Download**: lädt eine Datei vom Server.
|
|
||||||
|
|
||||||
* **abort**: Abbruch eine Übertragung in Bearbeitung.
|
|
||||||
|
|
||||||
## Upload
|
|
||||||
|
|
||||||
**Parameter**:
|
|
||||||
|
|
||||||
* **FileURL**: Dateisystem-URL, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten)
|
|
||||||
|
|
||||||
* **Server**: URL des Servers, die Datei zu empfangen, wie kodiert`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: ein Rückruf, der ein `FileUploadResult`-Objekt übergeben wird. *(Funktion)*
|
|
||||||
|
|
||||||
* **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileUploadResult`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)*
|
|
||||||
|
|
||||||
* **Optionen**: optionale Parameter *(Objekt)*. Gültige Schlüssel:
|
|
||||||
|
|
||||||
* **FileKey**: der Name des Form-Elements. Wird standardmäßig auf `file` . (DOM-String und enthält)
|
|
||||||
* **Dateiname**: der Dateiname beim Speichern der Datei auf dem Server verwendet. Wird standardmäßig auf `image.jpg` . (DOM-String und enthält)
|
|
||||||
* **httpMethod**: die HTTP-Methode, die-entweder `PUT` oder `POST`. Der Standardwert ist `POST`. (DOM-String und enthält)
|
|
||||||
* **mimeType**: den Mime-Typ der Daten hochzuladen. Standardwerte auf `Image/Jpeg`. (DOM-String und enthält)
|
|
||||||
* **params**: eine Reihe von optionalen Schlüssel/Wert-Paaren in der HTTP-Anforderung übergeben. (Objekt)
|
|
||||||
* **chunkedMode**: ob die Daten in "Chunked" streaming-Modus hochladen. Der Standardwert ist `true`. (Boolean)
|
|
||||||
* **headers**: eine Karte von Header-Name-Header-Werte. Verwenden Sie ein Array, um mehr als einen Wert anzugeben. (Objekt)
|
|
||||||
|
|
||||||
* **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)*
|
|
||||||
|
|
||||||
### Beispiel
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Beispiel mit hochladen Kopf- und Progress-Ereignisse (Android und iOS nur)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
Ein `FileUploadResult`-Objekt wird an den Erfolg-Rückruf des `Objekts <code>FileTransfer`-Upload()-Methode</code> übergeben.
|
|
||||||
|
|
||||||
### Eigenschaften
|
|
||||||
|
|
||||||
* **BytesSent**: die Anzahl der Bytes, die als Teil des Uploads an den Server gesendet. (lange)
|
|
||||||
|
|
||||||
* **ResponseCode**: die HTTP-Response-Code vom Server zurückgegeben. (lange)
|
|
||||||
|
|
||||||
* **response**: der HTTP-Antwort vom Server zurückgegeben. (DOM-String und enthält)
|
|
||||||
|
|
||||||
* **Header**: die HTTP-Response-Header vom Server. (Objekt)
|
|
||||||
|
|
||||||
* Derzeit unterstützt auf iOS nur.
|
|
||||||
|
|
||||||
### iOS Macken
|
|
||||||
|
|
||||||
* Unterstützt keine `responseCode` oder`bytesSent`.
|
|
||||||
|
|
||||||
## Download
|
|
||||||
|
|
||||||
**Parameter**:
|
|
||||||
|
|
||||||
* **source**: URL des Servers, um die Datei herunterzuladen, wie kodiert`encodeURI()`.
|
|
||||||
|
|
||||||
* **target**: Dateisystem-Url, das die Datei auf dem Gerät. Für rückwärts Kompatibilität, dies kann auch der vollständige Pfad der Datei auf dem Gerät sein. (Siehe [rückwärts Kompatibilität Notes] unten)
|
|
||||||
|
|
||||||
* **SuccessCallback**: ein Rückruf, der übergeben wird ein `FileEntry` Objekt. *(Funktion)*
|
|
||||||
|
|
||||||
* **errorCallback**: ein Rückruf, der ausgeführt wird, tritt ein Fehler beim Abrufen der `FileEntry`. Mit einem `FileTransferError`-Objekt aufgerufen. *(Funktion)*
|
|
||||||
|
|
||||||
* **TrustAllHosts**: Optionaler Parameter, wird standardmäßig auf `false` . Wenn legen Sie auf `true` , es akzeptiert alle Sicherheitszertifikate. Dies ist nützlich, da Android selbstsignierte Zertifikate ablehnt. Nicht für den produktiven Einsatz empfohlen. Auf Android und iOS unterstützt. *(Boolean)*
|
|
||||||
|
|
||||||
* **Options**: optionale Parameter, derzeit nur unterstützt Kopfzeilen (z. B. Autorisierung (Standardauthentifizierung), etc.).
|
|
||||||
|
|
||||||
### Beispiel
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
Bricht einen in-Progress-Transfer. Der Onerror-Rückruf wird ein FileTransferError-Objekt übergeben, die einen Fehlercode FileTransferError.ABORT_ERR hat.
|
|
||||||
|
|
||||||
### Beispiel
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
Ein `FileTransferError`-Objekt wird an eine Fehler-Callback übergeben, wenn ein Fehler auftritt.
|
|
||||||
|
|
||||||
### Eigenschaften
|
|
||||||
|
|
||||||
* **Code**: einer der vordefinierten Fehlercodes aufgeführt. (Anzahl)
|
|
||||||
|
|
||||||
* **Quelle**: URL der Quelle. (String)
|
|
||||||
|
|
||||||
* **Ziel**: URL zum Ziel. (String)
|
|
||||||
|
|
||||||
* **HTTP_STATUS**: HTTP-Statuscode. Dieses Attribut ist nur verfügbar, wenn ein Response-Code aus der HTTP-Verbindung eingeht. (Anzahl)
|
|
||||||
|
|
||||||
* **body** Antworttext. Dieses Attribut ist nur verfügbar, wenn eine Antwort von der HTTP-Verbindung eingeht. (String)
|
|
||||||
|
|
||||||
* **exception**: entweder e.getMessage oder e.toString (String)
|
|
||||||
|
|
||||||
### Konstanten
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Hinweise rückwärts Kompatibilität
|
|
||||||
|
|
||||||
Frühere Versionen des Plugins würde nur Gerät-Absolute-Dateipfade als Quelle für Uploads oder als Ziel für Downloads übernehmen. Diese Pfade wäre in der Regel der form
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Für rückwärts Kompatibilität, diese Pfade noch akzeptiert werden, und wenn Ihre Anwendung Pfade wie diese im permanenten Speicher aufgezeichnet hat, dann sie können weiter verwendet werden.
|
|
||||||
|
|
||||||
Diese Pfade waren zuvor in der Eigenschaft `fullPath` `FileEntry` und `DirectoryEntry`-Objekte, die durch das Plugin Datei zurückgegeben ausgesetzt. Neue Versionen der die Datei-Erweiterung, jedoch nicht länger werden diese Pfade zu JavaScript.
|
|
||||||
|
|
||||||
Wenn Sie ein auf eine neue Upgrade (1.0.0 oder neuere) Version der Datei, und Sie haben zuvor mit `entry.fullPath` als Argumente `download()` oder `upload()`, dann ändern Sie den Code, um die Dateisystem-URLs verwenden müssen.
|
|
||||||
|
|
||||||
`FileEntry.toURL()` und `DirectoryEntry.toURL()` zurück, eine Dateisystem-URL in der form
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
die anstelle der absoluten Dateipfad in `download()` und `upload()` Methode verwendet werden kann.
|
|
|
@ -1,311 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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-file-transfer
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer)
|
|
||||||
|
|
||||||
Documentación del plugin: <doc/index.md>
|
|
||||||
|
|
||||||
Este plugin te permite cargar y descargar archivos.
|
|
||||||
|
|
||||||
Este plugin define global `FileTransfer` , `FileUploadOptions` constructores.
|
|
||||||
|
|
||||||
Aunque en el ámbito global, no están disponibles hasta después de la `deviceready` evento.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Instalación
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Plataformas soportadas
|
|
||||||
|
|
||||||
* Amazon fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Explorador
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 y 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
\ * *No soporta `onprogress` ni `abort()` *
|
|
||||||
|
|
||||||
\ ** *No soporta `onprogress` *
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
El objeto `FileTransfer` proporciona una manera para subir archivos utilizando una varias parte solicitud HTTP POST o PUT y descargar archivos, así.
|
|
||||||
|
|
||||||
## Propiedades
|
|
||||||
|
|
||||||
* **OnProgress**: llama con un `ProgressEvent` cuando se transfiere un nuevo paquete de datos. *(Función)*
|
|
||||||
|
|
||||||
## Métodos
|
|
||||||
|
|
||||||
* **cargar**: envía un archivo a un servidor.
|
|
||||||
|
|
||||||
* **Descargar**: descarga un archivo del servidor.
|
|
||||||
|
|
||||||
* **abortar**: aborta una transferencia en curso.
|
|
||||||
|
|
||||||
## subir
|
|
||||||
|
|
||||||
**Parámetros**:
|
|
||||||
|
|
||||||
* **fileURL**: URL de Filesystem que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo)
|
|
||||||
|
|
||||||
* **servidor**: dirección URL del servidor para recibir el archivo, como codificada por`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: una devolución de llamada que se pasa un `FileUploadResult` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **errorCallback**: una devolución de llamada que se ejecuta si se produce un error recuperar la `FileUploadResult` . Invocado con un `FileTransferError` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **Opciones**: parámetros opcionales *(objeto)*. Teclas válidas:
|
|
||||||
|
|
||||||
* **fileKey**: el nombre del elemento de formulario. Por defecto es `file` . (DOMString)
|
|
||||||
* **nombre de archivo**: el nombre del archivo a utilizar al guardar el archivo en el servidor. Por defecto es `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: método HTTP el utilizar - o `PUT` o `POST` . Por defecto es `POST` . (DOMString)
|
|
||||||
* **mimeType**: el tipo mime de los datos para cargar. Por defecto es `image/jpeg` . (DOMString)
|
|
||||||
* **params**: un conjunto de pares clave/valor opcional para pasar en la petición HTTP. (Objeto)
|
|
||||||
* **chunkedMode**: Si desea cargar los datos en modo de transmisión fragmentado. Por defecto es `true` . (Boolean)
|
|
||||||
* **headers**: un mapa de nombre de encabezado/valores de encabezado Utilice una matriz para especificar más de un valor. En iOS FireOS y Android, si existe un encabezado llamado Content-Type, datos de un formulario multipart no se utilizará. (Object)
|
|
||||||
* **httpMethod**: HTTP el método a utilizar por ejemplo POST o poner. Por defecto `el POST`. (DOMString)
|
|
||||||
|
|
||||||
* **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil ya que Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)*
|
|
||||||
|
|
||||||
### Ejemplo
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Ejemplo con cabeceras de subir y eventos de progreso (Android y iOS solamente)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
A `FileUploadResult` objeto se pasa a la devolución del éxito de la `FileTransfer` del objeto `upload()` método.
|
|
||||||
|
|
||||||
### Propiedades
|
|
||||||
|
|
||||||
* **bytesSent**: el número de bytes enviados al servidor como parte de la carga. (largo)
|
|
||||||
|
|
||||||
* **responseCode**: código de respuesta HTTP el devuelto por el servidor. (largo)
|
|
||||||
|
|
||||||
* **respuesta**: respuesta el HTTP devuelto por el servidor. (DOMString)
|
|
||||||
|
|
||||||
* **cabeceras**: cabeceras de respuesta HTTP el por el servidor. (Objeto)
|
|
||||||
|
|
||||||
* Actualmente compatible con iOS solamente.
|
|
||||||
|
|
||||||
### iOS rarezas
|
|
||||||
|
|
||||||
* No es compatible con `responseCode` o`bytesSent`.
|
|
||||||
|
|
||||||
## descargar
|
|
||||||
|
|
||||||
**Parámetros**:
|
|
||||||
|
|
||||||
* **fuente**: dirección URL del servidor para descargar el archivo, como codificada por`encodeURI()`.
|
|
||||||
|
|
||||||
* **objetivo**: Filesystem url que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo)
|
|
||||||
|
|
||||||
* **successCallback**: una devolución de llamada que se pasa un `FileEntry` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **errorCallback**: una devolución de llamada que se ejecuta si se produce un error al recuperar los `FileEntry` . Invocado con un `FileTransferError` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil porque Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)*
|
|
||||||
|
|
||||||
* **Opciones**: parámetros opcionales, actualmente sólo soporta cabeceras (como autorización (autenticación básica), etc.).
|
|
||||||
|
|
||||||
### Ejemplo
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
### Rarezas de WP8
|
|
||||||
|
|
||||||
* Descargar pide se almacena en caché por aplicación nativa. Para evitar el almacenamiento en caché, pasar `if-Modified-Since` encabezado para descargar el método.
|
|
||||||
|
|
||||||
## abortar
|
|
||||||
|
|
||||||
Aborta a una transferencia en curso. El callback onerror se pasa un objeto FileTransferError que tiene un código de error de FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Ejemplo
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
A `FileTransferError` objeto se pasa a un callback de error cuando se produce un error.
|
|
||||||
|
|
||||||
### Propiedades
|
|
||||||
|
|
||||||
* **código**: uno de los códigos de error predefinido enumerados a continuación. (Número)
|
|
||||||
|
|
||||||
* **fuente**: URL a la fuente. (String)
|
|
||||||
|
|
||||||
* **objetivo**: URL a la meta. (String)
|
|
||||||
|
|
||||||
* **HTTP_STATUS**: código de estado HTTP. Este atributo sólo está disponible cuando se recibe un código de respuesta de la conexión HTTP. (Número)
|
|
||||||
|
|
||||||
* **cuerpo** Cuerpo de la respuesta. Este atributo sólo está disponible cuando se recibe una respuesta de la conexión HTTP. (String)
|
|
||||||
|
|
||||||
* **excepción**: cualquier e.getMessage o e.toString (String)
|
|
||||||
|
|
||||||
### Constantes
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Al revés notas de compatibilidad
|
|
||||||
|
|
||||||
Versiones anteriores de este plugin sólo aceptaría dispositivo-absoluto-archivo-rutas como la fuente de carga, o como destino para las descargas. Estos caminos normalmente sería de la forma
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Para atrás compatibilidad, estos caminos son aceptados todavía, y si su solicitud ha grabado caminos como éstos en almacenamiento persistente, entonces pueden seguir utilizarse.
|
|
||||||
|
|
||||||
Estos caminos fueron expuestos anteriormente en el `fullPath` propiedad de `FileEntry` y `DirectoryEntry` objetos devueltos por el plugin de archivo. Las nuevas versiones del archivo plugin, sin embargo, ya no exponen estos caminos a JavaScript.
|
|
||||||
|
|
||||||
Si va a actualizar a una nueva (1.0.0 o más reciente) versión del archivo y previamente han estado utilizando `entry.fullPath` como argumentos para `download()` o `upload()` , entonces tendrá que cambiar su código para usar URLs de sistema de archivos en su lugar.
|
|
||||||
|
|
||||||
`FileEntry.toURL()`y `DirectoryEntry.toURL()` devolver un filesystem dirección URL de la forma
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
que puede ser utilizado en lugar de la ruta del archivo absoluta tanto en `download()` y `upload()` los métodos.
|
|
|
@ -1,262 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
Este plugin te permite cargar y descargar archivos.
|
|
||||||
|
|
||||||
Este plugin define global `FileTransfer` , `FileUploadOptions` constructores.
|
|
||||||
|
|
||||||
Aunque en el ámbito global, no están disponibles hasta después de la `deviceready` evento.
|
|
||||||
|
|
||||||
document.addEventListener ("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {console.log(FileTransfer)};
|
|
||||||
|
|
||||||
|
|
||||||
## Instalación
|
|
||||||
|
|
||||||
Cordova plugin añade cordova-plugin-file-transferencia
|
|
||||||
|
|
||||||
|
|
||||||
## Plataformas soportadas
|
|
||||||
|
|
||||||
* Amazon fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Explorador
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 y 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
* *No son compatibles con `onprogress` ni `abort()` *
|
|
||||||
|
|
||||||
** *No son compatibles con `onprogress` *
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
El `FileTransfer` objeto proporciona una manera de subir archivos mediante una solicitud HTTP de POST varias parte y para descargar archivos.
|
|
||||||
|
|
||||||
## Propiedades
|
|
||||||
|
|
||||||
* **OnProgress**: llama con un `ProgressEvent` cuando se transfiere un nuevo paquete de datos. *(Función)*
|
|
||||||
|
|
||||||
## Métodos
|
|
||||||
|
|
||||||
* **cargar**: envía un archivo a un servidor.
|
|
||||||
|
|
||||||
* **Descargar**: descarga un archivo del servidor.
|
|
||||||
|
|
||||||
* **abortar**: aborta una transferencia en curso.
|
|
||||||
|
|
||||||
## subir
|
|
||||||
|
|
||||||
**Parámetros**:
|
|
||||||
|
|
||||||
* **fileURL**: URL de Filesystem que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo)
|
|
||||||
|
|
||||||
* **servidor**: dirección URL del servidor para recibir el archivo, como codificada por`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: una devolución de llamada que se pasa un `FileUploadResult` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **errorCallback**: una devolución de llamada que se ejecuta si se produce un error recuperar la `FileUploadResult` . Invocado con un `FileTransferError` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **Opciones**: parámetros opcionales *(objeto)*. Teclas válidas:
|
|
||||||
|
|
||||||
* **fileKey**: el nombre del elemento de formulario. Por defecto es `file` . (DOMString)
|
|
||||||
* **nombre de archivo**: el nombre del archivo a utilizar al guardar el archivo en el servidor. Por defecto es `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: método HTTP el utilizar - o `PUT` o `POST` . Por defecto es `POST` . (DOMString)
|
|
||||||
* **mimeType**: el tipo mime de los datos para cargar. Por defecto es `image/jpeg` . (DOMString)
|
|
||||||
* **params**: un conjunto de pares clave/valor opcional para pasar en la petición HTTP. (Objeto)
|
|
||||||
* **chunkedMode**: Si desea cargar los datos en modo de transmisión fragmentado. Por defecto es `true` . (Boolean)
|
|
||||||
* **cabeceras**: un mapa de valores de encabezado nombre/cabecera. Utilice una matriz para especificar más de un valor. (Objeto)
|
|
||||||
|
|
||||||
* **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil ya que Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)*
|
|
||||||
|
|
||||||
### Ejemplo
|
|
||||||
|
|
||||||
// !! Asume fileURL variable contiene una dirección URL válida a un archivo de texto en el dispositivo, / / por ejemplo, ganar var cdvfile://localhost/persistent/path/to/file.txt = function (r) {console.log ("código =" + r.responseCode);
|
|
||||||
Console.log ("respuesta =" + r.response);
|
|
||||||
Console.log ("Sent =" + r.bytesSent);}
|
|
||||||
|
|
||||||
var fallar = function (error) {alert ("ha ocurrido un error: código =" + error.code);
|
|
||||||
Console.log ("error al cargar el origen" + error.source);
|
|
||||||
Console.log ("upload error objetivo" + error.target);}
|
|
||||||
|
|
||||||
var opciones = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "prueba";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
Ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, opciones);
|
|
||||||
|
|
||||||
|
|
||||||
### Ejemplo con cabeceras de subir y eventos de progreso (Android y iOS solamente)
|
|
||||||
|
|
||||||
function win(r) {console.log ("código =" + r.responseCode);
|
|
||||||
Console.log ("respuesta =" + r.response);
|
|
||||||
Console.log ("Sent =" + r.bytesSent);}
|
|
||||||
|
|
||||||
function fail(error) {alert ("ha ocurrido un error: código =" + error.code);
|
|
||||||
Console.log ("error al cargar el origen" + error.source);
|
|
||||||
Console.log ("upload error objetivo" + error.target);}
|
|
||||||
|
|
||||||
var uri = encodeURI ("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var opciones = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
cabeceras de var ={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = encabezados;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
Ft.OnProgress = function(progressEvent) {si (progressEvent.lengthComputable) {loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} {loadingStatus.increment() más;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Ft.upload (fileURL, uri, win, fail, opciones);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
A `FileUploadResult` objeto se pasa a la devolución del éxito de la `FileTransfer` del objeto `upload()` método.
|
|
||||||
|
|
||||||
### Propiedades
|
|
||||||
|
|
||||||
* **bytesSent**: el número de bytes enviados al servidor como parte de la carga. (largo)
|
|
||||||
|
|
||||||
* **responseCode**: código de respuesta HTTP el devuelto por el servidor. (largo)
|
|
||||||
|
|
||||||
* **respuesta**: respuesta el HTTP devuelto por el servidor. (DOMString)
|
|
||||||
|
|
||||||
* **cabeceras**: cabeceras de respuesta HTTP el por el servidor. (Objeto)
|
|
||||||
|
|
||||||
* Actualmente compatible con iOS solamente.
|
|
||||||
|
|
||||||
### iOS rarezas
|
|
||||||
|
|
||||||
* No es compatible con `responseCode` o`bytesSent`.
|
|
||||||
|
|
||||||
## descargar
|
|
||||||
|
|
||||||
**Parámetros**:
|
|
||||||
|
|
||||||
* **fuente**: dirección URL del servidor para descargar el archivo, como codificada por`encodeURI()`.
|
|
||||||
|
|
||||||
* **objetivo**: Filesystem url que representa el archivo en el dispositivo. Para atrás compatibilidad, esto también puede ser la ruta de acceso completa del archivo en el dispositivo. (Ver [hacia atrás compatibilidad notas] debajo)
|
|
||||||
|
|
||||||
* **successCallback**: una devolución de llamada que se pasa un `FileEntry` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **errorCallback**: una devolución de llamada que se ejecuta si se produce un error al recuperar los `FileEntry` . Invocado con un `FileTransferError` objeto. *(Función)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: parámetro opcional, por defecto es `false` . Si establece en `true` , acepta todos los certificados de seguridad. Esto es útil porque Android rechaza certificados autofirmados seguridad. No se recomienda para uso productivo. Compatible con iOS y Android. *(boolean)*
|
|
||||||
|
|
||||||
* **Opciones**: parámetros opcionales, actualmente sólo soporta cabeceras (como autorización (autenticación básica), etc.).
|
|
||||||
|
|
||||||
### Ejemplo
|
|
||||||
|
|
||||||
// !! Asume fileURL variable contiene una dirección URL válida a un camino en el dispositivo, / / por ejemplo, File Transfer var cdvfile://localhost/persistent/path/to/downloads/ = new FileTransfer();
|
|
||||||
var uri = encodeURI ("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download (uri, fileURL, function(entry) {console.log ("descarga completa:" + entry.toURL());
|
|
||||||
}, function(error) {console.log ("error al descargar el origen" + error.source);
|
|
||||||
Console.log ("descargar error objetivo" + error.target);
|
|
||||||
Console.log ("código de error de carga" + error.code);
|
|
||||||
}, falso, {encabezados: {"Autorización": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA =="}});
|
|
||||||
|
|
||||||
|
|
||||||
## abortar
|
|
||||||
|
|
||||||
Aborta a una transferencia en curso. El callback onerror se pasa un objeto FileTransferError que tiene un código de error de FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Ejemplo
|
|
||||||
|
|
||||||
// !! Asume fileURL variable contiene una dirección URL válida a un archivo de texto en el dispositivo, / / por ejemplo, ganar cdvfile://localhost/persistent/path/to/file.txt var function(r) = {console.log ("no se debe llamar.");}
|
|
||||||
|
|
||||||
var fallar = function(error) {/ / error.code == FileTransferError.ABORT_ERR alert ("ha ocurrido un error: código =" + error.code);
|
|
||||||
Console.log ("error al cargar el origen" + error.source);
|
|
||||||
Console.log ("upload error objetivo" + error.target);}
|
|
||||||
|
|
||||||
var opciones = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
Ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, opciones);
|
|
||||||
Ft.Abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
A `FileTransferError` objeto se pasa a un callback de error cuando se produce un error.
|
|
||||||
|
|
||||||
### Propiedades
|
|
||||||
|
|
||||||
* **código**: uno de los códigos de error predefinido enumerados a continuación. (Número)
|
|
||||||
|
|
||||||
* **fuente**: URL a la fuente. (String)
|
|
||||||
|
|
||||||
* **objetivo**: URL a la meta. (String)
|
|
||||||
|
|
||||||
* **HTTP_STATUS**: código de estado HTTP. Este atributo sólo está disponible cuando se recibe un código de respuesta de la conexión HTTP. (Número)
|
|
||||||
|
|
||||||
* **cuerpo** Cuerpo de la respuesta. Este atributo sólo está disponible cuando se recibe una respuesta de la conexión HTTP. (String)
|
|
||||||
|
|
||||||
* **excepción**: cualquier e.getMessage o e.toString (String)
|
|
||||||
|
|
||||||
### Constantes
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Al revés notas de compatibilidad
|
|
||||||
|
|
||||||
Versiones anteriores de este plugin sólo aceptaría dispositivo-absoluto-archivo-rutas como la fuente de carga, o como destino para las descargas. Estos caminos normalmente sería de la forma
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Para atrás compatibilidad, estos caminos son aceptados todavía, y si su solicitud ha grabado caminos como éstos en almacenamiento persistente, entonces pueden seguir utilizarse.
|
|
||||||
|
|
||||||
Estos caminos fueron expuestos anteriormente en el `fullPath` propiedad de `FileEntry` y `DirectoryEntry` objetos devueltos por el plugin de archivo. Las nuevas versiones del archivo plugin, sin embargo, ya no exponen estos caminos a JavaScript.
|
|
||||||
|
|
||||||
Si va a actualizar a una nueva (1.0.0 o más reciente) versión del archivo y previamente han estado utilizando `entry.fullPath` como argumentos para `download()` o `upload()` , entonces tendrá que cambiar su código para usar URLs de sistema de archivos en su lugar.
|
|
||||||
|
|
||||||
`FileEntry.toURL()`y `DirectoryEntry.toURL()` devolver un filesystem dirección URL de la forma
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
que puede ser utilizado en lugar de la ruta del archivo absoluta tanto en `download()` y `upload()` los métodos.
|
|
|
@ -1,270 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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-file-transfer
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer)
|
|
||||||
|
|
||||||
Documentation du plugin : <doc/index.md>
|
|
||||||
|
|
||||||
Ce plugin vous permet de télécharger des fichiers.
|
|
||||||
|
|
||||||
Ce plugin définit global `FileTransfer` , `FileUploadOptions` constructeurs.
|
|
||||||
|
|
||||||
Bien que dans la portée globale, ils ne sont pas disponibles jusqu'après la `deviceready` événement.
|
|
||||||
|
|
||||||
document.addEventListener (« deviceready », onDeviceReady, false) ;
|
|
||||||
function onDeviceReady() {console.log(FileTransfer);}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Plates-formes supportées
|
|
||||||
|
|
||||||
* Amazon Fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Navigateur
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 et 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
\ * *Ne supportent pas `onprogress` ni `abort()` *
|
|
||||||
|
|
||||||
\ ** *Ne prennent pas en charge les `onprogress` *
|
|
||||||
|
|
||||||
# Transfert de fichiers
|
|
||||||
|
|
||||||
L'objet de `FileTransfer` fournit un moyen de télécharger des fichiers à l'aide d'une requête HTTP multi-part POST ou PUT et pour télécharger des fichiers.
|
|
||||||
|
|
||||||
## Propriétés
|
|
||||||
|
|
||||||
* **onprogress** : fonction appelée avec un `ProgressEvent` à chaque fois qu'un nouveau segment de données est transféré. *(Function)*
|
|
||||||
|
|
||||||
## Méthodes
|
|
||||||
|
|
||||||
* **upload** : envoie un fichier à un serveur.
|
|
||||||
|
|
||||||
* **download** : télécharge un fichier depuis un serveur.
|
|
||||||
|
|
||||||
* **abort** : annule le transfert en cours.
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
**Paramètres**:
|
|
||||||
|
|
||||||
* **fileURL** : système de fichiers URL représentant le fichier sur le périphérique. Pour la compatibilité ascendante, cela peut aussi être le chemin complet du fichier sur le périphérique. (Voir [Backwards Compatibility Notes] ci-dessous)
|
|
||||||
|
|
||||||
* **server** : l'URL du serveur destiné à recevoir le fichier, encodée via `encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: un rappel passé un `FileUploadResult` objet. *(Fonction)*
|
|
||||||
|
|
||||||
* **errorCallback**: un rappel qui s'exécute si une erreur survient récupérer la `FileUploadResult` . Appelée avec un `FileTransferError` objet. *(Fonction)*
|
|
||||||
|
|
||||||
* **options**: paramètres facultatifs *(objet)*. Clés valides :
|
|
||||||
|
|
||||||
* **fileKey**: le nom de l'élément form. Valeur par défaut est `file` . (DOMString)
|
|
||||||
* **fileName**: le nom de fichier à utiliser lorsque vous enregistrez le fichier sur le serveur. Valeur par défaut est `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: méthode de The HTTP à utiliser - soit `PUT` ou `POST` . Valeur par défaut est `POST` . (DOMString)
|
|
||||||
* **type MIME**: le type mime des données à télécharger. Valeur par défaut est `image/jpeg` . (DOMString)
|
|
||||||
* **params**: un ensemble de paires clé/valeur facultative pour passer dans la requête HTTP. (Objet)
|
|
||||||
* **chunkedMode**: s'il faut télécharger les données en mode streaming mémorisé en bloc. Valeur par défaut est `true` . (Boolean)
|
|
||||||
* **headers**: une carte des valeurs d'en-tête en-tête/nom. Un tableau permet de spécifier plusieurs valeurs. Sur iOS, FireOS et Android, si un en-tête nommé Content-Type n'est présent, les données de formulaire multipart servira pas. (Object)
|
|
||||||
* **httpMethod**: The HTTP méthode à utiliser par exemple poster ou mis. Par défaut, `message`. (DOMString)
|
|
||||||
|
|
||||||
* **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur est `true` , il accepte tous les certificats de sécurité. Ceci est utile car Android rejette des certificats auto-signés. N'est pas recommandé pour une utilisation en production. Supporté sur Android et iOS. *(booléen)*
|
|
||||||
|
|
||||||
### Exemple
|
|
||||||
|
|
||||||
// !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function (r) {console.log ("Code =" + r.responseCode) ;
|
|
||||||
Console.log ("réponse =" + r.response) ;
|
|
||||||
Console.log ("envoyés =" + r.bytesSent);}
|
|
||||||
|
|
||||||
échouer var = function (erreur) {alert ("une erreur est survenue : Code =" + error.code) ;
|
|
||||||
Console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log ("erreur de téléchargement cible" + error.target);}
|
|
||||||
|
|
||||||
options de var = new FileUploadOptions() ;
|
|
||||||
options.fileKey = « fichier » ;
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1) ;
|
|
||||||
options.mimeType = « text/plain » ;
|
|
||||||
|
|
||||||
var params = {} ;
|
|
||||||
params.value1 = « test » ;
|
|
||||||
params.Value2 = « param » ;
|
|
||||||
|
|
||||||
options.params = params ;
|
|
||||||
|
|
||||||
ft var = new FileTransfer() ;
|
|
||||||
ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ;
|
|
||||||
|
|
||||||
|
|
||||||
### Exemple avec téléchargement du Header et des Progress Events (Android et iOS uniquement)
|
|
||||||
|
|
||||||
function win(r) {console.log ("Code =" + r.responseCode) ;
|
|
||||||
Console.log ("réponse =" + r.response) ;
|
|
||||||
Console.log ("envoyés =" + r.bytesSent);}
|
|
||||||
|
|
||||||
function fail(error) {alert ("une erreur est survenue : Code =" + error.code) ;
|
|
||||||
Console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log ("erreur de téléchargement cible" + error.target);}
|
|
||||||
|
|
||||||
var uri = encodeURI ("http://some.server.com/upload.php") ;
|
|
||||||
|
|
||||||
options de var = new FileUploadOptions() ;
|
|
||||||
options.fileKey="file" ;
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1) ;
|
|
||||||
options.mimeType="text/plain" ;
|
|
||||||
|
|
||||||
en-têtes var ={'headerParam':'headerValue'} ;
|
|
||||||
|
|
||||||
options.Headers = en-têtes ;
|
|
||||||
|
|
||||||
ft var = new FileTransfer() ;
|
|
||||||
ft.OnProgress = function(progressEvent) {si (progressEvent.lengthComputable) {loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total) ;
|
|
||||||
} else {loadingStatus.increment() ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload (fileURL, uri, win, fail, options) ;
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
A `FileUploadResult` objet est passé au rappel de succès la `FileTransfer` de l'objet `upload()` méthode.
|
|
||||||
|
|
||||||
### Propriétés
|
|
||||||
|
|
||||||
* **bytesSent** : le nombre d'octets envoyés au serveur dans le cadre du téléchargement. (long)
|
|
||||||
|
|
||||||
* **responseCode** : le code de réponse HTTP retourné par le serveur. (long)
|
|
||||||
|
|
||||||
* **response** : la réponse HTTP renvoyée par le serveur. (DOMString)
|
|
||||||
|
|
||||||
* **en-têtes** : en-têtes de réponse HTTP par le serveur. (Objet)
|
|
||||||
|
|
||||||
* Actuellement pris en charge sur iOS seulement.
|
|
||||||
|
|
||||||
### Notes au sujet d'iOS
|
|
||||||
|
|
||||||
* Ne prend pas en charge les propriétés `responseCode` et `bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**Paramètres**:
|
|
||||||
|
|
||||||
* **source** : l'URL du serveur depuis lequel télécharger le fichier, encodée via `encodeURI()`.
|
|
||||||
|
|
||||||
* **target** : système de fichiers url représentant le fichier sur le périphérique. Pour la compatibilité ascendante, cela peut aussi être le chemin complet du fichier sur le périphérique. (Voir [Backwards Compatibility Notes] ci-dessous)
|
|
||||||
|
|
||||||
* **successCallback** : une callback de succès à laquelle est passée un objet `FileEntry`. *(Function)*
|
|
||||||
|
|
||||||
* **errorCallback**: un rappel qui s'exécute si une erreur se produit lors de la récupération du `FileEntry` . Appelée avec un `FileTransferError` objet. *(Fonction)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur est `true` , il accepte tous les certificats de sécurité. Ceci peut être utile car Android rejette les certificats auto-signés. N'est pas recommandé pour une utilisation en production. Supporté sur Android et iOS. *(booléen)*
|
|
||||||
|
|
||||||
* **options** : paramètres facultatifs, seules les en-têtes sont actuellement supportées (par exemple l'autorisation (authentification basique), etc.).
|
|
||||||
|
|
||||||
### Exemple
|
|
||||||
|
|
||||||
// !! Suppose fileURL variable contient une URL valide vers un chemin d'accès sur le périphérique, / / par exemple, transfert de fichiers var cdvfile://localhost/persistent/path/to/downloads/ = new FileTransfer() ;
|
|
||||||
var uri = encodeURI ("http://some.server.com/download.php") ;
|
|
||||||
|
|
||||||
fileTransfer.download (uri, fileURL, function(entry) {console.log ("téléchargement complet:" + entry.toURL()) ;
|
|
||||||
}, function(error) {console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log (« erreur de téléchargement cible » + error.target) ;
|
|
||||||
Console.log (« code d'erreur de téléchargement » + error.code) ;
|
|
||||||
}, faux, {en-têtes: {« Autorisation »: « dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA base == "}}) ;
|
|
||||||
|
|
||||||
|
|
||||||
### Quirks wp8
|
|
||||||
|
|
||||||
* Télécharger demande est mis en cache par l'implémentation native. Pour éviter la mise en cache, pass `if-Modified-Since` en-tête Télécharger méthode.
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
Abandonne un transfert en cours. Le rappel onerror est passé à un objet FileTransferError qui a un code d'erreur de FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Exemple
|
|
||||||
|
|
||||||
// !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function(r) {console.log ("ne devrait pas être appelée.");}
|
|
||||||
|
|
||||||
var fail = function(error) {/ / error.code == FileTransferError.ABORT_ERR alert ("une erreur est survenue : Code =" + error.code) ;
|
|
||||||
Console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log ("erreur de téléchargement cible" + error.target);}
|
|
||||||
|
|
||||||
options de var = new FileUploadOptions() ;
|
|
||||||
options.fileKey="file" ;
|
|
||||||
options.fileName="myphoto.jpg" ;
|
|
||||||
options.mimeType="image/jpeg" ;
|
|
||||||
|
|
||||||
ft var = new FileTransfer() ;
|
|
||||||
ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ;
|
|
||||||
ft.Abort() ;
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
A `FileTransferError` objet est passé à un rappel d'erreur lorsqu'une erreur survient.
|
|
||||||
|
|
||||||
### Propriétés
|
|
||||||
|
|
||||||
* **code** : l'un des codes d'erreur prédéfinis énumérés ci-dessous. (Number)
|
|
||||||
|
|
||||||
* **source** : l'URI de la source. (String)
|
|
||||||
|
|
||||||
* **target**: l'URI de la destination. (String)
|
|
||||||
|
|
||||||
* **http_status** : code d'état HTTP. Cet attribut n'est disponible que lorsqu'un code de réponse est fourni via la connexion HTTP. (Number)
|
|
||||||
|
|
||||||
* **corps** Corps de réponse. Cet attribut n'est disponible que lorsqu'une réponse est reçue de la connexion HTTP. (String)
|
|
||||||
|
|
||||||
* **exception**: soit e.getMessage ou e.toString (String)
|
|
||||||
|
|
||||||
### Constantes
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Backwards Compatibility Notes
|
|
||||||
|
|
||||||
Les versions précédentes de ce plugin n'accepterait périphérique--fichier-chemins d'accès absolus comme source pour les téléchargements, ou comme cible pour les téléchargements. Ces chemins seraient généralement de la forme
|
|
||||||
|
|
||||||
/ var/mobile/Applications/< application UUID >/Documents/chemin/vers/fichier (iOS), /storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Pour vers l'arrière la compatibilité, ces chemins sont toujours acceptés, et si votre application a enregistré des chemins comme celles-ci dans un stockage persistant, alors ils peuvent continuer à être utilisé.
|
|
||||||
|
|
||||||
Ces chemins ont été précédemment exposés dans le `fullPath` propriété de `FileEntry` et `DirectoryEntry` les objets retournés par le fichier plugin. Nouvelles versions du fichier plugin, cependant, ne plus exposent ces chemins à JavaScript.
|
|
||||||
|
|
||||||
Si vous migrez vers une nouvelle (1.0.0 ou plus récent) version de fichier et vous avez précédemment utilisé `entry.fullPath` comme arguments à `download()` ou `upload()` , alors vous aurez besoin de modifier votre code pour utiliser le système de fichiers URL au lieu de cela.
|
|
||||||
|
|
||||||
`FileEntry.toURL()`et `DirectoryEntry.toURL()` retournent une URL de système de fichiers du formulaire
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
qui peut être utilisé à la place le chemin d'accès absolu au fichier dans les deux `download()` et `upload()` méthodes.
|
|
|
@ -1,261 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
Ce plugin vous permet de télécharger des fichiers.
|
|
||||||
|
|
||||||
Ce plugin définit global `FileTransfer` , `FileUploadOptions` constructeurs.
|
|
||||||
|
|
||||||
Bien que dans la portée globale, ils ne sont pas disponibles jusqu'après la `deviceready` événement.
|
|
||||||
|
|
||||||
document.addEventListener (« deviceready », onDeviceReady, false) ;
|
|
||||||
function onDeviceReady() {console.log(FileTransfer);}
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Cordova plugin ajouter cordova-plugin-file-transfert
|
|
||||||
|
|
||||||
|
|
||||||
## Plates-formes prises en charge
|
|
||||||
|
|
||||||
* Amazon Fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Navigateur
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 et 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
* *Ne supportent pas `onprogress` ni `abort()` *
|
|
||||||
|
|
||||||
** *Ne prennent pas en charge `onprogress` *
|
|
||||||
|
|
||||||
# Transfert de fichiers
|
|
||||||
|
|
||||||
Le `FileTransfer` objet fournit un moyen de télécharger des fichiers à l'aide d'une requête HTTP de la poste plusieurs partie et pour télécharger des fichiers aussi bien.
|
|
||||||
|
|
||||||
## Propriétés
|
|
||||||
|
|
||||||
* **onprogress** : fonction appelée avec un `ProgressEvent` à chaque fois qu'un nouveau segment de données est transféré. *(Function)*
|
|
||||||
|
|
||||||
## Méthodes
|
|
||||||
|
|
||||||
* **upload** : envoie un fichier à un serveur.
|
|
||||||
|
|
||||||
* **download** : télécharge un fichier depuis un serveur.
|
|
||||||
|
|
||||||
* **abort** : annule le transfert en cours.
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
**Paramètres**:
|
|
||||||
|
|
||||||
* **fileURL** : système de fichiers URL représentant le fichier sur le périphérique. Pour la compatibilité ascendante, cela peut aussi être le chemin complet du fichier sur le périphérique. (Voir [Backwards Compatibility Notes] ci-dessous)
|
|
||||||
|
|
||||||
* **server** : l'URL du serveur destiné à recevoir le fichier, encodée via `encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: un rappel passé un `FileUploadResult` objet. *(Fonction)*
|
|
||||||
|
|
||||||
* **errorCallback**: un rappel qui s'exécute si une erreur survient récupérer la `FileUploadResult` . Appelée avec un `FileTransferError` objet. *(Fonction)*
|
|
||||||
|
|
||||||
* **options**: paramètres facultatifs *(objet)*. Clés valides :
|
|
||||||
|
|
||||||
* **fileKey**: le nom de l'élément form. Valeur par défaut est `file` . (DOMString)
|
|
||||||
* **fileName**: le nom de fichier à utiliser lorsque vous enregistrez le fichier sur le serveur. Valeur par défaut est `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: méthode de The HTTP à utiliser - soit `PUT` ou `POST` . Valeur par défaut est `POST` . (DOMString)
|
|
||||||
* **type MIME**: le type mime des données à télécharger. Valeur par défaut est `image/jpeg` . (DOMString)
|
|
||||||
* **params**: un ensemble de paires clé/valeur facultative pour passer dans la requête HTTP. (Objet)
|
|
||||||
* **chunkedMode**: s'il faut télécharger les données en mode streaming mémorisé en bloc. Valeur par défaut est `true` . (Boolean)
|
|
||||||
* **en-têtes**: une carte des valeurs d'en-tête en-tête/nom. Un tableau permet de spécifier plusieurs valeurs. (Objet)
|
|
||||||
|
|
||||||
* **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur `true` , il accepte tous les certificats de sécurité. Ceci est utile car Android rejette des certificats auto-signés. Non recommandé pour une utilisation de production. Supporté sur Android et iOS. *(boolean)*
|
|
||||||
|
|
||||||
### Exemple
|
|
||||||
|
|
||||||
// !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function (r) {console.log ("Code =" + r.responseCode) ;
|
|
||||||
Console.log ("réponse =" + r.response) ;
|
|
||||||
Console.log ("envoyés =" + r.bytesSent);}
|
|
||||||
|
|
||||||
échouer var = function (erreur) {alert ("une erreur est survenue : Code =" + error.code) ;
|
|
||||||
Console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log ("erreur de téléchargement cible" + error.target);}
|
|
||||||
|
|
||||||
options de var = new FileUploadOptions() ;
|
|
||||||
options.fileKey = « fichier » ;
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1) ;
|
|
||||||
options.mimeType = « text/plain » ;
|
|
||||||
|
|
||||||
var params = {} ;
|
|
||||||
params.value1 = « test » ;
|
|
||||||
params.Value2 = « param » ;
|
|
||||||
|
|
||||||
options.params = params ;
|
|
||||||
|
|
||||||
ft var = new FileTransfer() ;
|
|
||||||
ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ;
|
|
||||||
|
|
||||||
|
|
||||||
### Exemple avec téléchargement du Header et des Progress Events (Android et iOS uniquement)
|
|
||||||
|
|
||||||
function win(r) {console.log ("Code =" + r.responseCode) ;
|
|
||||||
Console.log ("réponse =" + r.response) ;
|
|
||||||
Console.log ("envoyés =" + r.bytesSent);}
|
|
||||||
|
|
||||||
function fail(error) {alert ("une erreur est survenue : Code =" + error.code) ;
|
|
||||||
Console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log ("erreur de téléchargement cible" + error.target);}
|
|
||||||
|
|
||||||
var uri = encodeURI ("http://some.server.com/upload.php") ;
|
|
||||||
|
|
||||||
options de var = new FileUploadOptions() ;
|
|
||||||
options.fileKey="file" ;
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1) ;
|
|
||||||
options.mimeType="text/plain" ;
|
|
||||||
|
|
||||||
en-têtes var ={'headerParam':'headerValue'} ;
|
|
||||||
|
|
||||||
options.Headers = en-têtes ;
|
|
||||||
|
|
||||||
ft var = new FileTransfer() ;
|
|
||||||
ft.OnProgress = function(progressEvent) {si (progressEvent.lengthComputable) {loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total) ;
|
|
||||||
} else {loadingStatus.increment() ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload (fileURL, uri, win, fail, options) ;
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
A `FileUploadResult` objet est passé au rappel de succès la `FileTransfer` de l'objet `upload()` méthode.
|
|
||||||
|
|
||||||
### Propriétés
|
|
||||||
|
|
||||||
* **bytesSent** : le nombre d'octets envoyés au serveur dans le cadre du téléchargement. (long)
|
|
||||||
|
|
||||||
* **responseCode** : le code de réponse HTTP retourné par le serveur. (long)
|
|
||||||
|
|
||||||
* **response** : la réponse HTTP renvoyée par le serveur. (DOMString)
|
|
||||||
|
|
||||||
* **en-têtes** : en-têtes de réponse HTTP par le serveur. (Objet)
|
|
||||||
|
|
||||||
* Actuellement pris en charge sur iOS seulement.
|
|
||||||
|
|
||||||
### iOS Remarques
|
|
||||||
|
|
||||||
* Ne prend pas en charge les propriétés `responseCode` et `bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**Paramètres**:
|
|
||||||
|
|
||||||
* **source** : l'URL du serveur depuis lequel télécharger le fichier, encodée via `encodeURI()`.
|
|
||||||
|
|
||||||
* **target** : système de fichiers url représentant le fichier sur le périphérique. Pour vers l'arrière la compatibilité, cela peut aussi être le chemin d'accès complet du fichier sur le périphérique. (Voir [vers l'arrière compatibilité note] ci-dessous)
|
|
||||||
|
|
||||||
* **successCallback** : une callback de succès à laquelle est passée un objet `FileEntry`. *(Function)*
|
|
||||||
|
|
||||||
* **errorCallback**: un rappel qui s'exécute si une erreur se produit lors de la récupération du `FileEntry` . Appelée avec un `FileTransferError` objet. *(Fonction)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: paramètre facultatif, valeur par défaut est `false` . Si la valeur est `true` , il accepte tous les certificats de sécurité. Ceci peut être utile car Android rejette les certificats auto-signés. N'est pas recommandé pour une utilisation en production. Supporté sur Android et iOS. *(booléen)*
|
|
||||||
|
|
||||||
* **options** : paramètres facultatifs, seules les en-têtes sont actuellement supportées (par exemple l'autorisation (authentification basique), etc.).
|
|
||||||
|
|
||||||
### Exemple
|
|
||||||
|
|
||||||
// !! Suppose fileURL variable contient une URL valide vers un chemin d'accès sur le périphérique, / / par exemple, transfert de fichiers var cdvfile://localhost/persistent/path/to/downloads/ = new FileTransfer() ;
|
|
||||||
var uri = encodeURI ("http://some.server.com/download.php") ;
|
|
||||||
|
|
||||||
fileTransfer.download (uri, fileURL, function(entry) {console.log ("téléchargement complet:" + entry.toURL()) ;
|
|
||||||
}, function(error) {console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log (« erreur de téléchargement cible » + error.target) ;
|
|
||||||
Console.log (« code d'erreur de téléchargement » + error.code) ;
|
|
||||||
}, faux, {en-têtes: {« Autorisation »: « dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA base == "}}) ;
|
|
||||||
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
Abandonne un transfert en cours. Le rappel onerror est passé à un objet FileTransferError qui a un code d'erreur de FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Exemple
|
|
||||||
|
|
||||||
// !! Suppose fileURL variable contient une URL valide dans un fichier texte sur le périphérique, / / par exemple, cdvfile://localhost/persistent/path/to/file.txt var win = function(r) {console.log ("ne devrait pas être appelée.");}
|
|
||||||
|
|
||||||
var fail = function(error) {/ / error.code == FileTransferError.ABORT_ERR alert ("une erreur est survenue : Code =" + error.code) ;
|
|
||||||
Console.log (« source de l'erreur de téléchargement » + error.source) ;
|
|
||||||
Console.log ("erreur de téléchargement cible" + error.target);}
|
|
||||||
|
|
||||||
options de var = new FileUploadOptions() ;
|
|
||||||
options.fileKey="file" ;
|
|
||||||
options.fileName="myphoto.jpg" ;
|
|
||||||
options.mimeType="image/jpeg" ;
|
|
||||||
|
|
||||||
ft var = new FileTransfer() ;
|
|
||||||
ft.upload (fileURL, encodeURI ("http://some.server.com/upload.php"), win, fail, options) ;
|
|
||||||
ft.Abort() ;
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
A `FileTransferError` objet est passé à un rappel d'erreur lorsqu'une erreur survient.
|
|
||||||
|
|
||||||
### Propriétés
|
|
||||||
|
|
||||||
* **code** : l'un des codes d'erreur prédéfinis énumérés ci-dessous. (Number)
|
|
||||||
|
|
||||||
* **source** : l'URI de la source. (String)
|
|
||||||
|
|
||||||
* **target**: l'URI de la destination. (String)
|
|
||||||
|
|
||||||
* **http_status** : code d'état HTTP. Cet attribut n'est disponible que lorsqu'un code de réponse est fourni via la connexion HTTP. (Number)
|
|
||||||
|
|
||||||
* **corps** Corps de réponse. Cet attribut n'est disponible que lorsqu'une réponse est reçue de la connexion HTTP. (String)
|
|
||||||
|
|
||||||
* **exception**: soit e.getMessage ou e.toString (String)
|
|
||||||
|
|
||||||
### Constantes
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Backwards Compatibility Notes
|
|
||||||
|
|
||||||
Les versions précédentes de ce plugin n'accepterait périphérique--fichier-chemins d'accès absolus comme source pour les téléchargements, ou comme cible pour les téléchargements. Ces chemins seraient généralement de la forme
|
|
||||||
|
|
||||||
/ var/mobile/Applications/< application UUID >/Documents/chemin/vers/fichier (iOS), /storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Pour vers l'arrière la compatibilité, ces chemins sont toujours acceptés, et si votre application a enregistré des chemins comme celles-ci dans un stockage persistant, alors ils peuvent continuer à être utilisé.
|
|
||||||
|
|
||||||
Ces chemins ont été précédemment exposés dans le `fullPath` propriété de `FileEntry` et `DirectoryEntry` les objets retournés par le fichier plugin. Nouvelles versions du fichier plugin, cependant, ne plus exposent ces chemins à JavaScript.
|
|
||||||
|
|
||||||
Si vous migrez vers une nouvelle (1.0.0 ou plus récent) version de fichier et vous avez précédemment utilisé `entry.fullPath` comme arguments à `download()` ou `upload()` , alors vous aurez besoin de modifier votre code pour utiliser le système de fichiers URL au lieu de cela.
|
|
||||||
|
|
||||||
`FileEntry.toURL()`et `DirectoryEntry.toURL()` retournent une URL de système de fichiers du formulaire
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
qui peut être utilisé à la place le chemin d'accès absolu au fichier dans les deux `download()` et `upload()` méthodes.
|
|
|
@ -1,311 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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-file-transfer
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer)
|
|
||||||
|
|
||||||
Documentazione plugin: <doc/index.md>
|
|
||||||
|
|
||||||
Questo plugin permette di caricare e scaricare file.
|
|
||||||
|
|
||||||
Questo plugin definisce globale `FileTransfer`, costruttori di `FileUploadOptions`.
|
|
||||||
|
|
||||||
Anche se in ambito globale, non sono disponibili fino a dopo l'evento `deviceready`.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installazione
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Piattaforme supportate
|
|
||||||
|
|
||||||
* Amazon fuoco OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Browser
|
|
||||||
* Firefox OS**
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 e 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
\ * *Non supportano `onprogress` né `abort()` *
|
|
||||||
|
|
||||||
\ * * *Non supportano `onprogress` *
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
L'oggetto `FileTransfer` fornisce un modo per caricare i file utilizzando una richiesta HTTP multiparte POST o PUT e scaricare file pure.
|
|
||||||
|
|
||||||
## Proprietà
|
|
||||||
|
|
||||||
* **OnProgress**: chiamata con un `ProgressEvent` ogni volta che un nuovo blocco di dati viene trasferito. *(Funzione)*
|
|
||||||
|
|
||||||
## Metodi
|
|
||||||
|
|
||||||
* **caricare**: invia un file a un server.
|
|
||||||
|
|
||||||
* **Scarica**: Scarica un file dal server.
|
|
||||||
|
|
||||||
* **Abort**: interrompe un trasferimento in corso.
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
**Parametri**:
|
|
||||||
|
|
||||||
* **fileURL**: Filesystem URL che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto)
|
|
||||||
|
|
||||||
* **server**: URL del server per ricevere il file, come codificato dal`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: un callback che viene passato un oggetto `FileUploadResult`. *(Funzione)*
|
|
||||||
|
|
||||||
* **errorCallback**: un callback che viene eseguito se si verifica un errore di recupero `FileUploadResult`. Richiamato con un oggetto `FileTransferError`. *(Funzione)*
|
|
||||||
|
|
||||||
* **opzioni**: parametri facoltativi *(oggetto)*. Chiavi valide:
|
|
||||||
|
|
||||||
* **fileKey**: il nome dell'elemento form. Valore predefinito è `file` . (DOMString)
|
|
||||||
* **nome file**: il nome del file da utilizzare quando si salva il file sul server. Valore predefinito è `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: metodo HTTP da utilizzare - `PUT` o `POST`. Impostazioni predefinite per `POST`. (DOMString)
|
|
||||||
* **mimeType**: il tipo mime dei dati da caricare. Impostazioni predefinite su `image/jpeg`. (DOMString)
|
|
||||||
* **params**: un insieme di coppie chiave/valore opzionale per passare nella richiesta HTTP. (Object)
|
|
||||||
* **chunkedMode**: se a caricare i dati in modalità streaming chunked. Impostazione predefinita è `true`. (Boolean)
|
|
||||||
* **headers**: una mappa di valori di intestazione e nome dell'intestazione. Utilizzare una matrice per specificare più di un valore. Su iOS, FireOS e Android, se è presente, un'intestazione Content-Type il nome dati form multipart non verranno utilizzati. (Object)
|
|
||||||
* **httpMethod**: metodo HTTP da utilizzare per esempio POST o PUT. Il valore predefinito è `POST`. (DOMString)
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile poiché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)*
|
|
||||||
|
|
||||||
### Esempio
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Esempio con intestazioni di caricare ed eventi Progress (Android e iOS solo)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
Un oggetto `FileUploadResult` viene passato al metodo di callback del metodo `upload()` dell'oggetto `FileTransfer` successo.
|
|
||||||
|
|
||||||
### Proprietà
|
|
||||||
|
|
||||||
* **bytesSent**: il numero di byte inviati al server come parte dell'upload. (lungo)
|
|
||||||
|
|
||||||
* **responseCode**: codice di risposta HTTP restituito dal server. (lungo)
|
|
||||||
|
|
||||||
* **risposta**: risposta HTTP restituito dal server. (DOMString)
|
|
||||||
|
|
||||||
* **intestazioni**: intestazioni di risposta HTTP dal server. (Oggetto)
|
|
||||||
|
|
||||||
* Attualmente supportato solo iOS.
|
|
||||||
|
|
||||||
### iOS stranezze
|
|
||||||
|
|
||||||
* Non supporta `responseCode` o`bytesSent`.
|
|
||||||
|
|
||||||
## Scarica
|
|
||||||
|
|
||||||
**Parametri**:
|
|
||||||
|
|
||||||
* **fonte**: URL del server per scaricare il file, come codificato dal`encodeURI()`.
|
|
||||||
|
|
||||||
* **destinazione**: Filesystem url che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto)
|
|
||||||
|
|
||||||
* **successCallback**: un callback passato un `FileEntry` oggetto. *(Funzione)*
|
|
||||||
|
|
||||||
* **errorCallback**: un callback che viene eseguito se si verifica un errore durante il recupero `FileEntry`. Richiamato con un oggetto `FileTransferError`. *(Function)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile perché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)*
|
|
||||||
|
|
||||||
* **opzioni**: parametri facoltativi, attualmente solo supporti intestazioni (ad esempio autorizzazione (autenticazione di base), ecc.).
|
|
||||||
|
|
||||||
### Esempio
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
### WP8 stranezze
|
|
||||||
|
|
||||||
* Il download richiede è nella cache di implementazione nativa. Per evitare la memorizzazione nella cache, passare `if-Modified-Since` intestazione per metodo di download.
|
|
||||||
|
|
||||||
## Abort
|
|
||||||
|
|
||||||
Interrompe un trasferimento in corso. Il callback onerror viene passato un oggetto FileTransferError che presenta un codice di errore di FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Esempio
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
Un oggetto `FileTransferError` viene passato a un callback di errore quando si verifica un errore.
|
|
||||||
|
|
||||||
### Proprietà
|
|
||||||
|
|
||||||
* **codice**: uno dei codici di errore predefiniti elencati di seguito. (Numero)
|
|
||||||
|
|
||||||
* **fonte**: URL all'origine. (String)
|
|
||||||
|
|
||||||
* **destinazione**: URL di destinazione. (String)
|
|
||||||
|
|
||||||
* **http_status**: codice di stato HTTP. Questo attributo è disponibile solo quando viene ricevuto un codice di risposta della connessione HTTP. (Numero)
|
|
||||||
|
|
||||||
* **body** Corpo della risposta. Questo attributo è disponibile solo quando viene ricevuta una risposta dalla connessione HTTP. (String)
|
|
||||||
|
|
||||||
* **exception**: O e.getMessage o e.toString (String)
|
|
||||||
|
|
||||||
### Costanti
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Note di compatibilità all'indietro
|
|
||||||
|
|
||||||
Versioni precedenti di questo plugin accetterebbe solo dispositivo-assoluto-percorsi di file come origine per upload, o come destinazione per il download. Questi percorsi si sarebbero generalmente di forma
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Per indietro compatibilità, questi percorsi sono ancora accettati, e se l'applicazione ha registrato percorsi come questi in un archivio permanente, quindi possono continuare a essere utilizzato.
|
|
||||||
|
|
||||||
Questi percorsi sono stati precedentemente esposti nella proprietà `fullPath` di `FileEntry` e oggetti `DirectoryEntry` restituiti dal File plugin. Nuove versioni del File plugin, tuttavia, non è più espongono questi percorsi a JavaScript.
|
|
||||||
|
|
||||||
Se si esegue l'aggiornamento a una nuova (1.0.0 o più recente) versione del File e si hanno precedentemente utilizzato `entry.fullPath` come argomenti per `download()` o `upload()`, quindi sarà necessario cambiare il codice per utilizzare gli URL filesystem invece.
|
|
||||||
|
|
||||||
`FileEntry.toURL()` e `DirectoryEntry.toURL()` restituiscono un filesystem URL del modulo
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
che può essere utilizzato al posto del percorso assoluto nei metodi sia `download()` e `upload()`.
|
|
|
@ -1,302 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
Questo plugin permette di caricare e scaricare file.
|
|
||||||
|
|
||||||
Questo plugin definisce globale `FileTransfer`, costruttori di `FileUploadOptions`.
|
|
||||||
|
|
||||||
Anche se in ambito globale, non sono disponibili fino a dopo l'evento `deviceready`.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Installazione
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Piattaforme supportate
|
|
||||||
|
|
||||||
* Amazon fuoco OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Browser
|
|
||||||
* Firefox OS**
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 e 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
* *Supporto `onprogress` né `abort()`*
|
|
||||||
|
|
||||||
** *Non supportano `onprogress`*
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
L'oggetto `FileTransfer` fornisce un modo per caricare i file utilizzando una richiesta HTTP di POST più parte e scaricare file pure.
|
|
||||||
|
|
||||||
## Proprietà
|
|
||||||
|
|
||||||
* **OnProgress**: chiamata con un `ProgressEvent` ogni volta che un nuovo blocco di dati viene trasferito. *(Funzione)*
|
|
||||||
|
|
||||||
## Metodi
|
|
||||||
|
|
||||||
* **caricare**: invia un file a un server.
|
|
||||||
|
|
||||||
* **Scarica**: Scarica un file dal server.
|
|
||||||
|
|
||||||
* **Abort**: interrompe un trasferimento in corso.
|
|
||||||
|
|
||||||
## caricare
|
|
||||||
|
|
||||||
**Parametri**:
|
|
||||||
|
|
||||||
* **fileURL**: Filesystem URL che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto)
|
|
||||||
|
|
||||||
* **server**: URL del server per ricevere il file, come codificato dal`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: un callback che viene passato un oggetto `FileUploadResult`. *(Funzione)*
|
|
||||||
|
|
||||||
* **errorCallback**: un callback che viene eseguito se si verifica un errore di recupero `FileUploadResult`. Richiamato con un oggetto `FileTransferError`. *(Funzione)*
|
|
||||||
|
|
||||||
* **opzioni**: parametri facoltativi *(oggetto)*. Chiavi valide:
|
|
||||||
|
|
||||||
* **fileKey**: il nome dell'elemento form. Valore predefinito è `file` . (DOMString)
|
|
||||||
* **nome file**: il nome del file da utilizzare quando si salva il file sul server. Valore predefinito è `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: metodo HTTP da utilizzare - `PUT` o `POST`. Impostazioni predefinite per `POST`. (DOMString)
|
|
||||||
* **mimeType**: il tipo mime dei dati da caricare. Impostazioni predefinite su `image/jpeg`. (DOMString)
|
|
||||||
* **params**: un insieme di coppie chiave/valore opzionale per passare nella richiesta HTTP. (Object)
|
|
||||||
* **chunkedMode**: se a caricare i dati in modalità streaming chunked. Impostazione predefinita è `true`. (Boolean)
|
|
||||||
* **headers**: mappa di valori nome/intestazione intestazione. Utilizzare una matrice per specificare più valori. (Object)
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile poiché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)*
|
|
||||||
|
|
||||||
### Esempio
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Esempio con intestazioni di caricare ed eventi Progress (Android e iOS solo)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
Un oggetto `FileUploadResult` viene passato al metodo di callback del metodo `upload()` dell'oggetto `FileTransfer` successo.
|
|
||||||
|
|
||||||
### Proprietà
|
|
||||||
|
|
||||||
* **bytesSent**: il numero di byte inviati al server come parte dell'upload. (lungo)
|
|
||||||
|
|
||||||
* **responseCode**: codice di risposta HTTP restituito dal server. (lungo)
|
|
||||||
|
|
||||||
* **risposta**: risposta HTTP restituito dal server. (DOMString)
|
|
||||||
|
|
||||||
* **intestazioni**: intestazioni di risposta HTTP dal server. (Oggetto)
|
|
||||||
|
|
||||||
* Attualmente supportato solo iOS.
|
|
||||||
|
|
||||||
### iOS stranezze
|
|
||||||
|
|
||||||
* Non supporta `responseCode` o`bytesSent`.
|
|
||||||
|
|
||||||
## Scarica
|
|
||||||
|
|
||||||
**Parametri**:
|
|
||||||
|
|
||||||
* **fonte**: URL del server per scaricare il file, come codificato dal`encodeURI()`.
|
|
||||||
|
|
||||||
* **destinazione**: Filesystem url che rappresenta il file nel dispositivo. Per indietro la compatibilità, questo può anche essere il percorso completo del file sul dispositivo. (Vedere [indietro compatibilità rileva] qui sotto)
|
|
||||||
|
|
||||||
* **successCallback**: un callback passato un `FileEntry` oggetto. *(Funzione)*
|
|
||||||
|
|
||||||
* **errorCallback**: un callback che viene eseguito se si verifica un errore durante il recupero `FileEntry`. Richiamato con un oggetto `FileTransferError`. *(Function)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametro opzionale, valore predefinito è `false` . Se impostata su `true` , accetta tutti i certificati di sicurezza. Questo è utile perché Android respinge i certificati autofirmati sicurezza. Non raccomandato per uso in produzione. Supportato su Android e iOS. *(boolean)*
|
|
||||||
|
|
||||||
* **opzioni**: parametri facoltativi, attualmente solo supporti intestazioni (ad esempio autorizzazione (autenticazione di base), ecc.).
|
|
||||||
|
|
||||||
### Esempio
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## Abort
|
|
||||||
|
|
||||||
Interrompe un trasferimento in corso. Il callback onerror viene passato un oggetto FileTransferError che presenta un codice di errore di FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Esempio
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
Un oggetto `FileTransferError` viene passato a un callback di errore quando si verifica un errore.
|
|
||||||
|
|
||||||
### Proprietà
|
|
||||||
|
|
||||||
* **codice**: uno dei codici di errore predefiniti elencati di seguito. (Numero)
|
|
||||||
|
|
||||||
* **fonte**: URL all'origine. (String)
|
|
||||||
|
|
||||||
* **destinazione**: URL di destinazione. (String)
|
|
||||||
|
|
||||||
* **http_status**: codice di stato HTTP. Questo attributo è disponibile solo quando viene ricevuto un codice di risposta della connessione HTTP. (Numero)
|
|
||||||
|
|
||||||
* **body** Corpo della risposta. Questo attributo è disponibile solo quando viene ricevuta una risposta dalla connessione HTTP. (String)
|
|
||||||
|
|
||||||
* **exception**: O e.getMessage o e.toString (String)
|
|
||||||
|
|
||||||
### Costanti
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Note di compatibilità all'indietro
|
|
||||||
|
|
||||||
Versioni precedenti di questo plugin accetterebbe solo dispositivo-assoluto-percorsi di file come origine per upload, o come destinazione per il download. Questi percorsi si sarebbero generalmente di forma
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Per indietro compatibilità, questi percorsi sono ancora accettati, e se l'applicazione ha registrato percorsi come questi in un archivio permanente, quindi possono continuare a essere utilizzato.
|
|
||||||
|
|
||||||
Questi percorsi sono stati precedentemente esposti nella proprietà `fullPath` di `FileEntry` e oggetti `DirectoryEntry` restituiti dal File plugin. Nuove versioni del File plugin, tuttavia, non è più espongono questi percorsi a JavaScript.
|
|
||||||
|
|
||||||
Se si esegue l'aggiornamento a una nuova (1.0.0 o più recente) versione del File e si hanno precedentemente utilizzato `entry.fullPath` come argomenti per `download()` o `upload()`, quindi sarà necessario cambiare il codice per utilizzare gli URL filesystem invece.
|
|
||||||
|
|
||||||
`FileEntry.toURL()` e `DirectoryEntry.toURL()` restituiscono un filesystem URL del modulo
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
che può essere utilizzato al posto del percorso assoluto nei metodi sia `download()` e `upload()`.
|
|
|
@ -1,311 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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-file-transfer
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer)
|
|
||||||
|
|
||||||
プラグインのマニュアル: <doc/index.md>
|
|
||||||
|
|
||||||
このプラグインは、アップロードし、ファイルをダウンロードすることができます。
|
|
||||||
|
|
||||||
このプラグインでは、グローバル `FileTransfer`、`FileUploadOptions` コンス トラクターを定義します。
|
|
||||||
|
|
||||||
グローバル スコープでは使用できませんまで `deviceready` イベントの後です。
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## インストール
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## サポートされているプラットフォーム
|
|
||||||
|
|
||||||
* アマゾン火 OS
|
|
||||||
* アンドロイド
|
|
||||||
* ブラックベリー 10
|
|
||||||
* ブラウザー
|
|
||||||
* Firefox の OS * *
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 と 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
\ * * `Onprogress`も`abort()`をサポートしていません。*
|
|
||||||
|
|
||||||
\ * * * `Onprogress`をサポートしていません。*
|
|
||||||
|
|
||||||
# 出色
|
|
||||||
|
|
||||||
`出色`オブジェクトは、HTTP マルチパート POST または PUT 要求を使用してファイルをアップロードし、同様にファイルをダウンロードする方法を提供します。
|
|
||||||
|
|
||||||
## プロパティ
|
|
||||||
|
|
||||||
* **onprogress**: と呼ばれる、 `ProgressEvent` データの新しいチャンクが転送されるたびに。*(機能)*
|
|
||||||
|
|
||||||
## メソッド
|
|
||||||
|
|
||||||
* **アップロード**: サーバーにファイルを送信します。
|
|
||||||
|
|
||||||
* **ダウンロード**: サーバーからファイルをダウンロードします。
|
|
||||||
|
|
||||||
* **中止**: 進行中の転送を中止します。
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
**パラメーター**:
|
|
||||||
|
|
||||||
* **fileURL**: デバイス上のファイルを表すファイルシステム URL。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下)
|
|
||||||
|
|
||||||
* **サーバー**: によって符号化されるように、ファイルを受信するサーバーの URL`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: `FileUploadResult` オブジェクトが渡されるコールバック。*(機能)*
|
|
||||||
|
|
||||||
* **errorCallback**: エラー `FileUploadResult` を取得するが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)*
|
|
||||||
|
|
||||||
* **オプション**: 省略可能なパラメーター *(オブジェクト)*。有効なキー:
|
|
||||||
|
|
||||||
* **fileKey**: フォーム要素の名前。既定値は `file` です。(,)
|
|
||||||
* **ファイル名**: ファイル名、サーバー上のファイルを保存するときに使用します。既定値は `image.jpg` です。(,)
|
|
||||||
* **httpMethod**: - `を置く` または `POST` のいずれかを使用する HTTP メソッド。デフォルト `のポスト` です。(,)
|
|
||||||
* **mimeType**: アップロードするデータの mime タイプ。`イメージ/jpeg` のデフォルトです。(,)
|
|
||||||
* **params**: HTTP リクエストに渡すために任意のキー/値ペアのセット。(オブジェクト)
|
|
||||||
* **chunkedMode**: チャンク ストリーミング モードでデータをアップロードするかどうか。デフォルトは `true` です。(ブール値)
|
|
||||||
* **headers**: ヘッダー名/ヘッダー値のマップ。 配列を使用して、1 つ以上の値を指定します。 IOS、FireOS、アンドロイドではという名前のコンテンツ タイプ ヘッダーが存在する場合、マルチパート フォーム データは使用されません。 (Object)
|
|
||||||
* **httpMethod**: 例えばを使用する HTTP メソッドを POST または PUT です。 デフォルト`のポスト`です。(DOMString)
|
|
||||||
|
|
||||||
* **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 これは Android の自己署名入りセキュリティ証明書を拒否するので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)*
|
|
||||||
|
|
||||||
### 例
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### サンプルのアップロード ヘッダーと進行状況のイベント (Android と iOS のみ)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
`FileUploadResult` オブジェクトは `FileTransfer` オブジェクト `upload()` メソッドの成功時のコールバックに渡されます。
|
|
||||||
|
|
||||||
### プロパティ
|
|
||||||
|
|
||||||
* **bytesSent**: アップロードの一部としてサーバーに送信されたバイト数。(ロング)
|
|
||||||
|
|
||||||
* **記述**: サーバーによって返される HTTP 応答コード。(ロング)
|
|
||||||
|
|
||||||
* **応答**: サーバーによって返される HTTP 応答。(,)
|
|
||||||
|
|
||||||
* **ヘッダー**: HTTP 応答ヘッダー サーバーによって。(オブジェクト)
|
|
||||||
|
|
||||||
* 現在 iOS のみでサポートされます。
|
|
||||||
|
|
||||||
### iOS の癖
|
|
||||||
|
|
||||||
* サポートしていない `responseCode` または`bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**パラメーター**:
|
|
||||||
|
|
||||||
* **ソース**: によって符号化されるように、ファイルをダウンロードするサーバーの URL`encodeURI()`.
|
|
||||||
|
|
||||||
* **ターゲット**: デバイス上のファイルを表すファイルシステム url。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下)
|
|
||||||
|
|
||||||
* **successCallback**: 渡されたコールバックを `FileEntry` オブジェクト。*(機能)*
|
|
||||||
|
|
||||||
* **errorCallback**: `FileEntry` を取得するときにエラーが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 Android は、自己署名入りセキュリティ証明書を拒否しますので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)*
|
|
||||||
|
|
||||||
* **オプション**: 省略可能なパラメーターは、現在サポートするヘッダーのみ (認証 (基本認証) など)。
|
|
||||||
|
|
||||||
### 例
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
### WP8 癖
|
|
||||||
|
|
||||||
* ダウンロード要求するネイティブ実装によってキャッシュに格納されています。キャッシュされないように、渡す`以来変更された if`ヘッダー メソッドをダウンロードします。
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
進行中の転送を中止します。Onerror コールバックが FileTransferError.ABORT_ERR のエラー コードを持っている FileTransferError オブジェクトに渡されます。
|
|
||||||
|
|
||||||
### 例
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
`FileTransferError` オブジェクトは、エラーが発生したときにエラー コールバックに渡されます。
|
|
||||||
|
|
||||||
### プロパティ
|
|
||||||
|
|
||||||
* **コード**: 次のいずれかの定義済みのエラー コード。(数)
|
|
||||||
|
|
||||||
* **ソース**: ソースの URL。(文字列)
|
|
||||||
|
|
||||||
* **ターゲット**: 先の URL。(文字列)
|
|
||||||
|
|
||||||
* **http_status**: HTTP ステータス コード。この属性は、HTTP 接続から応答コードを受信したときにのみ使用できます。(数)
|
|
||||||
|
|
||||||
* **body**応答本体。この属性は、HTTP 接続から応答を受信したときにのみ使用できます。(文字列)
|
|
||||||
|
|
||||||
* **exception**: どちらか e.getMessage または e.toString (文字列)
|
|
||||||
|
|
||||||
### 定数
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## 後方互換性をノートします。
|
|
||||||
|
|
||||||
このプラグインの以前のバージョンまたはダウンロードのターゲットとして、アップロードのソースとしてのみデバイス絶対ファイル パスを受け入れるでしょう。これらのパスの形式は、通常
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
下位互換性、これらのパスを使用しても、アプリケーションは、永続的なストレージでこのようなパスを記録している場合、し彼らが引き続き使用されます。
|
|
||||||
|
|
||||||
これらのパスの `FileEntry` やファイル プラグインによって返される `DirectoryEntry` オブジェクトの `fullPath` プロパティで公開されていなかった。 新しいプラグインのバージョン、ファイル、ただし、もはや java スクリプトの設定をこれらのパスを公開します。
|
|
||||||
|
|
||||||
新しいにアップグレードする場合 (1.0.0 以降) ファイルのバージョン以前を使用している `entry.fullPath` `download()` または `upload()` への引数として、ファイルシステムの Url を代わりに使用するコードを変更する必要があります。
|
|
||||||
|
|
||||||
`FileEntry.toURL()` と `DirectoryEntry.toURL()` ファイルシステムの URL を返すフォーム
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
`download()`、`upload()` メソッドの絶対ファイル パスの代わりに使用できます。
|
|
|
@ -1,302 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
このプラグインは、アップロードし、ファイルをダウンロードすることができます。
|
|
||||||
|
|
||||||
このプラグインでは、グローバル `FileTransfer`、`FileUploadOptions` コンス トラクターを定義します。
|
|
||||||
|
|
||||||
グローバル スコープでは使用できませんまで `deviceready` イベントの後です。
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## インストール
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## サポートされているプラットフォーム
|
|
||||||
|
|
||||||
* アマゾン火 OS
|
|
||||||
* アンドロイド
|
|
||||||
* ブラックベリー 10
|
|
||||||
* ブラウザー
|
|
||||||
* Firefox の OS * *
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 と 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
* *`onprogress` も `abort()` をサポートしていません*
|
|
||||||
|
|
||||||
* * *`onprogress` をサポートしていません*
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
`FileTransfer` オブジェクトはマルチパートのポスト、HTTP 要求を使用してファイルをアップロードして同様にファイルをダウンロードする方法を提供します。
|
|
||||||
|
|
||||||
## プロパティ
|
|
||||||
|
|
||||||
* **onprogress**: と呼ばれる、 `ProgressEvent` データの新しいチャンクが転送されるたびに。*(機能)*
|
|
||||||
|
|
||||||
## メソッド
|
|
||||||
|
|
||||||
* **アップロード**: サーバーにファイルを送信します。
|
|
||||||
|
|
||||||
* **ダウンロード**: サーバーからファイルをダウンロードします。
|
|
||||||
|
|
||||||
* **中止**: 進行中の転送を中止します。
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
**パラメーター**:
|
|
||||||
|
|
||||||
* **fileURL**: デバイス上のファイルを表すファイルシステム URL。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下)
|
|
||||||
|
|
||||||
* **サーバー**: によって符号化されるように、ファイルを受信するサーバーの URL`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: `FileUploadResult` オブジェクトが渡されるコールバック。*(機能)*
|
|
||||||
|
|
||||||
* **errorCallback**: エラー `FileUploadResult` を取得するが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)*
|
|
||||||
|
|
||||||
* **オプション**: 省略可能なパラメーター *(オブジェクト)*。有効なキー:
|
|
||||||
|
|
||||||
* **fileKey**: フォーム要素の名前。既定値は `file` です。(,)
|
|
||||||
* **ファイル名**: ファイル名、サーバー上のファイルを保存するときに使用します。既定値は `image.jpg` です。(,)
|
|
||||||
* **httpMethod**: - `を置く` または `POST` のいずれかを使用する HTTP メソッド。デフォルト `のポスト` です。(,)
|
|
||||||
* **mimeType**: アップロードするデータの mime タイプ。`イメージ/jpeg` のデフォルトです。(,)
|
|
||||||
* **params**: HTTP リクエストに渡すために任意のキー/値ペアのセット。(オブジェクト)
|
|
||||||
* **chunkedMode**: チャンク ストリーミング モードでデータをアップロードするかどうか。デフォルトは `true` です。(ブール値)
|
|
||||||
* **headers**: ヘッダーの名前/ヘッダー値のマップ。1 つ以上の値を指定するには、配列を使用します。(オブジェクト)
|
|
||||||
|
|
||||||
* **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 これは Android の自己署名入りセキュリティ証明書を拒否するので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)*
|
|
||||||
|
|
||||||
### 例
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### サンプルのアップロード ヘッダーと進行状況のイベント (Android と iOS のみ)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
`FileUploadResult` オブジェクトは `FileTransfer` オブジェクト `upload()` メソッドの成功時のコールバックに渡されます。
|
|
||||||
|
|
||||||
### プロパティ
|
|
||||||
|
|
||||||
* **bytesSent**: アップロードの一部としてサーバーに送信されたバイト数。(ロング)
|
|
||||||
|
|
||||||
* **記述**: サーバーによって返される HTTP 応答コード。(ロング)
|
|
||||||
|
|
||||||
* **応答**: サーバーによって返される HTTP 応答。(,)
|
|
||||||
|
|
||||||
* **ヘッダー**: HTTP 応答ヘッダー サーバーによって。(オブジェクト)
|
|
||||||
|
|
||||||
* 現在 iOS のみでサポートされます。
|
|
||||||
|
|
||||||
### iOS の癖
|
|
||||||
|
|
||||||
* サポートしていない `responseCode` または`bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**パラメーター**:
|
|
||||||
|
|
||||||
* **ソース**: によって符号化されるように、ファイルをダウンロードするサーバーの URL`encodeURI()`.
|
|
||||||
|
|
||||||
* **ターゲット**: デバイス上のファイルを表すファイルシステム url。 下位互換性は、このことも、デバイス上のファイルの完全パスであります。 (参照してください [後方互換性メモ] の下)
|
|
||||||
|
|
||||||
* **successCallback**: 渡されたコールバックを `FileEntry` オブジェクト。*(機能)*
|
|
||||||
|
|
||||||
* **errorCallback**: `FileEntry` を取得するときにエラーが発生した場合に実行されるコールバック。`FileTransferError` オブジェクトを使って呼び出されます。*(機能)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: 省略可能なパラメーターは、デフォルト `false` 。 場合設定 `true` 、セキュリティ証明書をすべて受け付けます。 Android は、自己署名入りセキュリティ証明書を拒否しますので便利です。 運用環境で使用しないでください。 Android と iOS でサポートされています。 *(ブール値)*
|
|
||||||
|
|
||||||
* **オプション**: 省略可能なパラメーターは、現在サポートするヘッダーのみ (認証 (基本認証) など)。
|
|
||||||
|
|
||||||
### 例
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
進行中の転送を中止します。Onerror コールバックが FileTransferError.ABORT_ERR のエラー コードを持っている FileTransferError オブジェクトに渡されます。
|
|
||||||
|
|
||||||
### 例
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
`FileTransferError` オブジェクトは、エラーが発生したときにエラー コールバックに渡されます。
|
|
||||||
|
|
||||||
### プロパティ
|
|
||||||
|
|
||||||
* **コード**: 次のいずれかの定義済みのエラー コード。(数)
|
|
||||||
|
|
||||||
* **ソース**: ソースの URL。(文字列)
|
|
||||||
|
|
||||||
* **ターゲット**: 先の URL。(文字列)
|
|
||||||
|
|
||||||
* **http_status**: HTTP ステータス コード。この属性は、HTTP 接続から応答コードを受信したときにのみ使用できます。(数)
|
|
||||||
|
|
||||||
* **body**応答本体。この属性は、HTTP 接続から応答を受信したときにのみ使用できます。(文字列)
|
|
||||||
|
|
||||||
* **exception**: どちらか e.getMessage または e.toString (文字列)
|
|
||||||
|
|
||||||
### 定数
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## 後方互換性をノートします。
|
|
||||||
|
|
||||||
このプラグインの以前のバージョンまたはダウンロードのターゲットとして、アップロードのソースとしてのみデバイス絶対ファイル パスを受け入れるでしょう。これらのパスの形式は、通常
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
下位互換性、これらのパスを使用しても、アプリケーションは、永続的なストレージでこのようなパスを記録している場合、し彼らが引き続き使用されます。
|
|
||||||
|
|
||||||
これらのパスの `FileEntry` やファイル プラグインによって返される `DirectoryEntry` オブジェクトの `fullPath` プロパティで公開されていなかった。 新しいプラグインのバージョン、ファイル、ただし、もはや java スクリプトの設定をこれらのパスを公開します。
|
|
||||||
|
|
||||||
新しいにアップグレードする場合 (1.0.0 以降) ファイルのバージョン以前を使用している `entry.fullPath` `download()` または `upload()` への引数として、ファイルシステムの Url を代わりに使用するコードを変更する必要があります。
|
|
||||||
|
|
||||||
`FileEntry.toURL()` と `DirectoryEntry.toURL()` ファイルシステムの URL を返すフォーム
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
`download()`、`upload()` メソッドの絶対ファイル パスの代わりに使用できます。
|
|
|
@ -1,311 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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-file-transfer
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer)
|
|
||||||
|
|
||||||
플러그인 문서: <doc/index.md>
|
|
||||||
|
|
||||||
이 플러그인을 사용 하면 업로드 및 다운로드 파일 수 있습니다.
|
|
||||||
|
|
||||||
이 플러그인 글로벌 `FileTransfer`, `FileUploadOptions` 생성자를 정의합니다.
|
|
||||||
|
|
||||||
전역 범위에서 그들은 제공 되지 않습니다 때까지 `deviceready` 이벤트 후.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## 설치
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## 지원 되는 플랫폼
|
|
||||||
|
|
||||||
* 아마존 화재 운영 체제
|
|
||||||
* 안 드 로이드
|
|
||||||
* 블랙베리 10
|
|
||||||
* 브라우저
|
|
||||||
* 파이어 폭스 OS * *
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7과 8 *
|
|
||||||
* 윈도우 8
|
|
||||||
* 윈도우
|
|
||||||
|
|
||||||
\** `Onprogress` 도 `abort()` 를 지원 하지 않습니다*
|
|
||||||
|
|
||||||
\*** `Onprogress` 를 지원 하지 않습니다*
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
`FileTransfer` 개체는 HTTP 다중 파트 POST 또는 PUT 요청을 사용 하 여 파일을 업로드 하 고 또한 파일을 다운로드 하는 방법을 제공 합니다.
|
|
||||||
|
|
||||||
## 속성
|
|
||||||
|
|
||||||
* **onprogress**:로 불리는 `ProgressEvent` 새로운 양의 데이터를 전송 하는 때마다. *(기능)*
|
|
||||||
|
|
||||||
## 메서드
|
|
||||||
|
|
||||||
* **업로드**: 파일을 서버에 보냅니다.
|
|
||||||
|
|
||||||
* **다운로드**: 서버에서 파일을 다운로드 합니다.
|
|
||||||
|
|
||||||
* **중단**: 진행 중인 전송 중단.
|
|
||||||
|
|
||||||
## 업로드
|
|
||||||
|
|
||||||
**매개 변수**:
|
|
||||||
|
|
||||||
* **fileURL**: 장치에 파일을 나타내는 파일 시스템 URL. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래)
|
|
||||||
|
|
||||||
* **서버**: 인코딩 파일 수신 서버의 URL`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: `FileUploadResult` 개체를 전달 하는 콜백. *(기능)*
|
|
||||||
|
|
||||||
* **errorCallback**: `FileUploadResult` 검색에 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)*
|
|
||||||
|
|
||||||
* **옵션**: 선택적 매개 변수 *(개체)*. 유효한 키:
|
|
||||||
|
|
||||||
* **fileKey**: form 요소의 이름. 기본값은 `file` . (DOMString)
|
|
||||||
* **파일 이름**: 파일 이름을 서버에 파일을 저장할 때 사용 합니다. 기본값은 `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: `넣어` 또는 `게시물`-사용 하도록 HTTP 메서드. `게시물` 기본값입니다. (DOMString)
|
|
||||||
* **mimeType**: 업로드 데이터의 mime 형식을. `이미지/jpeg`의 기본값입니다. (DOMString)
|
|
||||||
* **params**: HTTP 요청에 전달할 선택적 키/값 쌍의 집합. (개체)
|
|
||||||
* **chunkedMode**: 청크 스트리밍 모드에서 데이터 업로드를 합니다. 기본값은 `true`입니다. (부울)
|
|
||||||
* **headers**: 헤더 이름 및 헤더 값의 지도. 배열을 사용 하 여 하나 이상의 값을 지정. IOS, FireOS, 안 드 로이드에 있으면 라는 콘텐츠 형식 헤더, 다중 양식 데이터는 사용할 수 없습니다. (Object)
|
|
||||||
* **httpMethod**: HTTP 메서드 예를 사용 하 여 게시 하거나 넣어. `게시물`기본값입니다. (DOMString)
|
|
||||||
|
|
||||||
* **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 이 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)*
|
|
||||||
|
|
||||||
### 예를 들어
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### 예를 들어 헤더 업로드 및 진행 이벤트 (안 드 로이드와 iOS만)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
`FileUploadResult` 개체 `FileTransfer` 개체의 `원래` 방법의 성공 콜백에 전달 됩니다.
|
|
||||||
|
|
||||||
### 속성
|
|
||||||
|
|
||||||
* **bytesSent**: 업로드의 일부로 서버에 보낸 바이트 수. (긴)
|
|
||||||
|
|
||||||
* **responseCode**: 서버에서 반환 된 HTTP 응답 코드. (긴)
|
|
||||||
|
|
||||||
* **response**: 서버에서 반환 되는 HTTP 응답. (DOMString)
|
|
||||||
|
|
||||||
* **headers**: 서버에서 HTTP 응답 헤더. (개체)
|
|
||||||
|
|
||||||
* 현재 ios만 지원 합니다.
|
|
||||||
|
|
||||||
### iOS 단점
|
|
||||||
|
|
||||||
* 지원 하지 않는 `responseCode` 또는`bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**매개 변수**:
|
|
||||||
|
|
||||||
* **source**: URL로 인코딩된 파일, 다운로드 서버`encodeURI()`.
|
|
||||||
|
|
||||||
* **target**: 장치에 파일을 나타내는 파일 시스템 url. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래)
|
|
||||||
|
|
||||||
* **successCallback**: 콜백 전달 되는 `FileEntry` 개체. *(기능)*
|
|
||||||
|
|
||||||
* **errorCallback**: `FileEntry`를 검색할 때 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)*
|
|
||||||
|
|
||||||
* **options**: 선택적 매개 변수를 현재 지 원하는 머리글만 (예: 인증 (기본 인증), 등).
|
|
||||||
|
|
||||||
### 예를 들어
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
### WP8 특수
|
|
||||||
|
|
||||||
* 다운로드 요청 기본 구현에 의해 캐시 되 고. 캐싱을 방지 하려면 전달 `if-수정-이후` 헤더를 다운로드 하는 방법.
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
진행 중인 전송을 중단합니다. onerror 콜백 FileTransferError.ABORT_ERR의 오류 코드는 FileTransferError 개체를 전달 합니다.
|
|
||||||
|
|
||||||
### 예를 들어
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
`FileTransferError` 개체 오류가 발생 하면 오류 콜백에 전달 됩니다.
|
|
||||||
|
|
||||||
### 속성
|
|
||||||
|
|
||||||
* **code**: 미리 정의 된 오류 코드 중 하나가 아래에 나열 된. (수)
|
|
||||||
|
|
||||||
* **source**: 소스 URL. (문자열)
|
|
||||||
|
|
||||||
* **target**: 대상 URL. (문자열)
|
|
||||||
|
|
||||||
* **http_status**: HTTP 상태 코드. 이 특성은 응답 코드를 HTTP 연결에서 수신에 사용할 수 있습니다. (수)
|
|
||||||
|
|
||||||
* **body** 응답 본문입니다. 이 특성은 HTTP 연결에서 응답을 받을 때에 사용할 수 있습니다. (문자열)
|
|
||||||
|
|
||||||
* **exception**: 어느 e.getMessage 또는 e.toString (문자열)
|
|
||||||
|
|
||||||
### 상수
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## 이전 버전과 호환성 노트
|
|
||||||
|
|
||||||
이 플러그인의 이전 버전만 업로드에 대 한 소스 또는 다운로드에 대 한 대상 장치 절대 파일 경로 받아들일 것 이다. 이러한 경로 일반적으로 폼의 것
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
대 한 뒤 호환성, 이러한 경로 여전히 허용, 그리고 응용 프로그램이 영구 저장소에서 이와 같은 경로 기록 했다, 그때 그들은 계속할 수 있다면 사용할 수.
|
|
||||||
|
|
||||||
이러한 경로 `FileEntry` 및 파일 플러그인에 의해 반환 된 `DirectoryEntry` 개체의 `fullPath` 속성에 노출 되었던. 그러나 파일 플러그인의,, 더 이상 새로운 버전 자바 스크립트이 경로 노출.
|
|
||||||
|
|
||||||
새로 업그레이드 하는 경우 (1.0.0 이상) 버전의 파일, 및 이전 사용 하 고 `entry.fullPath` `download()` 또는 `upload()` 인수로 다음 대신 파일 시스템 Url을 사용 하 여 코드를 변경 해야 합니다.
|
|
||||||
|
|
||||||
폼의 파일 URL을 반환 하는 `FileEntry.toURL()` 및 `DirectoryEntry.toURL()`
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
어떤 `download()` 및 `upload()` 방법에서 절대 파일 경로 대신 사용할 수 있습니다.
|
|
|
@ -1,302 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
이 플러그인을 사용 하면 업로드 및 다운로드 파일 수 있습니다.
|
|
||||||
|
|
||||||
이 플러그인 글로벌 `FileTransfer`, `FileUploadOptions` 생성자를 정의합니다.
|
|
||||||
|
|
||||||
전역 범위에서 그들은 제공 되지 않습니다 때까지 `deviceready` 이벤트 후.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## 설치
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## 지원 되는 플랫폼
|
|
||||||
|
|
||||||
* 아마존 화재 운영 체제
|
|
||||||
* 안 드 로이드
|
|
||||||
* 블랙베리 10
|
|
||||||
* 브라우저
|
|
||||||
* 파이어 폭스 OS * *
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7과 8 *
|
|
||||||
* 윈도우 8
|
|
||||||
* 윈도우
|
|
||||||
|
|
||||||
* *`onprogress`도 `abort()`를 지원 하지 않습니다*
|
|
||||||
|
|
||||||
* * *`onprogress`를 지원 하지 않습니다*
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
`FileTransfer` 개체는 HTTP 다중 파트 POST 요청을 사용 하 여 파일 업로드 뿐만 아니라 파일을 다운로드 하는 방법을 제공 합니다.
|
|
||||||
|
|
||||||
## 속성
|
|
||||||
|
|
||||||
* **onprogress**:로 불리는 `ProgressEvent` 새로운 양의 데이터를 전송 하는 때마다. *(기능)*
|
|
||||||
|
|
||||||
## 메서드
|
|
||||||
|
|
||||||
* **업로드**: 파일을 서버에 보냅니다.
|
|
||||||
|
|
||||||
* **다운로드**: 서버에서 파일을 다운로드 합니다.
|
|
||||||
|
|
||||||
* **중단**: 진행 중인 전송 중단.
|
|
||||||
|
|
||||||
## 업로드
|
|
||||||
|
|
||||||
**매개 변수**:
|
|
||||||
|
|
||||||
* **fileURL**: 장치에 파일을 나타내는 파일 시스템 URL. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래)
|
|
||||||
|
|
||||||
* **서버**: 인코딩 파일 수신 서버의 URL`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: `FileUploadResult` 개체를 전달 하는 콜백. *(기능)*
|
|
||||||
|
|
||||||
* **errorCallback**: `FileUploadResult` 검색에 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)*
|
|
||||||
|
|
||||||
* **옵션**: 선택적 매개 변수 *(개체)*. 유효한 키:
|
|
||||||
|
|
||||||
* **fileKey**: form 요소의 이름. 기본값은 `file` . (DOMString)
|
|
||||||
* **파일 이름**: 파일 이름을 서버에 파일을 저장할 때 사용 합니다. 기본값은 `image.jpg` . (DOMString)
|
|
||||||
* **httpMethod**: `넣어` 또는 `게시물`-사용 하도록 HTTP 메서드. `게시물` 기본값입니다. (DOMString)
|
|
||||||
* **mimeType**: 업로드 데이터의 mime 형식을. `이미지/jpeg`의 기본값입니다. (DOMString)
|
|
||||||
* **params**: HTTP 요청에 전달할 선택적 키/값 쌍의 집합. (개체)
|
|
||||||
* **chunkedMode**: 청크 스트리밍 모드에서 데이터 업로드를 합니다. 기본값은 `true`입니다. (부울)
|
|
||||||
* **headers**: 헤더 이름/헤더 값의 지도. 배열을 사용 하 여 하나 이상의 값을 지정 합니다. (개체)
|
|
||||||
|
|
||||||
* **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 이 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)*
|
|
||||||
|
|
||||||
### 예를 들어
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### 예를 들어 헤더 업로드 및 진행 이벤트 (안 드 로이드와 iOS만)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
`FileUploadResult` 개체 `FileTransfer` 개체의 `원래` 방법의 성공 콜백에 전달 됩니다.
|
|
||||||
|
|
||||||
### 속성
|
|
||||||
|
|
||||||
* **bytesSent**: 업로드의 일부로 서버에 보낸 바이트 수. (긴)
|
|
||||||
|
|
||||||
* **responseCode**: 서버에서 반환 된 HTTP 응답 코드. (긴)
|
|
||||||
|
|
||||||
* **response**: 서버에서 반환 되는 HTTP 응답. (DOMString)
|
|
||||||
|
|
||||||
* **headers**: 서버에서 HTTP 응답 헤더. (개체)
|
|
||||||
|
|
||||||
* 현재 ios만 지원 합니다.
|
|
||||||
|
|
||||||
### iOS 단점
|
|
||||||
|
|
||||||
* 지원 하지 않는 `responseCode` 또는`bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**매개 변수**:
|
|
||||||
|
|
||||||
* **source**: URL로 인코딩된 파일, 다운로드 서버`encodeURI()`.
|
|
||||||
|
|
||||||
* **target**: 장치에 파일을 나타내는 파일 시스템 url. 에 대 한 이전 버전과 호환성을이 수도 장치에 있는 파일의 전체 경로 수. (참조 [거꾸로 호환성 노트] 아래)
|
|
||||||
|
|
||||||
* **successCallback**: 콜백 전달 되는 `FileEntry` 개체. *(기능)*
|
|
||||||
|
|
||||||
* **errorCallback**: `FileEntry`를 검색할 때 오류가 발생 하면 실행 되는 콜백. `FileTransferError` 개체와 함께 호출 됩니다. *(기능)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: 선택적 매개 변수는 기본적으로 `false` . 만약 설정 `true` , 그것은 모든 보안 인증서를 허용 합니다. 안 드 로이드 자체 서명 된 보안 인증서를 거부 하기 때문에 유용 합니다. 프로덕션 환경에서 사용 권장 되지 않습니다. 안 드 로이드와 iOS에서 지원. *(부울)*
|
|
||||||
|
|
||||||
* **options**: 선택적 매개 변수를 현재 지 원하는 머리글만 (예: 인증 (기본 인증), 등).
|
|
||||||
|
|
||||||
### 예를 들어
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
진행 중인 전송을 중단합니다. onerror 콜백 FileTransferError.ABORT_ERR의 오류 코드는 FileTransferError 개체를 전달 합니다.
|
|
||||||
|
|
||||||
### 예를 들어
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
`FileTransferError` 개체 오류가 발생 하면 오류 콜백에 전달 됩니다.
|
|
||||||
|
|
||||||
### 속성
|
|
||||||
|
|
||||||
* **code**: 미리 정의 된 오류 코드 중 하나가 아래에 나열 된. (수)
|
|
||||||
|
|
||||||
* **source**: 소스 URL. (문자열)
|
|
||||||
|
|
||||||
* **target**: 대상 URL. (문자열)
|
|
||||||
|
|
||||||
* **http_status**: HTTP 상태 코드. 이 특성은 응답 코드를 HTTP 연결에서 수신에 사용할 수 있습니다. (수)
|
|
||||||
|
|
||||||
* **body** 응답 본문입니다. 이 특성은 HTTP 연결에서 응답을 받을 때에 사용할 수 있습니다. (문자열)
|
|
||||||
|
|
||||||
* **exception**: 어느 e.getMessage 또는 e.toString (문자열)
|
|
||||||
|
|
||||||
### 상수
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## 이전 버전과 호환성 노트
|
|
||||||
|
|
||||||
이 플러그인의 이전 버전만 업로드에 대 한 소스 또는 다운로드에 대 한 대상 장치 절대 파일 경로 받아들일 것 이다. 이러한 경로 일반적으로 폼의 것
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
대 한 뒤 호환성, 이러한 경로 여전히 허용, 그리고 응용 프로그램이 영구 저장소에서 이와 같은 경로 기록 했다, 그때 그들은 계속할 수 있다면 사용할 수.
|
|
||||||
|
|
||||||
이러한 경로 `FileEntry` 및 파일 플러그인에 의해 반환 된 `DirectoryEntry` 개체의 `fullPath` 속성에 노출 되었던. 그러나 파일 플러그인의,, 더 이상 새로운 버전 자바 스크립트이 경로 노출.
|
|
||||||
|
|
||||||
새로 업그레이드 하는 경우 (1.0.0 이상) 버전의 파일, 및 이전 사용 하 고 `entry.fullPath` `download()` 또는 `upload()` 인수로 다음 대신 파일 시스템 Url을 사용 하 여 코드를 변경 해야 합니다.
|
|
||||||
|
|
||||||
폼의 파일 URL을 반환 하는 `FileEntry.toURL()` 및 `DirectoryEntry.toURL()`
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
어떤 `download()` 및 `upload()` 방법에서 절대 파일 경로 대신 사용할 수 있습니다.
|
|
|
@ -1,311 +0,0 @@
|
||||||
<!--
|
|
||||||
# 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-file-transfer
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg)](https://travis-ci.org/apache/cordova-plugin-file-transfer)
|
|
||||||
|
|
||||||
Plugin dokumentacja: <doc/index.md>
|
|
||||||
|
|
||||||
Plugin pozwala na przesyłanie i pobieranie plików.
|
|
||||||
|
|
||||||
Ten plugin określa globalne `FileTransfer`, `FileUploadOptions` konstruktorów.
|
|
||||||
|
|
||||||
Chociaż w globalnym zasięgu, są nie dostępne dopiero po `deviceready` imprezie.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Instalacja
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Obsługiwane platformy
|
|
||||||
|
|
||||||
* Amazon Fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Przeglądarka
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 i 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
\ * *Nie obsługują `onprogress` ani `abort()` *
|
|
||||||
|
|
||||||
\ ** *Nie obsługują `onprogress` *
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
Obiekt `FileTransfer` zapewnia sposób wgrać pliki za pomocą Multi-część POST lub PUT żądania HTTP i pobierania plików, jak również.
|
|
||||||
|
|
||||||
## Właściwości
|
|
||||||
|
|
||||||
* **OnProgress**: o nazwie `ProgressEvent` gdy nowy kawałek danych jest przenoszona. *(Funkcja)*
|
|
||||||
|
|
||||||
## Metody
|
|
||||||
|
|
||||||
* **wgraj**: wysyła plik na serwer.
|
|
||||||
|
|
||||||
* **do pobrania**: pliki do pobrania pliku z serwera.
|
|
||||||
|
|
||||||
* **przerwać**: przerywa w toku transferu.
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
**Parametry**:
|
|
||||||
|
|
||||||
* **fileURL**: URL plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej)
|
|
||||||
|
|
||||||
* **serwer**: adres URL serwera, aby otrzymać plik, jak kodowane przez`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: wywołania zwrotnego, który jest przekazywany obiekt `FileUploadResult`. *(Funkcja)*
|
|
||||||
|
|
||||||
* **errorCallback**: wywołanie zwrotne, które wykonuje, jeżeli wystąpi błąd pobierania `FileUploadResult`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)*
|
|
||||||
|
|
||||||
* **Opcje**: parametry opcjonalne *(obiektu)*. Ważne klucze:
|
|
||||||
|
|
||||||
* **fileKey**: nazwa elementu form. Domyślnie `file` . (DOMString)
|
|
||||||
* **Nazwa pliku**: nazwy pliku, aby użyć podczas zapisywania pliku na serwerze. Domyślnie `image.jpg` . (DOMString)
|
|
||||||
* **element httpMethod**: Metoda HTTP do użycia - `umieścić` lub `POST`. Domyślnie `POST`. (DOMString)
|
|
||||||
* **mimeType**: Typ mime danych do przesłania. Domyślnie do `image/jpeg`. (DOMString)
|
|
||||||
* **params**: zestaw par opcjonalny klucz/wartość w żądaniu HTTP. (Obiekt)
|
|
||||||
* **chunkedMode**: czy przekazać dane w trybie pakietowego przesyłania strumieniowego. Wartością domyślną jest `true`. (Wartość logiczna)
|
|
||||||
* **headers**: Mapa wartości Nazwa/nagłówka nagłówek. Aby określić więcej niż jedną wartość, należy użyć tablicę. Na iOS, FireOS i Android jeśli nagłówek o nazwie Content-Type jest obecny, wieloczęściowa forma nie danych. (Object)
|
|
||||||
* **element httpMethod**: Metoda HTTP np. POST lub PUT. Ustawienia domyślne do `POST`. (DOMString)
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)*
|
|
||||||
|
|
||||||
### Przykład
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Przykład z Prześlij nagłówki i zdarzeń postępu (Android i iOS tylko)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
Obiekt `FileUploadResult` jest przekazywana do sukcesu wywołania zwrotnego metody `upload() służącą` obiektu `FileTransfer`.
|
|
||||||
|
|
||||||
### Właściwości
|
|
||||||
|
|
||||||
* **bytesSent**: liczba bajtów wysłanych do serwera jako część upload. (długie)
|
|
||||||
|
|
||||||
* **responseCode**: kod odpowiedzi HTTP, zwracane przez serwer. (długie)
|
|
||||||
|
|
||||||
* **odpowiedź**: HTTP odpowiedzi zwracane przez serwer. (DOMString)
|
|
||||||
|
|
||||||
* **nagłówki**: nagłówki HTTP odpowiedzi przez serwer. (Obiekt)
|
|
||||||
|
|
||||||
* Obecnie obsługiwane na iOS tylko.
|
|
||||||
|
|
||||||
### Dziwactwa iOS
|
|
||||||
|
|
||||||
* Nie obsługuje `responseCode` lub`bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**Parametry**:
|
|
||||||
|
|
||||||
* **Źródło**: adres URL serwera, aby pobrać plik, jak kodowane przez`encodeURI()`.
|
|
||||||
|
|
||||||
* **cel**: url plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej)
|
|
||||||
|
|
||||||
* **successCallback**: wywołania zwrotnego, który jest przekazywany `FileEntry` obiektu. *(Funkcja)*
|
|
||||||
|
|
||||||
* **errorCallback**: wywołanie zwrotne, które wykonuje, jeśli wystąpi błąd podczas pobierania `FileEntry`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)*
|
|
||||||
|
|
||||||
* **Opcje**: parametry opcjonalne, obecnie tylko obsługuje nagłówki (takie jak autoryzacja (uwierzytelnianie podstawowe), itp.).
|
|
||||||
|
|
||||||
### Przykład
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
### WP8 dziwactwa
|
|
||||||
|
|
||||||
* Pobierz wnioski są buforowane przez rodzimych realizacji. Aby uniknąć, buforowanie, przekazać `if-Modified-Since` nagłówka do pobrania Metoda.
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
Przerywa w toku transferu. Onerror callback jest przekazywany obiekt FileTransferError, który kod błędu z FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Przykład
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
Obiekt `FileTransferError` jest przekazywana do błąd wywołania zwrotnego, gdy wystąpi błąd.
|
|
||||||
|
|
||||||
### Właściwości
|
|
||||||
|
|
||||||
* **Kod**: jeden z kodów błędów wstępnie zdefiniowanych poniżej. (Liczba)
|
|
||||||
|
|
||||||
* **Źródło**: URL do źródła. (String)
|
|
||||||
|
|
||||||
* **cel**: adres URL do docelowego. (String)
|
|
||||||
|
|
||||||
* **HTTP_STATUS**: kod stanu HTTP. Ten atrybut jest dostępna tylko po otrzymaniu kodu odpowiedzi z połączenia HTTP. (Liczba)
|
|
||||||
|
|
||||||
* **body** Treść odpowiedzi. Ten atrybut jest dostępna tylko wtedy, gdy odpowiedź jest otrzymanych od połączenia HTTP. (String)
|
|
||||||
|
|
||||||
* **exception**: albo e.getMessage lub e.toString (String)
|
|
||||||
|
|
||||||
### Stałe
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Do tyłu zgodności stwierdza
|
|
||||||
|
|
||||||
Poprzednie wersje tego pluginu tylko zaakceptować urządzenia bezwzględnych ścieżek jako źródło dla przekazywania, lub w celu pobrania. Te ścieżki będzie zazwyczaj formy
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Do tyłu zgodności, akceptowane są jeszcze te ścieżki, i jeśli aplikacja nagrał ścieżki, jak te w trwałej pamięci, następnie można nadal stosować.
|
|
||||||
|
|
||||||
Te ścieżki były narażone wcześniej we właściwości `fullPath` `FileEntry` i `DirectoryEntry` obiektów zwróconych przez wtyczki pliku. Nowe wersje pliku plugin, jednak już wystawiać te ścieżki do JavaScript.
|
|
||||||
|
|
||||||
Jeśli uaktualniasz nowy (1.0.0 lub nowsza) wersja pliku i mieć wcześniej przy `entry.fullPath` jako argumenty `download()` lub `upload() służącą`, a następnie trzeba będzie zmienić kod aby używać adresów URL plików zamiast.
|
|
||||||
|
|
||||||
`FileEntry.toURL()` i `DirectoryEntry.toURL()` zwraca adres URL plików formularza
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
które mogą być używane zamiast bezwzględna ścieżka zarówno `download()` i `metody upload()` metody.
|
|
|
@ -1,302 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
Plugin pozwala na przesyłanie i pobieranie plików.
|
|
||||||
|
|
||||||
Ten plugin określa globalne `FileTransfer`, `FileUploadOptions` konstruktorów.
|
|
||||||
|
|
||||||
Chociaż w globalnym zasięgu, są nie dostępne dopiero po `deviceready` imprezie.
|
|
||||||
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false);
|
|
||||||
function onDeviceReady() {
|
|
||||||
console.log(FileTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Instalacja
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Obsługiwane platformy
|
|
||||||
|
|
||||||
* Amazon Fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Przeglądarka
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 i 8 *
|
|
||||||
* Windows 8
|
|
||||||
* Windows
|
|
||||||
|
|
||||||
* *Nie obsługują `onprogress` ani `abort()`*
|
|
||||||
|
|
||||||
* * *Nie obsługują `onprogress`*
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
Obiekt `FileTransfer` zapewnia sposób wgrać pliki przy użyciu żądania HTTP wieloczęściowe POST i pobierania plików, jak również.
|
|
||||||
|
|
||||||
## Właściwości
|
|
||||||
|
|
||||||
* **OnProgress**: o nazwie `ProgressEvent` gdy nowy kawałek danych jest przenoszona. *(Funkcja)*
|
|
||||||
|
|
||||||
## Metody
|
|
||||||
|
|
||||||
* **wgraj**: wysyła plik na serwer.
|
|
||||||
|
|
||||||
* **do pobrania**: pliki do pobrania pliku z serwera.
|
|
||||||
|
|
||||||
* **przerwać**: przerywa w toku transferu.
|
|
||||||
|
|
||||||
## upload
|
|
||||||
|
|
||||||
**Parametry**:
|
|
||||||
|
|
||||||
* **fileURL**: URL plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej)
|
|
||||||
|
|
||||||
* **serwer**: adres URL serwera, aby otrzymać plik, jak kodowane przez`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: wywołania zwrotnego, który jest przekazywany obiekt `FileUploadResult`. *(Funkcja)*
|
|
||||||
|
|
||||||
* **errorCallback**: wywołanie zwrotne, które wykonuje, jeżeli wystąpi błąd pobierania `FileUploadResult`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)*
|
|
||||||
|
|
||||||
* **Opcje**: parametry opcjonalne *(obiektu)*. Ważne klucze:
|
|
||||||
|
|
||||||
* **fileKey**: nazwa elementu form. Domyślnie `file` . (DOMString)
|
|
||||||
* **Nazwa pliku**: nazwy pliku, aby użyć podczas zapisywania pliku na serwerze. Domyślnie `image.jpg` . (DOMString)
|
|
||||||
* **element httpMethod**: Metoda HTTP do użycia - `umieścić` lub `POST`. Domyślnie `POST`. (DOMString)
|
|
||||||
* **mimeType**: Typ mime danych do przesłania. Domyślnie do `image/jpeg`. (DOMString)
|
|
||||||
* **params**: zestaw par opcjonalny klucz/wartość w żądaniu HTTP. (Obiekt)
|
|
||||||
* **chunkedMode**: czy przekazać dane w trybie pakietowego przesyłania strumieniowego. Wartością domyślną jest `true`. (Wartość logiczna)
|
|
||||||
* **headers**: Mapa wartości Nazwa/nagłówka nagłówek. Aby określić więcej niż jedną wartość, należy użyć tablicę. (Obiekt)
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)*
|
|
||||||
|
|
||||||
### Przykład
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Przykład z Prześlij nagłówki i zdarzeń postępu (Android i iOS tylko)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
Obiekt `FileUploadResult` jest przekazywana do sukcesu wywołania zwrotnego metody `upload() służącą` obiektu `FileTransfer`.
|
|
||||||
|
|
||||||
### Właściwości
|
|
||||||
|
|
||||||
* **bytesSent**: liczba bajtów wysłanych do serwera jako część upload. (długie)
|
|
||||||
|
|
||||||
* **responseCode**: kod odpowiedzi HTTP, zwracane przez serwer. (długie)
|
|
||||||
|
|
||||||
* **odpowiedź**: HTTP odpowiedzi zwracane przez serwer. (DOMString)
|
|
||||||
|
|
||||||
* **nagłówki**: nagłówki HTTP odpowiedzi przez serwer. (Obiekt)
|
|
||||||
|
|
||||||
* Obecnie obsługiwane na iOS tylko.
|
|
||||||
|
|
||||||
### Dziwactwa iOS
|
|
||||||
|
|
||||||
* Nie obsługuje `responseCode` lub`bytesSent`.
|
|
||||||
|
|
||||||
## download
|
|
||||||
|
|
||||||
**Parametry**:
|
|
||||||
|
|
||||||
* **Źródło**: adres URL serwera, aby pobrać plik, jak kodowane przez`encodeURI()`.
|
|
||||||
|
|
||||||
* **cel**: url plików reprezentujących pliku na urządzenie. Dla wstecznej kompatybilności, to może również być pełną ścieżkę pliku na urządzenie. (Zobacz [wstecz zgodności zauważa] poniżej)
|
|
||||||
|
|
||||||
* **successCallback**: wywołania zwrotnego, który jest przekazywany `FileEntry` obiektu. *(Funkcja)*
|
|
||||||
|
|
||||||
* **errorCallback**: wywołanie zwrotne, które wykonuje, jeśli wystąpi błąd podczas pobierania `FileEntry`. Wywoływany z obiektu `FileTransferError`. *(Funkcja)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: parametr opcjonalny, domyślnie `false` . Jeśli zestaw `true` , to akceptuje wszystkie certyfikaty bezpieczeństwa. Jest to przydatne, ponieważ Android odrzuca Certyfikaty samopodpisane. Nie zaleca się do użytku produkcyjnego. Obsługiwane na Androida i iOS. *(wartość logiczna)*
|
|
||||||
|
|
||||||
* **Opcje**: parametry opcjonalne, obecnie tylko obsługuje nagłówki (takie jak autoryzacja (uwierzytelnianie podstawowe), itp.).
|
|
||||||
|
|
||||||
### Przykład
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## abort
|
|
||||||
|
|
||||||
Przerywa w toku transferu. Onerror callback jest przekazywany obiekt FileTransferError, który kod błędu z FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Przykład
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
Obiekt `FileTransferError` jest przekazywana do błąd wywołania zwrotnego, gdy wystąpi błąd.
|
|
||||||
|
|
||||||
### Właściwości
|
|
||||||
|
|
||||||
* **Kod**: jeden z kodów błędów wstępnie zdefiniowanych poniżej. (Liczba)
|
|
||||||
|
|
||||||
* **Źródło**: URL do źródła. (String)
|
|
||||||
|
|
||||||
* **cel**: adres URL do docelowego. (String)
|
|
||||||
|
|
||||||
* **HTTP_STATUS**: kod stanu HTTP. Ten atrybut jest dostępna tylko po otrzymaniu kodu odpowiedzi z połączenia HTTP. (Liczba)
|
|
||||||
|
|
||||||
* **body** Treść odpowiedzi. Ten atrybut jest dostępna tylko wtedy, gdy odpowiedź jest otrzymanych od połączenia HTTP. (String)
|
|
||||||
|
|
||||||
* **exception**: albo e.getMessage lub e.toString (String)
|
|
||||||
|
|
||||||
### Stałe
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Do tyłu zgodności stwierdza
|
|
||||||
|
|
||||||
Poprzednie wersje tego pluginu tylko zaakceptować urządzenia bezwzględnych ścieżek jako źródło dla przekazywania, lub w celu pobrania. Te ścieżki będzie zazwyczaj formy
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Do tyłu zgodności, akceptowane są jeszcze te ścieżki, i jeśli aplikacja nagrał ścieżki, jak te w trwałej pamięci, następnie można nadal stosować.
|
|
||||||
|
|
||||||
Te ścieżki były narażone wcześniej we właściwości `fullPath` `FileEntry` i `DirectoryEntry` obiektów zwróconych przez wtyczki pliku. Nowe wersje pliku plugin, jednak już wystawiać te ścieżki do JavaScript.
|
|
||||||
|
|
||||||
Jeśli uaktualniasz nowy (1.0.0 lub nowsza) wersja pliku i mieć wcześniej przy `entry.fullPath` jako argumenty `download()` lub `upload() służącą`, a następnie trzeba będzie zmienić kod aby używać adresów URL plików zamiast.
|
|
||||||
|
|
||||||
`FileEntry.toURL()` i `DirectoryEntry.toURL()` zwraca adres URL plików formularza
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
które mogą być używane zamiast bezwzględna ścieżka zarówno `download()` i `metody upload()` metody.
|
|
|
@ -1,290 +0,0 @@
|
||||||
<!---
|
|
||||||
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-file-transfer
|
|
||||||
|
|
||||||
Этот плагин позволяет вам загружать и скачивать файлы.
|
|
||||||
|
|
||||||
## Установка
|
|
||||||
|
|
||||||
cordova plugin add cordova-plugin-file-transfer
|
|
||||||
|
|
||||||
|
|
||||||
## Поддерживаемые платформы
|
|
||||||
|
|
||||||
* Amazon Fire OS
|
|
||||||
* Android
|
|
||||||
* BlackBerry 10
|
|
||||||
* Firefox OS **
|
|
||||||
* iOS
|
|
||||||
* Windows Phone 7 и 8 *
|
|
||||||
* Windows 8 ***|
|
|
||||||
* Windows ***|
|
|
||||||
|
|
||||||
* *Не поддерживают `onprogress` , ни `abort()` *
|
|
||||||
|
|
||||||
** *Не поддерживает `onprogress` *
|
|
||||||
|
|
||||||
Частичная поддержка `onprogress` для закачки метод. `onprogress` вызывается с пустой ход событий благодаря Windows limitations_
|
|
||||||
|
|
||||||
# FileTransfer
|
|
||||||
|
|
||||||
`FileTransfer`Объект предоставляет способ для загрузки файлов с помощью нескольких частей запроса POST HTTP и для загрузки файлов, а также.
|
|
||||||
|
|
||||||
## Параметры
|
|
||||||
|
|
||||||
* **OnProgress**: называется с `ProgressEvent` всякий раз, когда новый фрагмент данных передается. *(Функция)*
|
|
||||||
|
|
||||||
## Методы
|
|
||||||
|
|
||||||
* **добавлено**: отправляет файл на сервер.
|
|
||||||
|
|
||||||
* **скачать**: Скачать файл с сервера.
|
|
||||||
|
|
||||||
* **прервать**: прерывает передачу в прогресс.
|
|
||||||
|
|
||||||
## загрузить
|
|
||||||
|
|
||||||
**Параметры**:
|
|
||||||
|
|
||||||
* **fileURL**: файловой системы URL-адрес, представляющий файл на устройстве. Для обратной совместимости, это также может быть полный путь к файлу на устройстве. (См. [обратной совместимости отмечает] ниже)
|
|
||||||
|
|
||||||
* **сервер**: URL-адрес сервера, чтобы получить файл, как закодированные`encodeURI()`.
|
|
||||||
|
|
||||||
* **successCallback**: обратного вызова, передаваемого `Metadata` объект. *(Функция)*
|
|
||||||
|
|
||||||
* **errorCallback**: обратного вызова, который выполняется в случае получения ошибки `Metadata` . Вызываемый с `FileTransferError` объект. *(Функция)*
|
|
||||||
|
|
||||||
* **опции**: необязательные параметры *(объект)*. Допустимые ключи:
|
|
||||||
|
|
||||||
* **fileKey**: имя элемента form. По умолчанию `file` . (DOMString)
|
|
||||||
* **имя файла**: имя файла для использования при сохранении файла на сервере. По умолчанию `image.jpg` . (DOMString)
|
|
||||||
* **mimeType**: mime-тип данных для загрузки. По умолчанию `image/jpeg` . (DOMString)
|
|
||||||
* **params**: набор пар дополнительный ключ/значение для передачи в HTTP-запросе. (Объект)
|
|
||||||
* **chunkedMode**: следует ли загружать данные в фрагментарности потоковом режиме. По умолчанию `true` . (Логическое значение)
|
|
||||||
* **заголовки**: Карта значений заголовок имя заголовка. Используйте массив для указания более одного значения. (Объект)
|
|
||||||
|
|
||||||
* **trustAllHosts**: необязательный параметр, по умолчанию `false` . Если значение `true` , она принимает все сертификаты безопасности. Это полезно, поскольку Android отвергает самозаверяющие сертификаты. Не рекомендуется для использования в производстве. Поддерживается на Android и iOS. *(логическое значение)*
|
|
||||||
|
|
||||||
### Пример
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function (r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function (error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey = "file";
|
|
||||||
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
|
|
||||||
options.mimeType = "text/plain";
|
|
||||||
|
|
||||||
var params = {};
|
|
||||||
params.value1 = "test";
|
|
||||||
params.value2 = "param";
|
|
||||||
|
|
||||||
options.params = params;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
### Пример с загружать заголовки и события Progress (Android и iOS только)
|
|
||||||
|
|
||||||
function win(r) {
|
|
||||||
console.log("Code = " + r.responseCode);
|
|
||||||
console.log("Response = " + r.response);
|
|
||||||
console.log("Sent = " + r.bytesSent);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail(error) {
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var uri = encodeURI("http://some.server.com/upload.php");
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
|
|
||||||
options.mimeType="text/plain";
|
|
||||||
|
|
||||||
var headers={'headerParam':'headerValue'};
|
|
||||||
|
|
||||||
options.headers = headers;
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.onprogress = function(progressEvent) {
|
|
||||||
if (progressEvent.lengthComputable) {
|
|
||||||
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
|
|
||||||
} else {
|
|
||||||
loadingStatus.increment();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ft.upload(fileURL, uri, win, fail, options);
|
|
||||||
|
|
||||||
|
|
||||||
## FileUploadResult
|
|
||||||
|
|
||||||
Объект `FileUploadResult` передается на успех обратного вызова метода `upload()` объекта `FileTransfer`.
|
|
||||||
|
|
||||||
### Параметры
|
|
||||||
|
|
||||||
* **bytesSent**: количество байт, отправленных на сервер как часть загрузки. (длинная)
|
|
||||||
|
|
||||||
* **responseCode**: код ответа HTTP, возвращаемых сервером. (длинная)
|
|
||||||
|
|
||||||
* **ответ**: ответ HTTP, возвращаемых сервером. (DOMString)
|
|
||||||
|
|
||||||
* **заголовки**: заголовки ответов HTTP-сервером. (Объект)
|
|
||||||
|
|
||||||
* В настоящее время поддерживается только для iOS.
|
|
||||||
|
|
||||||
### Особенности iOS
|
|
||||||
|
|
||||||
* Не поддерживает `responseCode` или`bytesSent`.
|
|
||||||
|
|
||||||
## Скачать
|
|
||||||
|
|
||||||
**Параметры**:
|
|
||||||
|
|
||||||
* **источник**: URL-адрес сервера для загрузки файла, как закодированные`encodeURI()`.
|
|
||||||
|
|
||||||
* **Цель**: файловой системы URL-адрес, представляющий файл на устройстве. Для обратной совместимости, это также может быть полный путь к файлу на устройстве. (См. [обратной совместимости отмечает] ниже)
|
|
||||||
|
|
||||||
* **successCallback**: обратного вызова, передаваемого `FileEntry` объект. *(Функция)*
|
|
||||||
|
|
||||||
* **errorCallback**: обратного вызова, который выполняется, если возникает ошибка при получении `Metadata` . Вызываемый с `FileTransferError` объект. *(Функция)*
|
|
||||||
|
|
||||||
* **trustAllHosts**: необязательный параметр, по умолчанию `false` . Если значение `true` , она принимает все сертификаты безопасности. Это полезно, потому что Android отвергает самозаверяющие сертификаты. Не рекомендуется для использования в производстве. Поддерживается на Android и iOS. *(логическое значение)*
|
|
||||||
|
|
||||||
* **опции**: необязательные параметры, в настоящее время только поддерживает заголовки (например авторизации (базовая аутентификация) и т.д.).
|
|
||||||
|
|
||||||
### Пример
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a path on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/downloads/
|
|
||||||
|
|
||||||
var fileTransfer = new FileTransfer();
|
|
||||||
var uri = encodeURI("http://some.server.com/download.php");
|
|
||||||
|
|
||||||
fileTransfer.download(
|
|
||||||
uri,
|
|
||||||
fileURL,
|
|
||||||
function(entry) {
|
|
||||||
console.log("download complete: " + entry.toURL());
|
|
||||||
},
|
|
||||||
function(error) {
|
|
||||||
console.log("download error source " + error.source);
|
|
||||||
console.log("download error target " + error.target);
|
|
||||||
console.log("upload error code" + error.code);
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
## прервать
|
|
||||||
|
|
||||||
Прерывает передачу в прогресс. Onerror обратного вызова передается объект FileTransferError, который имеет код ошибки FileTransferError.ABORT_ERR.
|
|
||||||
|
|
||||||
### Пример
|
|
||||||
|
|
||||||
// !! Assumes variable fileURL contains a valid URL to a text file on the device,
|
|
||||||
// for example, cdvfile://localhost/persistent/path/to/file.txt
|
|
||||||
|
|
||||||
var win = function(r) {
|
|
||||||
console.log("Should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fail = function(error) {
|
|
||||||
// error.code == FileTransferError.ABORT_ERR
|
|
||||||
alert("An error has occurred: Code = " + error.code);
|
|
||||||
console.log("upload error source " + error.source);
|
|
||||||
console.log("upload error target " + error.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new FileUploadOptions();
|
|
||||||
options.fileKey="file";
|
|
||||||
options.fileName="myphoto.jpg";
|
|
||||||
options.mimeType="image/jpeg";
|
|
||||||
|
|
||||||
var ft = new FileTransfer();
|
|
||||||
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
|
|
||||||
ft.abort();
|
|
||||||
|
|
||||||
|
|
||||||
## FileTransferError
|
|
||||||
|
|
||||||
A `FileTransferError` при ошибке обратного вызова передается объект, при возникновении ошибки.
|
|
||||||
|
|
||||||
### Параметры
|
|
||||||
|
|
||||||
* **код**: один из кодов стандартных ошибок, перечисленные ниже. (Число)
|
|
||||||
|
|
||||||
* **источник**: URL-адрес источника. (Строка)
|
|
||||||
|
|
||||||
* **Цель**: URL-адрес к целевому объекту. (Строка)
|
|
||||||
|
|
||||||
* **http_status**: код состояния HTTP. Этот атрибут доступен только при код ответа от HTTP-соединения. (Число)
|
|
||||||
|
|
||||||
* **исключение**: либо e.getMessage или e.toString (строка)
|
|
||||||
|
|
||||||
### Константы
|
|
||||||
|
|
||||||
* 1 = `FileTransferError.FILE_NOT_FOUND_ERR`
|
|
||||||
* 2 = `FileTransferError.INVALID_URL_ERR`
|
|
||||||
* 3 = `FileTransferError.CONNECTION_ERR`
|
|
||||||
* 4 = `FileTransferError.ABORT_ERR`
|
|
||||||
* 5 = `FileTransferError.NOT_MODIFIED_ERR`
|
|
||||||
|
|
||||||
## Обратной совместимости отмечает
|
|
||||||
|
|
||||||
Предыдущие версии этого плагина будет принимать только устройства Абсолют файлам как источник для закачки, или как целевых для загрузок. Обычно эти пути бы формы
|
|
||||||
|
|
||||||
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
|
|
||||||
/storage/emulated/0/path/to/file (Android)
|
|
||||||
|
|
||||||
|
|
||||||
Для обратной совместимости, по-прежнему принимаются эти пути, и если ваше приложение зарегистрировано пути как в постоянное хранилище, то они могут продолжать использоваться.
|
|
||||||
|
|
||||||
Эти пути ранее были видны в `fullPath` свойства `FileEntry` и `DirectoryEntry` объекты, возвращаемые файл плагина. Новые версии файла плагина, однако, не подвергать эти пути в JavaScript.
|
|
||||||
|
|
||||||
Если вы переходите на новый (1.0.0 или новее) версию файла и вы ранее использовали `entry.fullPath` в качестве аргументов `download()` или `upload()` , то вам необходимо будет изменить код для использования файловой системы URL вместо.
|
|
||||||
|
|
||||||
`FileEntry.toURL()`и `DirectoryEntry.toURL()` возвращает URL-адрес формы файловой системы
|
|
||||||
|
|
||||||
cdvfile://localhost/persistent/path/to/file
|
|
||||||
|
|
||||||
|
|
||||||
которые могут быть использованы вместо абсолютного пути в обоих `download()` и `upload()` методы.
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue