Initial Commit ...
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"prepare_queue": {
|
||||
"installed": [],
|
||||
"uninstalled": []
|
||||
},
|
||||
"config_munge": {
|
||||
"files": {}
|
||||
},
|
||||
"installed_plugins": {
|
||||
"cordova-plugin-device": {
|
||||
"PACKAGE_NAME": "ir.saherelm.xFramework.xFramework"
|
||||
},
|
||||
"cordova-plugin-ionic-keyboard": {
|
||||
"PACKAGE_NAME": "ir.saherelm.xFramework.xFramework"
|
||||
},
|
||||
"cordova-plugin-ionic-webview": {
|
||||
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+",
|
||||
"PACKAGE_NAME": "ir.saherelm.xFramework.xFramework"
|
||||
},
|
||||
"cordova-plugin-splashscreen": {
|
||||
"PACKAGE_NAME": "ir.saherelm.xFramework.xFramework"
|
||||
},
|
||||
"cordova-plugin-statusbar": {
|
||||
"PACKAGE_NAME": "ir.saherelm.xFramework.xFramework"
|
||||
},
|
||||
"cordova-plugin-whitelist": {
|
||||
"PACKAGE_NAME": "ir.saherelm.xFramework.xFramework"
|
||||
}
|
||||
},
|
||||
"dependent_plugins": {}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
max_jobs: 1
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
nodejs_version: "4"
|
||||
matrix:
|
||||
- PLATFORM: windows-10-store
|
||||
JUST_BUILD: --justBuild
|
||||
install:
|
||||
- npm cache clean -f
|
||||
- node --version
|
||||
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
|
||||
- npm install -g cordova
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%
|
||||
@@ -0,0 +1,10 @@
|
||||
root: true
|
||||
extends: semistandard
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
camelcase: off
|
||||
padded-blocks: off
|
||||
operator-linebreak: off
|
||||
no-throw-literal: off
|
||||
@@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
|
||||
is intended as a quick reference, for complete details please see our Contributor Guidelines:
|
||||
|
||||
http://cordova.apache.org/contribute/contribute_guidelines.html
|
||||
|
||||
Thanks!
|
||||
-->
|
||||
|
||||
### Platforms affected
|
||||
|
||||
|
||||
### What does this PR do?
|
||||
|
||||
|
||||
### What testing has been done on this change?
|
||||
|
||||
|
||||
### Checklist
|
||||
- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
|
||||
- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
|
||||
- [ ] Added automated test coverage as appropriate for this change.
|
||||
@@ -0,0 +1,23 @@
|
||||
#If ignorance is bliss, then somebody knock the smile off my face
|
||||
|
||||
*.csproj.user
|
||||
*.suo
|
||||
*.cache
|
||||
Thumbs.db
|
||||
*.DS_Store
|
||||
|
||||
*.bak
|
||||
*.cache
|
||||
*.log
|
||||
*.swp
|
||||
*.user
|
||||
|
||||
node_modules
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
sudo: false
|
||||
addons:
|
||||
jwt:
|
||||
secure: egTo2EERSKVWdBoP+6ewd/JIyyly2XTT1xOVj27v2L148c453uRNPjXwiGRYu7vTw5rkGK+H54n4FG3rUOuEVNX9NDNC5TlkhTfmecXNzjyOIuV7xD0qg5s6Q3IXg8kAp9+JXWbVVR6hoPzmAAnTT4rcoh6cPg4Tf327W2sRGkw=
|
||||
env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION="4.2"
|
||||
matrix:
|
||||
include:
|
||||
- env: PLATFORM=browser-chrome
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-firefox
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-safari
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-edge
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-9.3
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-10.0
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=android-4.4
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-5.1
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-6.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-7.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-26.0.2
|
||||
before_install:
|
||||
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
|
||||
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
|
||||
install $TRAVIS_NODE_VERSION
|
||||
- node --version
|
||||
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
|
||||
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
|
||||
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26;
|
||||
fi
|
||||
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic
|
||||
&& npm install && popd
|
||||
- npm install -g cordova
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- npm test
|
||||
- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
|
||||
--buildName travis-plugin-device-$TRAVIS_JOB_NUMBER
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<!--
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
-->
|
||||
|
||||
# Contributing to Apache Cordova
|
||||
|
||||
Anyone can contribute to Cordova. And we need your contributions.
|
||||
|
||||
There are multiple ways to contribute: report bugs, improve the docs, and
|
||||
contribute code.
|
||||
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/contribute/).
|
||||
|
||||
The details are explained there, but the important items are:
|
||||
- Sign and submit an Apache ICLA (Contributor License Agreement).
|
||||
- Have a Jira issue open that corresponds to your contribution.
|
||||
- Run the tests so your patch doesn't break existing functionality.
|
||||
|
||||
We look forward to your contributions!
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,5 @@
|
||||
Apache Cordova
|
||||
Copyright 2012 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
@@ -0,0 +1,267 @@
|
||||
---
|
||||
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|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-device)|[](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
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
<!--
|
||||
#
|
||||
# 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
|
||||
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Dieses Plugin definiert eine globale `device` -Objekt, das des Geräts Hard- und Software beschreibt. Das Objekt im globalen Gültigkeitsbereich ist es zwar nicht verfügbar bis nach dem `deviceready` Ereignis.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Eigenschaften
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Rufen Sie die Version von Cordova, die auf dem Gerät ausgeführt.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Die `device.model` gibt den Namen der Modell- oder des Geräts zurück. Der Wert wird vom Gerätehersteller festgelegt und kann zwischen den Versionen des gleichen Produkts unterschiedlich sein.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Finden Sie unter http://theiphonewiki.com/wiki/index.php?title=Models / / Var-Modell = device.model;
|
||||
|
||||
|
||||
### Android Eigenarten
|
||||
|
||||
* Ruft den [Produktname](http://developer.android.com/reference/android/os/Build.html#PRODUCT) anstelle des [Modellnamens](http://developer.android.com/reference/android/os/Build.html#MODEL), das ist oft der Codename für die Produktion. Beispielsweise das Nexus One gibt `Passion` , und Motorola Droid gibt`voles`.
|
||||
|
||||
### Tizen Macken
|
||||
|
||||
* Gibt z. B. das Gerätemodell von dem Kreditor zugeordnet,`TIZEN`
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
* Gibt das vom Hersteller angegebenen Gerätemodell zurück. Beispielsweise gibt der Samsung-Fokus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Name des Betriebssystems des Geräts zu erhalten.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Macken
|
||||
|
||||
Windows Phone 7 Geräte melden die Plattform als`WinCE`.
|
||||
|
||||
### Windows Phone 8 Macken
|
||||
|
||||
Windows Phone 8 Geräte melden die Plattform als`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Des Geräts Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier) zu erhalten).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Beschreibung
|
||||
|
||||
Die Details wie eine UUID generiert wird werden vom Gerätehersteller und beziehen sich auf die Plattform oder das Modell des Geräts.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
/ / Android: wird eine zufällige 64-Bit-Ganzzahl (als Zeichenfolge, wieder!) / / die ganze Zahl wird beim ersten Start des Geräts erzeugt / / / / BlackBerry: gibt die PIN-Nummer des Gerätes / / Dies ist eine neunstellige eindeutige Ganzzahl (als String, obwohl!) / / / / iPhone: (paraphrasiert aus der Dokumentation zur UIDevice-Klasse) / / liefert eine Reihe von Hash-Werte, die aus mehreren Hardware erstellt identifiziert.
|
||||
/ / Es ist gewährleistet, dass für jedes Gerät eindeutig sein und kann nicht gebunden werden / / an den Benutzer weitergeleitet.
|
||||
/ / Windows Phone 7: gibt einen Hash des Gerät + aktueller Benutzer, / / wenn der Benutzer nicht definiert ist, eine Guid generiert und wird weiter bestehen, bis die app deinstalliert wird / / Tizen: gibt das Gerät IMEI (International Mobile Equipment Identity oder IMEI ist eine Zahl / / einzigartig für jedes GSM- und UMTS-Handy.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Die `uuid` auf iOS ist nicht eindeutig zu einem Gerät, aber für jede Anwendung, für jede Installation variiert. Es ändert sich, wenn Sie löschen und neu die app installieren, und möglicherweise auch beim iOS zu aktualisieren, oder auch ein Upgrade möglich die app pro Version (scheinbaren in iOS 5.1). Die `uuid` ist kein zuverlässiger Wert.
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
Die `uuid` für Windows Phone 7 die Berechtigung erfordert `ID_CAP_IDENTITY_DEVICE` . Microsoft wird diese Eigenschaft wahrscheinlich bald abzuschaffen. Wenn die Funktion nicht verfügbar ist, generiert die Anwendung eine persistente Guid, die für die Dauer der Installation der Anwendung auf dem Gerät gewährleistet ist.
|
||||
|
||||
## device.version
|
||||
|
||||
Version des Betriebssystems zu erhalten.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Dieses Plugin definiert eine globale `device` -Objekt, das des Geräts Hard- und Software beschreibt. Das Objekt im globalen Gültigkeitsbereich ist es zwar nicht verfügbar bis nach dem `deviceready` Ereignis.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Eigenschaften
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Rufen Sie die Version von Cordova, die auf dem Gerät ausgeführt.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Die `device.model` gibt den Namen der Modell- oder des Geräts zurück. Der Wert wird vom Gerätehersteller festgelegt und kann zwischen den Versionen des gleichen Produkts unterschiedlich sein.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Finden Sie unter http://theiphonewiki.com/wiki/index.php?title=Models / / Var-Modell = device.model;
|
||||
|
||||
|
||||
### Android Eigenarten
|
||||
|
||||
* Ruft den [Produktname][1] anstelle des [Modellnamens][2], das ist oft der Codename für die Produktion. Beispielsweise das Nexus One gibt `Passion` , und Motorola Droid gibt`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Tizen Macken
|
||||
|
||||
* Gibt z. B. das Gerätemodell von dem Kreditor zugeordnet,`TIZEN`
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
* Gibt das vom Hersteller angegebenen Gerätemodell zurück. Beispielsweise gibt der Samsung-Fokus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Name des Betriebssystems des Geräts zu erhalten.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Macken
|
||||
|
||||
Windows Phone 7 Geräte melden die Plattform als`WinCE`.
|
||||
|
||||
### Windows Phone 8 Macken
|
||||
|
||||
Windows Phone 8 Geräte melden die Plattform als`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Des Geräts Universally Unique Identifier ([UUID][3] zu erhalten).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Beschreibung
|
||||
|
||||
Die Details wie eine UUID generiert wird werden vom Gerätehersteller und beziehen sich auf die Plattform oder das Modell des Geräts.
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
/ / Android: wird eine zufällige 64-Bit-Ganzzahl (als Zeichenfolge, wieder!) / / die ganze Zahl wird beim ersten Start des Geräts erzeugt / / / / BlackBerry: gibt die PIN-Nummer des Gerätes / / Dies ist eine neunstellige eindeutige Ganzzahl (als String, obwohl!) / / / / iPhone: (paraphrasiert aus der Dokumentation zur UIDevice-Klasse) / / liefert eine Reihe von Hash-Werte, die aus mehreren Hardware erstellt identifiziert.
|
||||
/ / Es ist gewährleistet, dass für jedes Gerät eindeutig sein und kann nicht gebunden werden / / an den Benutzer weitergeleitet.
|
||||
/ / Windows Phone 7: gibt einen Hash des Gerät + aktueller Benutzer, / / wenn der Benutzer nicht definiert ist, eine Guid generiert und wird weiter bestehen, bis die app deinstalliert wird / / Tizen: gibt das Gerät IMEI (International Mobile Equipment Identity oder IMEI ist eine Zahl / / einzigartig für jedes GSM- und UMTS-Handy.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Die `uuid` auf iOS ist nicht eindeutig zu einem Gerät, aber für jede Anwendung, für jede Installation variiert. Es ändert sich, wenn Sie löschen und neu die app installieren, und möglicherweise auch beim iOS zu aktualisieren, oder auch ein Upgrade möglich die app pro Version (scheinbaren in iOS 5.1). Die `uuid` ist kein zuverlässiger Wert.
|
||||
|
||||
### Windows Phone 7 und 8 Eigenarten
|
||||
|
||||
Die `uuid` für Windows Phone 7 die Berechtigung erfordert `ID_CAP_IDENTITY_DEVICE` . Microsoft wird diese Eigenschaft wahrscheinlich bald abzuschaffen. Wenn die Funktion nicht verfügbar ist, generiert die Anwendung eine persistente Guid, die für die Dauer der Installation der Anwendung auf dem Gerät gewährleistet ist.
|
||||
|
||||
## device.version
|
||||
|
||||
Version des Betriebssystems zu erhalten.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Unterstützte Plattformen
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
### Kurzes Beispiel
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,216 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Este plugin define un global `device` objeto que describe del dispositivo hardware y software. Aunque el objeto está en el ámbito global, no está disponible hasta después de la `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalación
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propiedades
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Obtener la versión de Cordova que se ejecuta en el dispositivo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Amazon fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
El `device.model` devuelve el nombre de modelo del dispositivo o producto. El valor es fijado por el fabricante del dispositivo y puede ser diferente a través de versiones del mismo producto.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Rarezas Android
|
||||
|
||||
* Obtiene el [nombre del producto](http://developer.android.com/reference/android/os/Build.html#PRODUCT) en lugar del [nombre de la modelo](http://developer.android.com/reference/android/os/Build.html#MODEL), que es a menudo el nombre de código de producción. Por ejemplo, el Nexus One devuelve `Passion` y Motorola Droid devuelve `voles`.
|
||||
|
||||
### Rarezas Tizen
|
||||
|
||||
* Devuelve que el modelo de dispositivo asignado por el proveedor, por ejemplo, `TIZEN`
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
* Devuelve el modelo de dispositivo especificado por el fabricante. Por ejemplo, el Samsung Focus devuelve `SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtener el nombre del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 rarezas
|
||||
|
||||
Dispositivos Windows Phone 7 informe de la plataforma como `WinCE`.
|
||||
|
||||
### Windows Phone 8 rarezas
|
||||
|
||||
Dispositivos Windows Phone 8 Informe la plataforma como `Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtener identificador universalmente única del dispositivo ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descripción
|
||||
|
||||
Los detalles de cómo se genera un UUID son determinados por el fabricante del dispositivo y son específicos a la plataforma del dispositivo o modelo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Returns a random 64-bit integer (as a string, again!)
|
||||
// The integer is generated on the device's first boot
|
||||
//
|
||||
// BlackBerry: Returns the PIN number of the device
|
||||
// This is a nine-digit unique integer (as a string, though!)
|
||||
//
|
||||
// iPhone: (Paraphrased from the UIDevice Class documentation)
|
||||
// Returns a string of hash values created from multiple hardware identifies.
|
||||
// It is guaranteed to be unique for every device and can't be tied
|
||||
// to the user account.
|
||||
// Windows Phone 7 : Returns a hash of device+current user,
|
||||
// if the user is not defined, a guid is generated and will persist until the app is uninstalled
|
||||
// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
|
||||
// unique to every GSM and UMTS mobile phone.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Rarezas de iOS
|
||||
|
||||
El `uuid` en iOS no es exclusiva de un dispositivo, pero varía para cada aplicación, para cada instalación. Cambia si puedes borrar y volver a instalar la aplicación, y posiblemente también cuándo actualizar iOS, o incluso mejorar la aplicación por la versión (evidente en iOS 5.1). El `uuid` no es un valor confiable.
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
El `uuid` para Windows Phone 7 requiere el permiso `ID_CAP_IDENTITY_DEVICE`. Microsoft pronto probablemente desaprueban esta propiedad. Si la capacidad no está disponible, la aplicación genera un guid persistente que se mantiene durante la duración de la instalación de la aplicación en el dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Obtener la versión del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,220 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Este plugin define un global `device` objeto que describe del dispositivo hardware y software. Aunque el objeto está en el ámbito global, no está disponible hasta después de la `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalación
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propiedades
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Obtener la versión de Cordova que se ejecuta en el dispositivo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Amazon fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
El `device.model` devuelve el nombre de modelo del dispositivo o producto. El valor es fijado por el fabricante del dispositivo y puede ser diferente a través de versiones del mismo producto.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Rarezas Android
|
||||
|
||||
* Obtiene el [nombre del producto][1] en lugar del [nombre de la modelo][2], que es a menudo el nombre de código de producción. Por ejemplo, el Nexus One devuelve `Passion` y Motorola Droid devuelve `voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Rarezas Tizen
|
||||
|
||||
* Devuelve que el modelo de dispositivo asignado por el proveedor, por ejemplo, `TIZEN`
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
* Devuelve el modelo de dispositivo especificado por el fabricante. Por ejemplo, el Samsung Focus devuelve `SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtener el nombre del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 rarezas
|
||||
|
||||
Dispositivos Windows Phone 7 informe de la plataforma como `WinCE`.
|
||||
|
||||
### Windows Phone 8 rarezas
|
||||
|
||||
Dispositivos Windows Phone 8 Informe la plataforma como `Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtener identificador universalmente única del dispositivo ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descripción
|
||||
|
||||
Los detalles de cómo se genera un UUID son determinados por el fabricante del dispositivo y son específicos a la plataforma del dispositivo o modelo.
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: devuelve un entero de 64 bits al azar (como una cadena, otra vez!)
|
||||
// el entero es generado en el primer arranque del dispositivo
|
||||
//
|
||||
// BlackBerry: devuelve el número PIN del dispositivo
|
||||
// este es un entero único de nueve dígitos (como una cadena, aunque!)
|
||||
//
|
||||
// iPhone: (parafraseado de la documentación de la clase UIDevice)
|
||||
// devuelve una cadena de valores hash creado a partir
|
||||
// de múltiples hardware identifica.
|
||||
/ / Está garantizado para ser único para cada dispositivo y no puede ser atado / / a la cuenta de usuario.
|
||||
// Windows Phone 7: devuelve un hash de dispositivo + usuario actual,
|
||||
// si el usuario no está definido, un guid generado y persistirá hasta que se desinstala la aplicación
|
||||
//
|
||||
// Tizen: devuelve el dispositivo IMEI (identidad de equipo móvil internacional o IMEI es un número
|
||||
// único para cada teléfono móvil GSM y UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS chanfle
|
||||
|
||||
El `uuid` en iOS no es exclusiva de un dispositivo, pero varía para cada aplicación, para cada instalación. Cambia si puedes borrar y volver a instalar la aplicación, y posiblemente también cuándo actualizar iOS, o incluso mejorar la aplicación por la versión (evidente en iOS 5.1). El `uuid` no es un valor confiable.
|
||||
|
||||
### Windows Phone 7 y 8 rarezas
|
||||
|
||||
El `uuid` para Windows Phone 7 requiere el permiso `ID_CAP_IDENTITY_DEVICE`. Microsoft pronto probablemente desaprueban esta propiedad. Si la capacidad no está disponible, la aplicación genera un guid persistente que se mantiene durante la duración de la instalación de la aplicación en el dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Obtener la versión del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plataformas soportadas
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Explorador
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
### Ejemplo rápido
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. el Mango se vuelve 7.10.7720
|
||||
// Tizen: devuelve "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,215 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Ce plugin définit un global `device` objet qui décrit le matériel et les logiciels de l'appareil. Bien que l'objet est dans la portée globale, il n'est pas disponible jusqu'après la `deviceready` événement.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propriétés
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Retourne la version de Cordova en cours d'exécution sur l'appareil.
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
L'objet `device.model` retourne le nom du modèle de l'appareil/produit. Cette valeur est définie par le fabricant du périphérique et peut varier entre les différentes versions d'un même produit.
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Voir http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Quirks Android
|
||||
|
||||
* Retourne le [nom du produit](http://developer.android.com/reference/android/os/Build.html#PRODUCT) au lieu du [nom du modèle](http://developer.android.com/reference/android/os/Build.html#MODEL), ce qui équivaut souvent au nom de code de production. Par exemple, `Passion` pour le Nexus One et `voles` pour le Motorola Droid.
|
||||
|
||||
### Bizarreries de paciarelli
|
||||
|
||||
* Retourne le modèle du dispositif, assigné par le vendeur, par exemple `TIZEN`
|
||||
|
||||
### Notes au sujet de Windows Phone 7 et 8
|
||||
|
||||
* Retourne le modèle de l'appareil spécifié par le fabricant. Par exemple `SGH-i917` pour le Samsung Focus.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtenir le nom de système d'exploitation de l'appareil.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Quirks
|
||||
|
||||
Appareils Windows Phone 7 rapport de la plate-forme comme`WinCE`.
|
||||
|
||||
### Notes au sujet de Windows Phone 8
|
||||
|
||||
Appareils Windows Phone 8 rapport de la plate-forme comme`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtenir Universally Unique Identifier de l'appareil ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
Les détails de comment un UUID généré sont déterminées par le fabricant du périphérique et sont spécifiques à la plate-forme ou le modèle de l'appareil.
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// Android : retourne un nombre entier 64-bit aléatoire (sous la forme d'une chaîne de caractères, encore !)
|
||||
// Ce nombre entier est généré lors du premier démarrage de l'appareil
|
||||
//
|
||||
// BlackBerry : retourne le numéro PIN de l'appareil
|
||||
// Il s'agit d'un nombre entier unique à neuf chiffres (sous la forme d'une chaîne de caractères cependant !)
|
||||
//
|
||||
// iPhone : (copié depuis la documentation de la classe UIDevice)
|
||||
// Retourne une chaîne de caractères générée à partir de plusieurs caractéristiques matérielles.
|
||||
/ / Il est garanti pour être unique pour chaque appareil et ne peut pas être lié / / pour le compte d'utilisateur.
|
||||
// Windows Phone 7 : retourne un hashage généré à partir de appareil+utilisateur actuel,
|
||||
// si aucun utilisateur n'est défini, un guid est généré persistera jusqu'à ce que l'application soit désinstallée
|
||||
// Tizen : retourne le numéro IMEI (International Mobile Equipment Identity) de l'appareil, ce numéro est
|
||||
// unique pour chaque téléphone GSM et UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Spécificités iOS
|
||||
|
||||
Le `uuid` sur iOS n'est pas propre à un périphérique, mais varie pour chaque application, pour chaque installation. Elle change si vous supprimez, puis réinstallez l'application, et éventuellement aussi quand vous mettre à jour d'iOS, ou même mettre à jour le soft par version (apparent dans iOS 5.1). Le `uuid` n'est pas une valeur fiable.
|
||||
|
||||
### Notes au sujet de Windows Phone 7 et 8
|
||||
|
||||
Le `uuid` pour Windows Phone 7 requiert l'autorisation `ID_CAP_IDENTITY_DEVICE` . Microsoft va probablement bientôt obsolète de cette propriété. Si la capacité n'est pas disponible, l'application génère un guid persistant qui est maintenu pendant toute la durée de l'installation de l'application sur le périphérique.
|
||||
|
||||
## device.version
|
||||
|
||||
Téléchargez la version de système d'exploitation.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plates-formes supportées
|
||||
|
||||
* Android 2.1+
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Exemple court
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,218 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Ce plugin définit un global `device` objet qui décrit le matériel et les logiciels de l'appareil. Bien que l'objet est dans la portée globale, il n'est pas disponible jusqu'après la `deviceready` événement.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Propriétés
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Retourne la version de Cordova en cours d'exécution sur l'appareil.
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
L'objet `device.model` retourne le nom du modèle de l'appareil/produit. Cette valeur est définie par le fabricant du périphérique et peut varier entre les différentes versions d'un même produit.
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Voir http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Quirks Android
|
||||
|
||||
* Retourne le [nom du produit][1] au lieu du [nom du modèle][2], ce qui équivaut souvent au nom de code de production. Par exemple, `Passion` pour le Nexus One et `voles` pour le Motorola Droid.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Bizarreries de paciarelli
|
||||
|
||||
* Retourne le modèle du dispositif, assigné par le vendeur, par exemple `TIZEN`
|
||||
|
||||
### Windows Phone 7 et 8 Quirks
|
||||
|
||||
* Retourne le modèle de l'appareil spécifié par le fabricant. Par exemple `SGH-i917` pour le Samsung Focus.
|
||||
|
||||
## device.platform
|
||||
|
||||
Obtenir le nom de système d'exploitation de l'appareil.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 Quirks
|
||||
|
||||
Appareils Windows Phone 7 rapport de la plate-forme comme`WinCE`.
|
||||
|
||||
### Notes au sujet de Windows Phone 8
|
||||
|
||||
Appareils Windows Phone 8 rapport de la plate-forme comme`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Obtenir Universally Unique Identifier de l'appareil ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
Les détails de comment un UUID généré sont déterminées par le fabricant du périphérique et sont spécifiques à la plate-forme ou le modèle de l'appareil.
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// Android : retourne un nombre entier 64-bit aléatoire (sous la forme d'une chaîne de caractères, encore !)
|
||||
// Ce nombre entier est généré lors du premier démarrage de l'appareil
|
||||
//
|
||||
// BlackBerry : retourne le numéro PIN de l'appareil
|
||||
// Il s'agit d'un nombre entier unique à neuf chiffres (sous la forme d'une chaîne de caractères cependant !)
|
||||
//
|
||||
// iPhone : (copié depuis la documentation de la classe UIDevice)
|
||||
// Retourne une chaîne de caractères générée à partir de plusieurs caractéristiques matérielles.
|
||||
/ / Il est garanti pour être unique pour chaque appareil et ne peut pas être lié / / pour le compte d'utilisateur.
|
||||
// Windows Phone 7 : retourne un hashage généré à partir de appareil+utilisateur actuel,
|
||||
// si aucun utilisateur n'est défini, un guid est généré persistera jusqu'à ce que l'application soit désinstallée
|
||||
// Tizen : retourne le numéro IMEI (International Mobile Equipment Identity) de l'appareil, ce numéro est
|
||||
// unique pour chaque téléphone GSM et UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Spécificités iOS
|
||||
|
||||
Le `uuid` sur iOS n'est pas propre à un périphérique, mais varie pour chaque application, pour chaque installation. Elle change si vous supprimez, puis réinstallez l'application, et éventuellement aussi quand vous mettre à jour d'iOS, ou même mettre à jour le soft par version (apparent dans iOS 5.1). Le `uuid` n'est pas une valeur fiable.
|
||||
|
||||
### Windows Phone 7 et 8 Quirks
|
||||
|
||||
Le `uuid` pour Windows Phone 7 requiert l'autorisation `ID_CAP_IDENTITY_DEVICE` . Microsoft va probablement bientôt obsolète de cette propriété. Si la capacité n'est pas disponible, l'application génère un guid persistant qui est maintenu pendant toute la durée de l'installation de l'application sur le périphérique.
|
||||
|
||||
## device.version
|
||||
|
||||
Téléchargez la version de système d'exploitation.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Plates-formes prises en charge
|
||||
|
||||
* Android 2.1+
|
||||
* BlackBerry 10
|
||||
* Navigateur
|
||||
* iOS
|
||||
* Paciarelli
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
### Petit exemple
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Questo plugin definisce un global `device` oggetto che descrive il dispositivo hardware e software. Sebbene l'oggetto sia in ambito globale, non è disponibile fino a dopo il `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installazione
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Proprietà
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Ottenere la versione di Cordova in esecuzione nel dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Amazon fuoco OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Il `device.model` restituisce il nome del modello del dispositivo o del prodotto. Il valore viene impostato dal produttore del dispositivo e può essere differente tra le versioni dello stesso prodotto.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Vedi http://theiphonewiki.com/wiki/index.php?title=Models / / modello var = device.model;
|
||||
|
||||
|
||||
### Stranezze Android
|
||||
|
||||
* Ottiene il [nome del prodotto](http://developer.android.com/reference/android/os/Build.html#PRODUCT) anziché il [nome del modello](http://developer.android.com/reference/android/os/Build.html#MODEL), che è spesso il nome di codice di produzione. Ad esempio, restituisce il Nexus One `Passion` , e Motorola Droid restituisce`voles`.
|
||||
|
||||
### Tizen stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo assegnato dal fornitore, ad esempio,`TIZEN`
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo specificato dal produttore. Ad esempio, restituisce il Samsung Focus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Ottenere il nome del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 capricci
|
||||
|
||||
Windows Phone 7 dispositivi segnalano la piattaforma come`WinCE`.
|
||||
|
||||
### Windows Phone 8 stranezze
|
||||
|
||||
Dispositivi Windows Phone 8 segnalano la piattaforma come`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Ottenere identificatore del dispositivo univoco universale ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descrizione
|
||||
|
||||
I dettagli di come viene generato un UUID sono determinati dal produttore del dispositivo e sono specifici per la piattaforma o il modello del dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
/ / Android: restituisce un intero casuale di 64 bit (come stringa, ancora una volta!) / / il numero intero è generato al primo avvio del dispositivo / / / / BlackBerry: restituisce il numero PIN del dispositivo / / questo è un valore integer univoco a nove cifre (come stringa, benchè!) / / / / iPhone: (parafrasato dalla documentazione della classe UIDevice) / / restituisce una stringa di valori hash creata dall'hardware più identifica.
|
||||
/ / È garantito per essere unica per ogni dispositivo e non può essere legato / / per l'account utente.
|
||||
/ / Windows Phone 7: restituisce un hash dell'utente corrente, + dispositivo / / se l'utente non è definito, un guid generato e persisterà fino a quando l'applicazione viene disinstallata / / Tizen: restituisce il dispositivo IMEI (International Mobile Equipment Identity o IMEI è un numero / / unico per ogni cellulare GSM e UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Il `uuid` su iOS non è univoco per un dispositivo, ma varia per ogni applicazione, per ogni installazione. Cambia se si elimina e re-installare l'app, e possibilmente anche quando aggiornare iOS o anche aggiornare l'app per ogni versione (apparente in iOS 5.1). Il `uuid` non è un valore affidabile.
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
Il `uuid` per Windows Phone 7 richiede l'autorizzazione `ID_CAP_IDENTITY_DEVICE` . Microsoft probabilmente sarà presto deprecare questa proprietà. Se la funzionalità non è disponibile, l'applicazione genera un guid persistente che viene mantenuto per la durata dell'installazione dell'applicazione sul dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Ottenere la versione del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Questo plugin definisce un global `device` oggetto che descrive il dispositivo hardware e software. Sebbene l'oggetto sia in ambito globale, non è disponibile fino a dopo il `deviceready` evento.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Installazione
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Proprietà
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Ottenere la versione di Cordova in esecuzione nel dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Amazon fuoco OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Il `device.model` restituisce il nome del modello del dispositivo o del prodotto. Il valore viene impostato dal produttore del dispositivo e può essere differente tra le versioni dello stesso prodotto.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Vedi http://theiphonewiki.com/wiki/index.php?title=Models / / modello var = device.model;
|
||||
|
||||
|
||||
### Stranezze Android
|
||||
|
||||
* Ottiene il [nome del prodotto][1] anziché il [nome del modello][2], che è spesso il nome di codice di produzione. Ad esempio, restituisce il Nexus One `Passion` , e Motorola Droid restituisce`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Tizen stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo assegnato dal fornitore, ad esempio,`TIZEN`
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
* Restituisce il modello di dispositivo specificato dal produttore. Ad esempio, restituisce il Samsung Focus`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Ottenere il nome del sistema operativo del dispositivo.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 capricci
|
||||
|
||||
Windows Phone 7 dispositivi segnalano la piattaforma come`WinCE`.
|
||||
|
||||
### Windows Phone 8 stranezze
|
||||
|
||||
Dispositivi Windows Phone 8 segnalano la piattaforma come`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Ottenere identificatore del dispositivo univoco universale ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Descrizione
|
||||
|
||||
I dettagli di come viene generato un UUID sono determinati dal produttore del dispositivo e sono specifici per la piattaforma o il modello del dispositivo.
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
/ / Android: restituisce un intero casuale di 64 bit (come stringa, ancora una volta!) / / il numero intero è generato al primo avvio del dispositivo / / / / BlackBerry: restituisce il numero PIN del dispositivo / / questo è un valore integer univoco a nove cifre (come stringa, benchè!) / / / / iPhone: (parafrasato dalla documentazione della classe UIDevice) / / restituisce una stringa di valori hash creata dall'hardware più identifica.
|
||||
/ / È garantito per essere unica per ogni dispositivo e non può essere legato / / per l'account utente.
|
||||
/ / Windows Phone 7: restituisce un hash dell'utente corrente, + dispositivo / / se l'utente non è definito, un guid generato e persisterà fino a quando l'applicazione viene disinstallata / / Tizen: restituisce il dispositivo IMEI (International Mobile Equipment Identity o IMEI è un numero / / unico per ogni cellulare GSM e UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
Il `uuid` su iOS non è univoco per un dispositivo, ma varia per ogni applicazione, per ogni installazione. Cambia se si elimina e re-installare l'app, e possibilmente anche quando aggiornare iOS o anche aggiornare l'app per ogni versione (apparente in iOS 5.1). Il `uuid` non è un valore affidabile.
|
||||
|
||||
### Windows Phone 7 e 8 stranezze
|
||||
|
||||
Il `uuid` per Windows Phone 7 richiede l'autorizzazione `ID_CAP_IDENTITY_DEVICE` . Microsoft probabilmente sarà presto deprecare questa proprietà. Se la funzionalità non è disponibile, l'applicazione genera un guid persistente che viene mantenuto per la durata dell'installazione dell'applicazione sul dispositivo.
|
||||
|
||||
## device.version
|
||||
|
||||
Ottenere la versione del sistema operativo.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Piattaforme supportate
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Browser
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
### Esempio rapido
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
このプラグインをグローバル定義します `device` オブジェクトは、デバイスのハードウェアとソフトウェアについて説明します。 それは後まで利用可能なオブジェクトがグローバル スコープでは、 `deviceready` イベント。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## インストール
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## プロパティ
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
デバイスで実行されているコルドバのバージョンを取得します。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アマゾン火 OS
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`、デバイスのモデルまたは製品の名前を返します。値は、デバイスの製造元によって設定され、同じ製品のバージョン間で異なる可能性があります。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models を参照してください//var モデル = device.model;
|
||||
|
||||
|
||||
### Android の癖
|
||||
|
||||
* 生産コード名は[モデル名](http://developer.android.com/reference/android/os/Build.html#MODEL)の代わりに[製品名](http://developer.android.com/reference/android/os/Build.html#PRODUCT)を取得します。 たとえば、ネクサス 1 つを返します `Passion` 、Motorola のドロイドを返します`voles`.
|
||||
|
||||
### Tizen の癖
|
||||
|
||||
* たとえば、ベンダーによって割り当てられているデバイスのモデルを返します`TIZEN`
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
* 製造元によって指定されたデバイスのモデルを返します。たとえば、三星フォーカスを返します`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
デバイスのオペレーティング システム名を取得します。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* Browser4
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 の癖
|
||||
|
||||
Windows Phone 7 デバイスとプラットフォームを報告します。`WinCE`.
|
||||
|
||||
### Windows Phone 8 癖
|
||||
|
||||
Windows Phone 8 デバイスとプラットフォームを報告します。`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
デバイスのユニバーサル ・ ユニーク識別子 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)を取得します。).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 解説
|
||||
|
||||
UUID を生成する方法の詳細は、デバイスの製造元によって決定され、デバイスのプラットフォームやモデルに固有です。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
//アンドロイド: ランダムな 64 ビットの整数 (を文字列として返します、再び !)/デバイスの最初の起動時に生成される整数/////ブラックベリー: デバイスのピン番号を返します//これは 9 桁の一意な整数 (を文字列としても !)////iPhone: (UIDevice クラスのドキュメントから言い換え)//識別複数のハードウェアから作成されたハッシュ値の文字列を返します。。
|
||||
//それはすべてのデバイスに対して一意であることが保証され、接続することはできません//ユーザー アカウント。
|
||||
//Windows Phone 7: デバイス + 現在のユーザーのハッシュを返します//ユーザーが定義されていない場合 guid が生成され、アプリがアンインストールされるまで保持されます//Tizen: デバイスの IMEI を返します (国際モバイル機器アイデンティティまたは IMEI は番号です//すべての GSM および UMTS の携帯電話に固有です。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS の気まぐれ
|
||||
|
||||
`uuid`IOS で、デバイスに固有ではないインストールごと、アプリケーションごとに異なります。 削除、アプリを再インストールした場合に変更と多分またときアップグレード iOS の, またはもアップグレードするアプリ (iOS の 5.1 で明らかに) バージョンごと。 `uuid`は信頼性の高い値ではありません。
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
`uuid`のために Windows Phone 7 には、権限が必要です `ID_CAP_IDENTITY_DEVICE` 。 Microsoft はすぐにこのプロパティを廃止して可能性があります。 機能が利用できない場合、アプリケーションはデバイスへのアプリケーションのインストールの持続期間のために保持されている永続的な guid を生成します。
|
||||
|
||||
## device.version
|
||||
|
||||
オペレーティング システムのバージョンを取得します。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド 2.1 +
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
このプラグインをグローバル定義します `device` オブジェクトは、デバイスのハードウェアとソフトウェアについて説明します。 それは後まで利用可能なオブジェクトがグローバル スコープでは、 `deviceready` イベント。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## インストール
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## プロパティ
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
デバイスで実行されているコルドバのバージョンを取得します。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アマゾン火 OS
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`、デバイスのモデルまたは製品の名前を返します。値は、デバイスの製造元によって設定され、同じ製品のバージョン間で異なる可能性があります。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models を参照してください//var モデル = device.model;
|
||||
|
||||
|
||||
### Android の癖
|
||||
|
||||
* 生産コード名は[モデル名][1]の代わりに[製品名][2]を取得します。 たとえば、ネクサス 1 つを返します `Passion` 、Motorola のドロイドを返します`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
|
||||
### Tizen の癖
|
||||
|
||||
* たとえば、ベンダーによって割り当てられているデバイスのモデルを返します`TIZEN`
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
* 製造元によって指定されたデバイスのモデルを返します。たとえば、三星フォーカスを返します`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
デバイスのオペレーティング システム名を取得します。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* Browser4
|
||||
* Firefox の OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 の癖
|
||||
|
||||
Windows Phone 7 デバイスとプラットフォームを報告します。`WinCE`.
|
||||
|
||||
### Windows Phone 8 癖
|
||||
|
||||
Windows Phone 8 デバイスとプラットフォームを報告します。`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
デバイスのユニバーサル ・ ユニーク識別子 ([UUID][3]を取得します。).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 説明
|
||||
|
||||
UUID を生成する方法の詳細は、デバイスの製造元によって決定され、デバイスのプラットフォームやモデルに固有です。
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
//アンドロイド: ランダムな 64 ビットの整数 (を文字列として返します、再び !)/デバイスの最初の起動時に生成される整数/////ブラックベリー: デバイスのピン番号を返します//これは 9 桁の一意な整数 (を文字列としても !)////iPhone: (UIDevice クラスのドキュメントから言い換え)//識別複数のハードウェアから作成されたハッシュ値の文字列を返します。。
|
||||
//それはすべてのデバイスに対して一意であることが保証され、接続することはできません//ユーザー アカウント。
|
||||
//Windows Phone 7: デバイス + 現在のユーザーのハッシュを返します//ユーザーが定義されていない場合 guid が生成され、アプリがアンインストールされるまで保持されます//Tizen: デバイスの IMEI を返します (国際モバイル機器アイデンティティまたは IMEI は番号です//すべての GSM および UMTS の携帯電話に固有です。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS の気まぐれ
|
||||
|
||||
`uuid`IOS で、デバイスに固有ではないインストールごと、アプリケーションごとに異なります。 削除、アプリを再インストールした場合に変更と多分またときアップグレード iOS の, またはもアップグレードするアプリ (iOS の 5.1 で明らかに) バージョンごと。 `uuid`は信頼性の高い値ではありません。
|
||||
|
||||
### Windows Phone 7 と 8 癖
|
||||
|
||||
`uuid`のために Windows Phone 7 には、権限が必要です `ID_CAP_IDENTITY_DEVICE` 。 Microsoft はすぐにこのプロパティを廃止して可能性があります。 機能が利用できない場合、アプリケーションはデバイスへのアプリケーションのインストールの持続期間のために保持されている永続的な guid を生成します。
|
||||
|
||||
## device.version
|
||||
|
||||
オペレーティング システムのバージョンを取得します。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### サポートされているプラットフォーム
|
||||
|
||||
* アンドロイド 2.1 +
|
||||
* ブラックベリー 10
|
||||
* ブラウザー
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
### 簡単な例
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
이 플러그인 정의 전역 `device` 개체, 디바이스의 하드웨어 및 소프트웨어에 설명 합니다. 개체는 전역 범위에서 비록 그것은 후까지 사용할 수 있는 `deviceready` 이벤트.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 설치
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 속성
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
코르도바는 장치에서 실행 중인 버전을 얻을.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 아마존 화재 운영 체제
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`소자의 모델 또는 제품의 이름을 반환 합니다. 값 장치 제조업체에서 설정 되 고 동일 제품의 버전 간에 다를 수 있습니다.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models 참조 / / var 모델 = device.model;
|
||||
|
||||
|
||||
### 안 드 로이드 단점
|
||||
|
||||
* 어떤은 종종 프로덕션 코드 이름 대신 [제품 모델 이름](http://developer.android.com/reference/android/os/Build.html#MODEL), [제품 이름](http://developer.android.com/reference/android/os/Build.html#PRODUCT) 을 가져옵니다. 예를 들어 넥서스 하나 반환 합니다 `Passion` , 모토로라 Droid를 반환 합니다`voles`.
|
||||
|
||||
### Tizen 특수
|
||||
|
||||
* 예를 들어, 공급 업체에 의해 할당 된 디바이스 모델을 반환 합니다.`TIZEN`
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
* 제조업체에서 지정 하는 장치 모델을 반환 합니다. 예를 들어 삼성 포커스를 반환 합니다.`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
장치의 운영 체제 이름을 얻을.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* Browser4
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 단점
|
||||
|
||||
Windows Phone 7 장치 보고 플랫폼으로`WinCE`.
|
||||
|
||||
### Windows Phone 8 단점
|
||||
|
||||
Windows Phone 8 장치 보고 플랫폼으로`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
소자의 보편적으로 고유 식별자 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier) 를 얻을합니다).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 설명
|
||||
|
||||
UUID 생성 방법의 자세한 내용은 장치 제조업체에 의해 결정 됩니다 및 소자의 플랫폼 이나 모델.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
/ / 안 드 로이드: (문자열로 다시!) 임의의 64 비트 정수를 반환 합니다 / / 정수 장치의 첫 번째 부팅에서 생성 / / / / 블랙베리: 디바이스의 핀 번호를 반환 합니다 / / 이것은 9 자리 고유 정수 (문자열로 비록!) / / / / 아이폰: (UIDevice 클래스 설명서에서 읊 었) / / 문자열 여러 하드웨어에서 생성 하는 해시 값을 식별 하는 반환 합니다.
|
||||
/ 그것은 모든 장치에 대 한 고유 해야 보장 되 고 묶일 수 없습니다 / / / 사용자 계정에.
|
||||
/ / Windows Phone 7: 장치 + 현재 사용자의 해시를 반환 합니다 / / 사용자 정의 되지 않은 경우 guid 생성 되 고 응용 프로그램을 제거할 때까지 유지 됩니다 / / Tizen: 반환 장치 IMEI (국제 모바일 기기 식별 또는 IMEI 숫자입니다 / / 모든 GSM와 UMTS 휴대 전화 고유.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 특질
|
||||
|
||||
`uuid`ios 장치에 고유 하지 않습니다 하지만 각 설치에 대 한 응용 프로그램 마다 다릅니다. 삭제 하 고 다시 애플 리 케이 션을 설치 하는 경우 변경 가능 하 게 또한 iOS를 업그레이드 하거나 때 버전 (iOS 5.1에에서 명백한) 당 응용 프로그램 업그레이드도 하 고. `uuid`은 신뢰할 수 있는 값이 아닙니다.
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
`uuid`Windows Phone 7 필요 허가 `ID_CAP_IDENTITY_DEVICE` . Microsoft는 곧이 속성을 세웁니다 가능성이 것입니다. 기능을 사용할 수 없는 경우 응용 프로그램 장치에 응용 프로그램의 설치 하는 동안 유지 하는 영구 guid를 생성 합니다.
|
||||
|
||||
## device.version
|
||||
|
||||
운영 체제 버전을 얻을.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드 2.1 +
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
이 플러그인 정의 전역 `device` 개체, 디바이스의 하드웨어 및 소프트웨어에 설명 합니다. 개체는 전역 범위에서 비록 그것은 후까지 사용할 수 있는 `deviceready` 이벤트.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 설치
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 속성
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
코르도바는 장치에서 실행 중인 버전을 얻을.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 아마존 화재 운영 체제
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`소자의 모델 또는 제품의 이름을 반환 합니다. 값 장치 제조업체에서 설정 되 고 동일 제품의 버전 간에 다를 수 있습니다.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Http://theiphonewiki.com/wiki/index.php?title=Models 참조 / / var 모델 = device.model;
|
||||
|
||||
|
||||
### 안 드 로이드 단점
|
||||
|
||||
* 어떤은 종종 프로덕션 코드 이름 대신 [제품 모델 이름][1], [제품 이름][2] 을 가져옵니다. 예를 들어 넥서스 하나 반환 합니다 `Passion` , 모토로라 Droid를 반환 합니다`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
|
||||
### Tizen 특수
|
||||
|
||||
* 예를 들어, 공급 업체에 의해 할당 된 디바이스 모델을 반환 합니다.`TIZEN`
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
* 제조업체에서 지정 하는 장치 모델을 반환 합니다. 예를 들어 삼성 포커스를 반환 합니다.`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
장치의 운영 체제 이름을 얻을.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* Browser4
|
||||
* Firefox 운영 체제
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 단점
|
||||
|
||||
Windows Phone 7 장치 보고 플랫폼으로`WinCE`.
|
||||
|
||||
### Windows Phone 8 단점
|
||||
|
||||
Windows Phone 8 장치 보고 플랫폼으로`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
소자의 보편적으로 고유 식별자 ([UUID][3] 를 얻을합니다).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 설명
|
||||
|
||||
UUID 생성 방법의 자세한 내용은 장치 제조업체에 의해 결정 됩니다 및 소자의 플랫폼 이나 모델.
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
/ / 안 드 로이드: (문자열로 다시!) 임의의 64 비트 정수를 반환 합니다 / / 정수 장치의 첫 번째 부팅에서 생성 / / / / 블랙베리: 디바이스의 핀 번호를 반환 합니다 / / 이것은 9 자리 고유 정수 (문자열로 비록!) / / / / 아이폰: (UIDevice 클래스 설명서에서 읊 었) / / 문자열 여러 하드웨어에서 생성 하는 해시 값을 식별 하는 반환 합니다.
|
||||
/ 그것은 모든 장치에 대 한 고유 해야 보장 되 고 묶일 수 없습니다 / / / 사용자 계정에.
|
||||
/ / Windows Phone 7: 장치 + 현재 사용자의 해시를 반환 합니다 / / 사용자 정의 되지 않은 경우 guid 생성 되 고 응용 프로그램을 제거할 때까지 유지 됩니다 / / Tizen: 반환 장치 IMEI (국제 모바일 기기 식별 또는 IMEI 숫자입니다 / / 모든 GSM와 UMTS 휴대 전화 고유.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 특질
|
||||
|
||||
`uuid`ios 장치에 고유 하지 않습니다 하지만 각 설치에 대 한 응용 프로그램 마다 다릅니다. 삭제 하 고 다시 애플 리 케이 션을 설치 하는 경우 변경 가능 하 게 또한 iOS를 업그레이드 하거나 때 버전 (iOS 5.1에에서 명백한) 당 응용 프로그램 업그레이드도 하 고. `uuid`은 신뢰할 수 있는 값이 아닙니다.
|
||||
|
||||
### Windows Phone 7, 8 특수
|
||||
|
||||
`uuid`Windows Phone 7 필요 허가 `ID_CAP_IDENTITY_DEVICE` . Microsoft는 곧이 속성을 세웁니다 가능성이 것입니다. 기능을 사용할 수 없는 경우 응용 프로그램 장치에 응용 프로그램의 설치 하는 동안 유지 하는 영구 guid를 생성 합니다.
|
||||
|
||||
## device.version
|
||||
|
||||
운영 체제 버전을 얻을.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 지원 되는 플랫폼
|
||||
|
||||
* 안 드 로이드 2.1 +
|
||||
* 블랙베리 10
|
||||
* 브라우저
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
### 빠른 예제
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,214 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
Ten plugin określa globalne `device` obiekt, który opisuje urządzenia sprzętowe i programowe. Mimo, że obiekt jest w globalnym zasięgu, nie jest dostępne dopiero po `deviceready` zdarzenie.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalacja
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Właściwości
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Pobierz wersję Cordova działa na urządzeniu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`Zwraca nazwę modelu lub produktu. Wartość jest zestaw przez producenta urządzenia i mogą się różnić między wersjami tego samego produktu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Zobacz http://theiphonewiki.com/wiki/index.php?title=Models / / modelu var = device.model;
|
||||
|
||||
|
||||
### Dziwactwa Androida
|
||||
|
||||
* Pobiera [nazwę produktu](http://developer.android.com/reference/android/os/Build.html#PRODUCT) zamiast [nazwy modelu](http://developer.android.com/reference/android/os/Build.html#MODEL), który często jest nazwą kod produkcji. Na przykład, Nexus One zwraca `Passion` , i zwraca Motorola Droid`voles`.
|
||||
|
||||
### Dziwactwa Tizen
|
||||
|
||||
* Zwraca modelu urządzenia przypisane przez dostawcę, na przykład,`TIZEN`
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
* Zwraca modelu urządzenia, określonej przez producenta. Na przykład Samsung ostrości zwraca`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Uzyskać nazwę systemu operacyjnego urządzenia.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Dziwactwa Windows Phone 7
|
||||
|
||||
Urządzenia Windows Phone 7 raport platformy jako`WinCE`.
|
||||
|
||||
### Windows Phone 8 dziwactwa
|
||||
|
||||
Urządzenia Windows Phone 8 raport platformy jako`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Się urządzenia uniwersalnie unikatowy identyfikator ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Opis
|
||||
|
||||
Szczegóły jak UUID jest generowane są określane przez producenta urządzenia i są specyficzne dla platformy lub modelu urządzenia.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Returns a random 64-bit integer (as a string, again!)
|
||||
// The integer is generated on the device's first boot
|
||||
//
|
||||
// BlackBerry: Returns the PIN number of the device
|
||||
// This is a nine-digit unique integer (as a string, though!)
|
||||
//
|
||||
// iPhone: (Paraphrased from the UIDevice Class documentation)
|
||||
// Returns a string of hash values created from multiple hardware identifies.
|
||||
// It is guaranteed to be unique for every device and can't be tied
|
||||
// to the user account.
|
||||
// Windows Phone 7 : Returns a hash of device+current user,
|
||||
// if the user is not defined, a guid is generated and will persist until the app is uninstalled
|
||||
// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number
|
||||
// unique to every GSM and UMTS mobile phone.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS dziwactwo
|
||||
|
||||
`uuid`Na iOS nie jest przypisany do urządzenia, ale różni się dla każdej aplikacji, dla każdej instalacji. Zmienia się jeśli możesz usunąć i ponownie zainstalować aplikację, a ewentualnie także po aktualizacji iOS czy nawet uaktualnienia aplikacji dla wersji (widoczny w iOS 5.1). `uuid`Jest nie wiarygodne wartości.
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
`uuid`Dla Windows Phone 7 wymaga uprawnień `ID_CAP_IDENTITY_DEVICE` . Microsoft będzie prawdopodobnie potępiać ten wkrótce. Jeśli funkcja nie jest dostępna, aplikacja generuje trwałe identyfikator guid, który jest utrzymywany przez czas trwania instalacji aplikacji na urządzeniu.
|
||||
|
||||
## device.version
|
||||
|
||||
Pobierz wersję systemu operacyjnego.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Ten plugin określa globalne `device` obiekt, który opisuje urządzenia sprzętowe i programowe. Mimo, że obiekt jest w globalnym zasięgu, nie jest dostępne dopiero po `deviceready` zdarzenie.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Instalacja
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Właściwości
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Pobierz wersję Cordova działa na urządzeniu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`Zwraca nazwę modelu lub produktu. Wartość jest zestaw przez producenta urządzenia i mogą się różnić między wersjami tego samego produktu.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. Zobacz http://theiphonewiki.com/wiki/index.php?title=Models / / modelu var = device.model;
|
||||
|
||||
|
||||
### Dziwactwa Androida
|
||||
|
||||
* Pobiera [nazwę produktu][1] zamiast [nazwy modelu][2], który często jest nazwą kod produkcji. Na przykład, Nexus One zwraca `Passion` , i zwraca Motorola Droid`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Dziwactwa Tizen
|
||||
|
||||
* Zwraca modelu urządzenia przypisane przez dostawcę, na przykład,`TIZEN`
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
* Zwraca modelu urządzenia, określonej przez producenta. Na przykład Samsung ostrości zwraca`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Uzyskać nazwę systemu operacyjnego urządzenia.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Browser4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Dziwactwa Windows Phone 7
|
||||
|
||||
Urządzenia Windows Phone 7 raport platformy jako`WinCE`.
|
||||
|
||||
### Windows Phone 8 dziwactwa
|
||||
|
||||
Urządzenia Windows Phone 8 raport platformy jako`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Się urządzenia uniwersalnie unikatowy identyfikator ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Opis
|
||||
|
||||
Szczegóły jak UUID jest generowane są określane przez producenta urządzenia i są specyficzne dla platformy lub modelu urządzenia.
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
/ / Android: zwraca losowe 64-bitowa liczba całkowita (jako ciąg, znowu!) / / liczba całkowita jest generowany na pierwszego uruchomienia urządzenia / / / / BlackBerry: zwraca numer PIN urządzenia / / to jest unikatową liczbą całkowitą dziewięciu cyfr (jako ciąg, choć!) / / / / iPhone: (zacytowana w dokumentacji klasy UIDevice) / / zwraca ciąg wartości mieszania utworzone z wielu sprzętu identyfikuje.
|
||||
Zapewniona jest unikatowy dla każdego urządzenia i nie może być związane z / do konta użytkownika.
|
||||
/ / Windows Phone 7: zwraca wartość mieszania urządzenia + bieżący użytkownik, / / jeśli nie zdefiniowane przez użytkownika, identyfikator guid jest generowany i będzie trwać do czasu odinstalowania aplikacji / / Tizen: zwraca urządzenia IMEI (International Mobile Equipment Identity lub IMEI jest liczbą / / unikatowe dla każdego telefonu komórkowego GSM i UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS dziwactwo
|
||||
|
||||
`uuid`Na iOS nie jest przypisany do urządzenia, ale różni się dla każdej aplikacji, dla każdej instalacji. Zmienia się jeśli możesz usunąć i ponownie zainstalować aplikację, a ewentualnie także po aktualizacji iOS czy nawet uaktualnienia aplikacji dla wersji (widoczny w iOS 5.1). `uuid`Jest nie wiarygodne wartości.
|
||||
|
||||
### Windows Phone 7 i 8 dziwactwa
|
||||
|
||||
`uuid`Dla Windows Phone 7 wymaga uprawnień `ID_CAP_IDENTITY_DEVICE` . Microsoft będzie prawdopodobnie potępiać ten wkrótce. Jeśli funkcja nie jest dostępna, aplikacja generuje trwałe identyfikator guid, który jest utrzymywany przez czas trwania instalacji aplikacji na urządzeniu.
|
||||
|
||||
## device.version
|
||||
|
||||
Pobierz wersję systemu operacyjnego.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Obsługiwane platformy
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Przeglądarka
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
### Szybki przykład
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,219 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
Этот плагин определяет глобальный объект `device`, который описывает оборудование и программное обеспечение устройства. Несмотря на то что объект в глобальной области видимости, он не доступен до того момента пока не произойдет событие `deviceready`.
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## Установка
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## Параметры
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
Возвращает версию Cordova, работающую на устройстве.
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Обозреватель
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
Свойство `device.model` возвращает имя устройства модели или продукта. Значение устанавливается производителем устройства и могут отличаться в разных версиях одного и того же продукта.
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Обозреватель
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models
|
||||
//
|
||||
var model = device.model;
|
||||
|
||||
|
||||
### Особенности Android
|
||||
|
||||
* Возвращает [имя продукта][1] , а не [имя модели][2], которое часто является производственным кодом. Например, Nexus One из них возвращает `Passion` , и Motorola Droid возвращает `voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Особенности Tizen
|
||||
|
||||
* Возвращает модель устройства, назначенного вендором, например,`TIZEN`
|
||||
|
||||
### Особенности Windows Phone 7 и 8
|
||||
|
||||
* Возвращает модель устройства, указанной заводом-изготовителем. Например Samsung Focus возвращает `SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
Получите имя операционной системы устройства.
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* Браузером4
|
||||
* Firefox OS
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Особенности Windows Phone 7
|
||||
|
||||
Windows Phone 7 устройства сообщают платформу как `WinCE`.
|
||||
|
||||
### Особенности Windows Phone 8
|
||||
|
||||
Устройства Windows Phone 8 сообщают платформу как `Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
Возвращает универсальный уникального идентификатора ([UUID][3] устройства).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### Описание
|
||||
|
||||
Подробная информация о том как UUID генерируется, определяются изготовителем устройства и являются специфическими для платформы или модели устройства.
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// Android: Возвращает случайное 64-разрядное целое число (в виде строки, опять!)
|
||||
// целое число генерируется при первой загрузке устройства
|
||||
//
|
||||
// BlackBerry: Возвращает номер PIN устройства
|
||||
// это 9 значный уникальный целочисленный (как строка, хотя!)
|
||||
//
|
||||
// iPhone: (Перефразировано из документации класса UIDevice)
|
||||
// возвращает строку хэш-значения, созданные из нескольких аппаратных определяет.
|
||||
// Это значение гарантированно является уникальным для каждого устройства и не может быть привязано
|
||||
// к учетной записи пользователя.
|
||||
// Windows Phone 7: Возвращает хэш устройство + текущего пользователя,
|
||||
// если пользователь не определен, формируется guid который и будет сохраняться до тех пор, пока приложение не удалиться
|
||||
// Tizen: возвращает IMEI устройства (Международный идентификатор мобильного оборудования или IMEI это число
|
||||
// уникальное для каждого мобильного телефона GSM и UMTS.
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### Особенности iOS
|
||||
|
||||
На iOS `uuid` не является уникальным для устройства, но варьируется для каждого приложения, и для каждой установки. Значение меняется, если удалить и повторно установить приложение, и возможно также когда вы обновите iOS, или даже обновить приложение до следующей версии (очевидно в iOS 5.1). Значение `uuid` не является надежным.
|
||||
|
||||
### Особенности Windows Phone 7 и 8
|
||||
|
||||
Для Windows Phone 7 `uuid` требует разрешения `ID_CAP_IDENTITY_DEVICE` . Microsoft скорее всего скоро сделает это свойство устаревшим. Если возможность недоступна, приложение создает постоянные guid, который сохраняется на все время установки приложения на устройстве.
|
||||
|
||||
## device.version
|
||||
|
||||
Возвращает версию операционной системы.
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### Поддерживаемые платформы
|
||||
|
||||
* Android 2.1 +
|
||||
* BlackBerry 10
|
||||
* Обозреватель
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 и 8
|
||||
* Windows 8
|
||||
|
||||
### Краткий пример
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,203 @@
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-device)
|
||||
|
||||
這個外掛程式定義全球 `device` 物件,描述該設備的硬體和軟體。 雖然物件是在全球範圍內,但不是可用,直到後 `deviceready` 事件。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 安裝
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 屬性
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
獲取科爾多瓦在設備上運行的版本。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* 亞馬遜火 OS
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* 火狐瀏覽器作業系統
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`返回設備的模型或產品的名稱。值由設備製造商設置和同一產品的不同版本可能不同。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. 請參閱 HTTP://theiphonewiki.com/wiki/index.php?title=Models / / var 模型 = device.model ;
|
||||
|
||||
|
||||
### Android 的怪癖
|
||||
|
||||
* 獲取[產品名稱](http://developer.android.com/reference/android/os/Build.html#PRODUCT)而不是[產品型號名稱](http://developer.android.com/reference/android/os/Build.html#MODEL),這往往是生產代碼名稱。 例如,Nexus One 返回 `Passion` ,和摩托羅拉 Droid 返回`voles`.
|
||||
|
||||
### Tizen 怪癖
|
||||
|
||||
* 例如,返回與供應商指派的設備模型`TIZEN`
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
* 返回由製造商指定的設備模型。例如,三星焦點返回`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
獲取設備的作業系統名稱。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* Browser4
|
||||
* 火狐瀏覽器作業系統
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 的怪癖
|
||||
|
||||
Windows Phone 7 設備報告作為平臺`WinCE`.
|
||||
|
||||
### Windows Phone 8 怪癖
|
||||
|
||||
Windows Phone 8 設備報告作為平臺`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
獲取設備的通用唯一識別碼 ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)).
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 說明
|
||||
|
||||
如何生成一個 UUID 的細節由設備製造商和特定于設備的平臺或模型。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
/ / Android: 一個隨機的 64 位整數 (作為字串返回,再次!) / / 上設備的第一次啟動生成的整數 / / / / 黑莓手機: 返回設備的 PIN 號碼 / / 這是九個數字的唯一整數 (作為字串,雖然!) / / / / iPhone: (從 UIDevice 類文檔解釋) / / 返回一個字串的雜湊值創建的多個硬體標識。
|
||||
/ / 它保證是唯一的每個設備並不能綁 / / 到使用者帳戶。
|
||||
/ / Windows Phone 7: 返回的雜湊代碼的設備 + 當前使用者,/ / 如果未定義使用者,則一個 guid 生成的並且將會保留直到卸載該應用程式 / / Tizen: 返回設備 IMEI (國際行動裝置身份或 IMEI 是一個數位 / / 獨有的每一個 UMTS 和 GSM 行動電話。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 怪癖
|
||||
|
||||
`uuid`在 iOS 不是唯一的一種裝置,但對於每個應用程式,為每個安裝而異。 如果您刪除並重新安裝該應用程式,它更改和可能還當你升級 iOS,或甚至升級每個版本 (iOS 5.1 中存在明顯的) 的應用程式。 `uuid`不是一個可靠的值。
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
`uuid`為 Windows Phone 7 須經許可 `ID_CAP_IDENTITY_DEVICE` 。 Microsoft 可能會很快棄用此屬性。 如果沒有可用的能力,應用程式將生成設備上應用程式的安裝過程中保持持續的 guid。
|
||||
|
||||
## device.version
|
||||
|
||||
獲取作業系統版本。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 2.1 +
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,206 @@
|
||||
<!---
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# cordova-plugin-device
|
||||
|
||||
這個外掛程式定義全球 `device` 物件,描述該設備的硬體和軟體。 雖然物件是在全球範圍內,但不是可用,直到後 `deviceready` 事件。
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
console.log(device.cordova);
|
||||
}
|
||||
|
||||
|
||||
## 安裝
|
||||
|
||||
cordova plugin add cordova-plugin-device
|
||||
|
||||
|
||||
## 屬性
|
||||
|
||||
* device.cordova
|
||||
* device.model
|
||||
* device.platform
|
||||
* device.uuid
|
||||
* device.version
|
||||
|
||||
## device.cordova
|
||||
|
||||
獲取科爾多瓦在設備上運行的版本。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* 亞馬遜火 OS
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* 火狐瀏覽器的作業系統
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
## device.model
|
||||
|
||||
`device.model`返回設備的模型或產品的名稱。值由設備製造商設置和同一產品的不同版本可能不同。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Android: Nexus One returns "Passion" (Nexus One code name)
|
||||
// Motorola Droid returns "voles"
|
||||
// BlackBerry: Torch 9800 returns "9800"
|
||||
// Browser: Google Chrome returns "Chrome"
|
||||
// Safari returns "Safari"
|
||||
// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. 請參閱 HTTP://theiphonewiki.com/wiki/index.php?title=Models / / var 模型 = device.model ;
|
||||
|
||||
|
||||
### Android 的怪癖
|
||||
|
||||
* 獲取[產品名稱][1]而不是[產品型號名稱][2],這往往是生產代碼名稱。 例如,Nexus One 返回 `Passion` ,和摩托羅拉 Droid 返回`voles`.
|
||||
|
||||
[1]: http://developer.android.com/reference/android/os/Build.html#PRODUCT
|
||||
[2]: http://developer.android.com/reference/android/os/Build.html#MODEL
|
||||
|
||||
### Tizen 怪癖
|
||||
|
||||
* 例如,返回與供應商指派的設備模型`TIZEN`
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
* 返回由製造商指定的設備模型。例如,三星焦點返回`SGH-i917`.
|
||||
|
||||
## device.platform
|
||||
|
||||
獲取設備的作業系統名稱。
|
||||
|
||||
var string = device.platform;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* Browser4
|
||||
* 火狐瀏覽器的作業系統
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Depending on the device, a few examples are:
|
||||
// - "Android"
|
||||
// - "BlackBerry 10"
|
||||
// - Browser: returns "MacIntel" on Mac
|
||||
// returns "Win32" on Windows
|
||||
// - "iOS"
|
||||
// - "WinCE"
|
||||
// - "Tizen"
|
||||
var devicePlatform = device.platform;
|
||||
|
||||
|
||||
### Windows Phone 7 的怪癖
|
||||
|
||||
Windows Phone 7 設備報告作為平臺`WinCE`.
|
||||
|
||||
### Windows Phone 8 怪癖
|
||||
|
||||
Windows Phone 8 設備報告作為平臺`Win32NT`.
|
||||
|
||||
## device.uuid
|
||||
|
||||
獲取設備的通用唯一識別碼 ([UUID][3]).
|
||||
|
||||
[3]: http://en.wikipedia.org/wiki/Universally_Unique_Identifier
|
||||
|
||||
var string = device.uuid;
|
||||
|
||||
|
||||
### 說明
|
||||
|
||||
如何生成一個 UUID 的細節由設備製造商和特定于設備的平臺或模型。
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 系統
|
||||
* 黑莓 10
|
||||
* iOS
|
||||
* Tizen
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
/ / Android: 一個隨機的 64 位整數 (作為字串返回,再次!) / / 上設備的第一次啟動生成的整數 / / / / 黑莓手機: 返回設備的 PIN 號碼 / / 這是九個數字的唯一整數 (作為字串,雖然!) / / / / iPhone: (從 UIDevice 類文檔解釋) / / 返回一個字串的雜湊值創建的多個硬體標識。
|
||||
/ / 它保證是唯一的每個設備並不能綁 / / 到使用者帳戶。
|
||||
/ / Windows Phone 7: 返回的雜湊代碼的設備 + 當前使用者,/ / 如果未定義使用者,則一個 guid 生成的並且將會保留直到卸載該應用程式 / / Tizen: 返回設備 IMEI (國際行動裝置身份或 IMEI 是一個數位 / / 獨有的每一個 UMTS 和 GSM 行動電話。
|
||||
var deviceID = device.uuid;
|
||||
|
||||
|
||||
### iOS 怪癖
|
||||
|
||||
`uuid`在 iOS 不是唯一的一種裝置,但對於每個應用程式,為每個安裝而異。 如果您刪除並重新安裝該應用程式,它更改和可能還當你升級 iOS,或甚至升級每個版本 (iOS 5.1 中存在明顯的) 的應用程式。 `uuid`不是一個可靠的值。
|
||||
|
||||
### Windows Phone 7 和 8 怪癖
|
||||
|
||||
`uuid`為 Windows Phone 7 須經許可 `ID_CAP_IDENTITY_DEVICE` 。 Microsoft 可能會很快棄用此屬性。 如果沒有可用的能力,應用程式將生成設備上應用程式的安裝過程中保持持續的 guid。
|
||||
|
||||
## device.version
|
||||
|
||||
獲取作業系統版本。
|
||||
|
||||
var string = device.version;
|
||||
|
||||
|
||||
### 支援的平臺
|
||||
|
||||
* Android 2.1 +
|
||||
* 黑莓 10
|
||||
* 瀏覽器
|
||||
* iOS
|
||||
* 泰
|
||||
* Windows Phone 7 和 8
|
||||
* Windows 8
|
||||
|
||||
### 快速的示例
|
||||
|
||||
// Android: Froyo OS would return "2.2"
|
||||
// Eclair OS would return "2.1", "2.0.1", or "2.0"
|
||||
// Version can also return update level "2.1-update1"
|
||||
//
|
||||
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
|
||||
//
|
||||
// Browser: Returns version number for the browser
|
||||
//
|
||||
// iPhone: iOS 3.2 returns "3.2"
|
||||
//
|
||||
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
|
||||
// Tizen: returns "TIZEN_20120425_2"
|
||||
var deviceVersion = device.version;
|
||||
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"_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": "version",
|
||||
"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": [
|
||||
"#DEV:/",
|
||||
"#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/saherelm/Documents/My Projects/xFrameworkTest",
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?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>
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
package org.apache.cordova.device;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.provider.Settings;
|
||||
|
||||
public class Device extends CordovaPlugin {
|
||||
public static final String TAG = "Device";
|
||||
|
||||
public static String platform; // Device OS
|
||||
public static String uuid; // Device UUID
|
||||
|
||||
private static final String ANDROID_PLATFORM = "Android";
|
||||
private static final String AMAZON_PLATFORM = "amazon-fireos";
|
||||
private static final String AMAZON_DEVICE = "Amazon";
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Device() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context of the Command. This can then be used to do things like
|
||||
* get file paths associated with the Activity.
|
||||
*
|
||||
* @param cordova The context of the main Activity.
|
||||
* @param webView The CordovaWebView Cordova is running in.
|
||||
*/
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
Device.uuid = getUuid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackContext The callback id used when calling back into JavaScript.
|
||||
* @return True if the action was valid, false if not.
|
||||
*/
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
if ("getDeviceInfo".equals(action)) {
|
||||
JSONObject r = new JSONObject();
|
||||
r.put("uuid", Device.uuid);
|
||||
r.put("version", this.getOSVersion());
|
||||
r.put("platform", this.getPlatform());
|
||||
r.put("model", this.getModel());
|
||||
r.put("manufacturer", this.getManufacturer());
|
||||
r.put("isVirtual", this.isVirtual());
|
||||
r.put("serial", this.getSerialNumber());
|
||||
callbackContext.success(r);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// LOCAL METHODS
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get the OS name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPlatform() {
|
||||
String platform;
|
||||
if (isAmazonDevice()) {
|
||||
platform = AMAZON_PLATFORM;
|
||||
} else {
|
||||
platform = ANDROID_PLATFORM;
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device's Universally Unique Identifier (UUID).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getUuid() {
|
||||
String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
String model = android.os.Build.MODEL;
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
String productname = android.os.Build.PRODUCT;
|
||||
return productname;
|
||||
}
|
||||
|
||||
public String getManufacturer() {
|
||||
String manufacturer = android.os.Build.MANUFACTURER;
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
public String getSerialNumber() {
|
||||
String serial = android.os.Build.SERIAL;
|
||||
return serial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the OS version.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getOSVersion() {
|
||||
String osversion = android.os.Build.VERSION.RELEASE;
|
||||
return osversion;
|
||||
}
|
||||
|
||||
public String getSDKVersion() {
|
||||
@SuppressWarnings("deprecation")
|
||||
String sdkversion = android.os.Build.VERSION.SDK;
|
||||
return sdkversion;
|
||||
}
|
||||
|
||||
public String getTimeZoneID() {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
return (tz.getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to check if the device is manufactured by Amazon
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isAmazonDevice() {
|
||||
if (android.os.Build.MANUFACTURER.equals(AMAZON_DEVICE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVirtual() {
|
||||
return android.os.Build.FINGERPRINT.contains("generic") ||
|
||||
android.os.Build.PRODUCT.contains("sdk");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
*
|
||||
* 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);
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
|
||||
@interface CDVDevice : CDVPlugin
|
||||
{}
|
||||
|
||||
+ (NSString*)cordovaVersion;
|
||||
|
||||
- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
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
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
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
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/* 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);
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:rim="http://www.blackberry.com/ns/widgets"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cordova-plugin-device-tests"
|
||||
version="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
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
*
|
||||
* 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
@@ -0,0 +1,36 @@
|
||||
// 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;
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var channel = require('cordova/channel');
|
||||
var utils = require('cordova/utils');
|
||||
var exec = require('cordova/exec');
|
||||
var cordova = require('cordova');
|
||||
|
||||
channel.createSticky('onCordovaInfoReady');
|
||||
// Tell cordova channel to wait on the CordovaInfoReady event
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device () {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
this.model = null;
|
||||
this.manufacturer = null;
|
||||
this.isVirtual = null;
|
||||
this.serial = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
channel.onCordovaReady.subscribe(function () {
|
||||
me.getInfo(function (info) {
|
||||
// ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
|
||||
// TODO: CB-5105 native implementations should not return info.cordova
|
||||
var buildLabel = cordova.version;
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = buildLabel;
|
||||
me.model = info.model;
|
||||
me.isVirtual = info.isVirtual;
|
||||
me.manufacturer = info.manufacturer || 'unknown';
|
||||
me.serial = info.serial || 'unknown';
|
||||
channel.onCordovaInfoReady.fire();
|
||||
}, function (e) {
|
||||
me.available = false;
|
||||
utils.alert('[ERROR] Error initializing Cordova: ' + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function (successCallback, errorCallback) {
|
||||
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
|
||||
exec(successCallback, errorCallback, 'Device', 'getDeviceInfo', []);
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
||||
@@ -0,0 +1,23 @@
|
||||
Copyright 2015-present Drifty Co.
|
||||
http://drifty.com/
|
||||
|
||||
MIT License
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,220 @@
|
||||
# cordova-plugin-ionic-keyboard
|
||||
|
||||
This plugin has been designed to work seamlessly with `cordova-plugin-ionic-webview`, so make sure you have it installed first:
|
||||
|
||||
- https://github.com/ionic-team/cordova-plugin-ionic-webview
|
||||
- https://ionicframework.com/docs/wkwebview/
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
cordova plugin add cordova-plugin-ionic-keyboard --save
|
||||
```
|
||||
|
||||
## Preferences
|
||||
|
||||
### KeyboardResize (for iOS only)
|
||||
|
||||
> Boolean (true by default)
|
||||
|
||||
#### Possible values
|
||||
- `true`: Showing/hiding the keyboard will trigger some kind of resizing of the app (see KeyboardResizeMode)
|
||||
- `false`: Web will not be resized when the keyboard shows up.
|
||||
|
||||
```xml
|
||||
<preference name="KeyboardResize" value="true" />
|
||||
```
|
||||
|
||||
### KeyboardResizeMode (for iOS only)
|
||||
|
||||
> String ('native' by default)
|
||||
|
||||
#### Possible values
|
||||
|
||||
- `native`: The whole native webview will be resized when the keyboard shows/hides, it will affect the `vh` relative unit.
|
||||
- `body`: Only the html `<body>` element will be resized. Relative units are not affected, because the viewport does not change.
|
||||
- `ionic`: Only the html `ion-app` element will be resized. Only for ionic apps.
|
||||
|
||||
```xml
|
||||
<preference name="KeyboardResizeMode" value="native" />
|
||||
```
|
||||
|
||||
### KeyboardStyle (for iOS only)
|
||||
|
||||
> String ('light' by default)
|
||||
|
||||
#### Possible values
|
||||
|
||||
- `light`
|
||||
- `dark`
|
||||
|
||||
```xml
|
||||
<preference name="KeyboardStyle" value="dark" />
|
||||
```
|
||||
|
||||
### HideKeyboardFormAccessoryBar (for iOS only)
|
||||
|
||||
> Boolean (true by default)
|
||||
|
||||
#### Possible values
|
||||
- `true`: hides the keyboard accessory bar.
|
||||
- `false`: shows the keyboard accessory bar.
|
||||
|
||||
```xml
|
||||
<preference name="HideKeyboardFormAccessoryBar" value="false" />
|
||||
```
|
||||
|
||||
### resizeOnFullScreen (for Android only)
|
||||
|
||||
There is an Android bug that prevents the keyboard from resizing the WebView when the app is in full screen (i.e. if StatusBar plugin is used to hide the StatusBar). This setting, if set to true, add a workaround that resizes the WebView even when the app is in full screen.
|
||||
|
||||
> Boolean (false by default)
|
||||
|
||||
#### Possible values
|
||||
- `false`: doesn't resize the WebView when the app is in full screen.
|
||||
- `true`: resizes the WebView when the app is in full screen.
|
||||
|
||||
|
||||
```xml
|
||||
<preference name="resizeOnFullScreen" value="true" />
|
||||
```
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
### Keyboard.hideFormAccessoryBar (for iOS only)
|
||||
|
||||
> Hide the keyboard toolbar.
|
||||
|
||||
Set to true to hide the additional toolbar that is on top of the keyboard. This toolbar features the Prev, Next, and Done buttons.
|
||||
|
||||
```js
|
||||
Keyboard.hideFormAccessoryBar(value, successCallback);
|
||||
```
|
||||
|
||||
#### Quick Example
|
||||
|
||||
```js
|
||||
Keyboard.hideFormAccessoryBar(true);
|
||||
Keyboard.hideFormAccessoryBar(false);
|
||||
Keyboard.hideFormAccessoryBar(null, (currentValue) => { console.log(currentValue); });
|
||||
```
|
||||
|
||||
### Keyboard.hide
|
||||
|
||||
> Hide the keyboard
|
||||
|
||||
Call this method to hide the keyboard
|
||||
|
||||
```js
|
||||
Keyboard.hide();
|
||||
```
|
||||
|
||||
### Keyboard.show (for Android only)
|
||||
|
||||
> Show the keyboard
|
||||
|
||||
Call this method to show the keyboard.
|
||||
|
||||
```js
|
||||
Keyboard.show();
|
||||
```
|
||||
|
||||
### Keyboard.setResizeMode (for iOS only)
|
||||
|
||||
> Programmatically set the resize mode
|
||||
|
||||
Call the method with parameter to set the resize mode.
|
||||
|
||||
```js
|
||||
// Possible values are the same as for 'KeyboardResizeMode' preference
|
||||
Keyboard.setResizeMode('native');
|
||||
Keyboard.setResizeMode('body');
|
||||
Keyboard.setResizeMode('ionic');
|
||||
```
|
||||
|
||||
### Keyboard.setKeyboardStyle (for iOS only)
|
||||
|
||||
> Programmatically set the keyboard style
|
||||
|
||||
```js
|
||||
// Possible values are the same as for 'KeyboardStyle' preference
|
||||
Keyboard.setKeyboardStyle('light'); // <- default
|
||||
Keyboard.setKeyboardStyle('dark');
|
||||
```
|
||||
|
||||
### Keyboard.disableScroll (for iOS only)
|
||||
|
||||
> Programmatically enable or disable the WebView scroll
|
||||
|
||||
```js
|
||||
Keyboard.disableScroll(true); // <- default
|
||||
Keyboard.disableScroll(false);
|
||||
```
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
### Keyboard.isVisible
|
||||
|
||||
> Determine if the keyboard is visible.
|
||||
|
||||
Read this property to determine if the keyboard is visible.
|
||||
|
||||
```js
|
||||
if (Keyboard.isVisible) {
|
||||
// do something
|
||||
}
|
||||
```
|
||||
|
||||
## Events
|
||||
|
||||
### keyboardDidHide
|
||||
|
||||
> This event is fired when the keyboard is fully closed.
|
||||
|
||||
Attach handler to this event to be able to receive notification when keyboard is closed.
|
||||
|
||||
```js
|
||||
window.addEventListener('keyboardDidHide', () => {
|
||||
// Describe your logic which will be run each time keyboard is closed.
|
||||
});
|
||||
```
|
||||
|
||||
### keyboardDidShow
|
||||
|
||||
> This event is fired when the keyboard is fully open.
|
||||
|
||||
Attach handler to this event to be able to receive notification when keyboard is opened.
|
||||
|
||||
```js
|
||||
window.addEventListener('keyboardDidShow', (event) => {
|
||||
// Describe your logic which will be run each time when keyboard is about to be shown.
|
||||
console.log(event.keyboardHeight);
|
||||
});
|
||||
```
|
||||
|
||||
### keyboardWillShow
|
||||
|
||||
> This event fires before keyboard will be shown.
|
||||
|
||||
Attach handler to this event to be able to receive notification when keyboard is about to be shown on the screen.
|
||||
|
||||
```js
|
||||
window.addEventListener('keyboardWillShow', (event) => {
|
||||
// Describe your logic which will be run each time when keyboard is about to be shown.
|
||||
console.log(event.keyboardHeight);
|
||||
});
|
||||
```
|
||||
|
||||
### keyboardWillHide
|
||||
|
||||
> This event fires before keyboard will be closed.
|
||||
|
||||
Attach handler to this event to be able to receive notification when keyboard is about to be closed.
|
||||
|
||||
```js
|
||||
window.addEventListener('keyboardWillHide', () => {
|
||||
// Describe your logic which will be run each time when keyboard is about to be closed.
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"_from": "cordova-plugin-ionic-keyboard@^2.0.5",
|
||||
"_id": "cordova-plugin-ionic-keyboard@2.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-yDUG+9ieKVRitq5mGlNxjaZh/MgEhFFIgTIPhqSbUaQ8UuZbawy5mhJAVClqY97q8/rcQtL6dCDa7x2sEtCLcA==",
|
||||
"_location": "/cordova-plugin-ionic-keyboard",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "cordova-plugin-ionic-keyboard@^2.0.5",
|
||||
"name": "cordova-plugin-ionic-keyboard",
|
||||
"escapedName": "cordova-plugin-ionic-keyboard",
|
||||
"rawSpec": "^2.0.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/",
|
||||
"#USER"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cordova-plugin-ionic-keyboard/-/cordova-plugin-ionic-keyboard-2.2.0.tgz",
|
||||
"_shasum": "53ba9ccd5e765165446a094cfe042a2ddd87d81d",
|
||||
"_spec": "cordova-plugin-ionic-keyboard@^2.0.5",
|
||||
"_where": "/home/saherelm/Documents/My Projects/xFrameworkTest",
|
||||
"author": {
|
||||
"name": "Apache Software Foundation"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ionic-team/cordova-plugin-ionic-keyboard/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Ionic Keyboard Plugin",
|
||||
"devDependencies": {
|
||||
"np": "^5.0.3",
|
||||
"sync-cordova-xml": "^0.4.0"
|
||||
},
|
||||
"homepage": "https://github.com/ionic-team/cordova-plugin-ionic-keyboard#readme",
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"keyboard",
|
||||
"ecosystem:cordova",
|
||||
"cordova-ios",
|
||||
"cordova-android"
|
||||
],
|
||||
"license": "Apache 2.0",
|
||||
"name": "cordova-plugin-ionic-keyboard",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ionic-team/cordova-plugin-ionic-keyboard.git"
|
||||
},
|
||||
"scripts": {
|
||||
"deploy": "np --yolo",
|
||||
"sync_plugin_xml": "sync-cordova-xml package.json plugin.xml --output=plugin.xml",
|
||||
"version": "npm run sync_plugin_xml && git add plugin.xml"
|
||||
},
|
||||
"version": "2.2.0"
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<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-ionic-keyboard" version="2.2.0">
|
||||
<name>cordova-plugin-ionic-keyboard</name>
|
||||
<description>Ionic Keyboard Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
<keywords>cordova,keyboard,ecosystem:cordova,cordova-ios,cordova-android</keywords>
|
||||
<repo>https://github.com/ionic-team/cordova-plugin-ionic-keyboard.git</repo>
|
||||
<issue>https://github.com/ionic-team/cordova-plugin-ionic-keyboard/issues</issue>
|
||||
<author>Apache Software Foundation</author>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.2.0"/>
|
||||
</engines>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
|
||||
<js-module src="www/ios/keyboard.js" name="keyboard">
|
||||
<clobbers target="window.Keyboard"/>
|
||||
</js-module>
|
||||
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="CDVIonicKeyboard">
|
||||
<param name="ios-package" value="CDVIonicKeyboard" onload="true"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<header-file src="src/ios/CDVIonicKeyboard.h"/>
|
||||
<source-file src="src/ios/CDVIonicKeyboard.m"/>
|
||||
</platform>
|
||||
|
||||
<!-- android -->
|
||||
<platform name="android">
|
||||
<js-module src="www/android/keyboard.js" name="keyboard">
|
||||
<clobbers target="window.Keyboard"/>
|
||||
</js-module>
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="CDVIonicKeyboard">
|
||||
<param name="android-package" value="io.ionic.keyboard.CDVIonicKeyboard" onload="true"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/CDVIonicKeyboard.java" target-dir="src/io/ionic/keyboard"/>
|
||||
</platform>
|
||||
|
||||
</plugin>
|
||||
@@ -0,0 +1,165 @@
|
||||
package io.ionic.keyboard;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.apache.cordova.PluginResult.Status;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
// import additionally required classes for calculating screen height
|
||||
import android.view.Display;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class CDVIonicKeyboard extends CordovaPlugin {
|
||||
private OnGlobalLayoutListener list;
|
||||
private View rootView;
|
||||
private View mChildOfContent;
|
||||
private int usableHeightPrevious;
|
||||
private FrameLayout.LayoutParams frameLayoutParams;
|
||||
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
}
|
||||
|
||||
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
|
||||
if ("hide".equals(action)) {
|
||||
cordova.getThreadPool().execute(new Runnable() {
|
||||
public void run() {
|
||||
//http://stackoverflow.com/a/7696791/1091751
|
||||
InputMethodManager inputManager = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
View v = cordova.getActivity().getCurrentFocus();
|
||||
|
||||
if (v == null) {
|
||||
callbackContext.error("No current focus");
|
||||
} else {
|
||||
inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
callbackContext.success(); // Thread-safe.
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if ("show".equals(action)) {
|
||||
cordova.getThreadPool().execute(new Runnable() {
|
||||
public void run() {
|
||||
((InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
callbackContext.success(); // Thread-safe.
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if ("init".equals(action)) {
|
||||
cordova.getThreadPool().execute(new Runnable() {
|
||||
public void run() {
|
||||
//calculate density-independent pixels (dp)
|
||||
//http://developer.android.com/guide/practices/screens_support.html
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
final float density = dm.density;
|
||||
|
||||
//http://stackoverflow.com/a/4737265/1091751 detect if keyboard is showing
|
||||
FrameLayout content = (FrameLayout) cordova.getActivity().findViewById(android.R.id.content);
|
||||
rootView = content.getRootView();
|
||||
list = new OnGlobalLayoutListener() {
|
||||
int previousHeightDiff = 0;
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
boolean resize = preferences.getBoolean("resizeOnFullScreen", false);
|
||||
if (resize) {
|
||||
possiblyResizeChildOfContent();
|
||||
}
|
||||
Rect r = new Rect();
|
||||
//r will be populated with the coordinates of your view that area still visible.
|
||||
rootView.getWindowVisibleDisplayFrame(r);
|
||||
|
||||
PluginResult result;
|
||||
|
||||
// cache properties for later use
|
||||
int rootViewHeight = rootView.getRootView().getHeight();
|
||||
int resultBottom = r.bottom;
|
||||
|
||||
// calculate screen height differently for android versions >= 21: Lollipop 5.x, Marshmallow 6.x
|
||||
//http://stackoverflow.com/a/29257533/3642890 beware of nexus 5
|
||||
int screenHeight;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
display.getSize(size);
|
||||
screenHeight = size.y;
|
||||
} else {
|
||||
screenHeight = rootViewHeight;
|
||||
}
|
||||
|
||||
int heightDiff = screenHeight - resultBottom;
|
||||
|
||||
int pixelHeightDiff = (int)(heightDiff / density);
|
||||
if (pixelHeightDiff > 100 && pixelHeightDiff != previousHeightDiff) { // if more than 100 pixels, its probably a keyboard...
|
||||
String msg = "S" + Integer.toString(pixelHeightDiff);
|
||||
result = new PluginResult(PluginResult.Status.OK, msg);
|
||||
result.setKeepCallback(true);
|
||||
callbackContext.sendPluginResult(result);
|
||||
}
|
||||
else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelHeightDiff ) > 100 ){
|
||||
String msg = "H";
|
||||
result = new PluginResult(PluginResult.Status.OK, msg);
|
||||
result.setKeepCallback(true);
|
||||
callbackContext.sendPluginResult(result);
|
||||
}
|
||||
previousHeightDiff = pixelHeightDiff;
|
||||
}
|
||||
|
||||
private void possiblyResizeChildOfContent() {
|
||||
int usableHeightNow = computeUsableHeight();
|
||||
if (usableHeightNow != usableHeightPrevious) {
|
||||
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
|
||||
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
|
||||
if (heightDifference > (usableHeightSansKeyboard/4)) {
|
||||
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
|
||||
} else {
|
||||
frameLayoutParams.height = usableHeightSansKeyboard;
|
||||
}
|
||||
mChildOfContent.requestLayout();
|
||||
usableHeightPrevious = usableHeightNow;
|
||||
}
|
||||
}
|
||||
|
||||
private int computeUsableHeight() {
|
||||
Rect r = new Rect();
|
||||
mChildOfContent.getWindowVisibleDisplayFrame(r);
|
||||
return (r.bottom - r.top);
|
||||
}
|
||||
};
|
||||
|
||||
mChildOfContent = content.getChildAt(0);
|
||||
rootView.getViewTreeObserver().addOnGlobalLayoutListener(list);
|
||||
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
|
||||
PluginResult dataResult = new PluginResult(PluginResult.Status.OK);
|
||||
dataResult.setKeepCallback(true);
|
||||
callbackContext.sendPluginResult(dataResult);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false; // Returning false results in a "MethodNotFound" error.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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 CDVIonicKeyboard : CDVPlugin
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
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 "CDVIonicKeyboard.h"
|
||||
#import <Cordova/CDVAvailability.h>
|
||||
#import <Cordova/NSDictionary+CordovaPreferences.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
ResizeNone,
|
||||
ResizeNative,
|
||||
ResizeBody,
|
||||
ResizeIonic,
|
||||
} ResizePolicy;
|
||||
|
||||
#ifndef __CORDOVA_3_2_0
|
||||
#warning "The keyboard plugin is only supported in Cordova 3.2 or greater, it may not work properly in an older version. If you do use this plugin in an older version, make sure the HideKeyboardFormAccessoryBar and KeyboardShrinksView preference values are false."
|
||||
#endif
|
||||
|
||||
@interface CDVIonicKeyboard () <UIScrollViewDelegate>
|
||||
|
||||
@property (readwrite, assign, nonatomic) BOOL disableScroll;
|
||||
@property (readwrite, assign, nonatomic) BOOL hideFormAccessoryBar;
|
||||
@property (readwrite, assign, nonatomic) BOOL keyboardIsVisible;
|
||||
@property (nonatomic, readwrite) ResizePolicy keyboardResizes;
|
||||
@property (readwrite, assign, nonatomic) NSString* keyboardStyle;
|
||||
@property (nonatomic, readwrite) BOOL isWK;
|
||||
@property (nonatomic, readwrite) int paddingBottom;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CDVIonicKeyboard
|
||||
|
||||
NSTimer *hideTimer;
|
||||
|
||||
- (id)settingForKey:(NSString *)key
|
||||
{
|
||||
return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
|
||||
}
|
||||
|
||||
#pragma mark Initialize
|
||||
|
||||
NSString* UIClassString;
|
||||
NSString* WKClassString;
|
||||
NSString* UITraitsClassString;
|
||||
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
UIClassString = [@[@"UI", @"Web", @"Browser", @"View"] componentsJoinedByString:@""];
|
||||
WKClassString = [@[@"WK", @"Content", @"View"] componentsJoinedByString:@""];
|
||||
UITraitsClassString = [@[@"UI", @"Text", @"Input", @"Traits"] componentsJoinedByString:@""];
|
||||
|
||||
NSDictionary *settings = self.commandDelegate.settings;
|
||||
|
||||
self.disableScroll = ![settings cordovaBoolSettingForKey:@"ScrollEnabled" defaultValue:NO];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarDidChangeFrame:) name: UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
||||
|
||||
self.keyboardResizes = ResizeNative;
|
||||
BOOL doesResize = [settings cordovaBoolSettingForKey:@"KeyboardResize" defaultValue:YES];
|
||||
if (!doesResize) {
|
||||
self.keyboardResizes = ResizeNone;
|
||||
NSLog(@"CDVIonicKeyboard: no resize");
|
||||
|
||||
} else {
|
||||
NSString *resizeMode = [settings cordovaSettingForKey:@"KeyboardResizeMode"];
|
||||
if (resizeMode) {
|
||||
if ([resizeMode isEqualToString:@"ionic"]) {
|
||||
self.keyboardResizes = ResizeIonic;
|
||||
} else if ([resizeMode isEqualToString:@"body"]) {
|
||||
self.keyboardResizes = ResizeBody;
|
||||
}
|
||||
}
|
||||
NSLog(@"CDVIonicKeyboard: resize mode %lu", (unsigned long)self.keyboardResizes);
|
||||
}
|
||||
self.hideFormAccessoryBar = [settings cordovaBoolSettingForKey:@"HideKeyboardFormAccessoryBar" defaultValue:YES];
|
||||
|
||||
NSString *keyboardStyle = [settings cordovaSettingForKey:@"KeyboardStyle"];
|
||||
if (keyboardStyle) {
|
||||
[self setKeyboardStyle:keyboardStyle];
|
||||
}
|
||||
|
||||
if ([settings cordovaBoolSettingForKey:@"KeyboardAppearanceDark" defaultValue:NO]) {
|
||||
[self setKeyboardStyle:@"dark"];
|
||||
}
|
||||
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[nc addObserver:self selector:@selector(onKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
|
||||
[nc addObserver:self selector:@selector(onKeyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
|
||||
[nc addObserver:self selector:@selector(onKeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
|
||||
[nc addObserver:self selector:@selector(onKeyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
|
||||
|
||||
// Prevent WKWebView to resize window
|
||||
BOOL isWK = self.isWK = [self.webView isKindOfClass:NSClassFromString(@"WKWebView")];
|
||||
if (!isWK) {
|
||||
NSLog(@"CDVIonicKeyboard: WARNING!!: Keyboard plugin works better with WK");
|
||||
}
|
||||
|
||||
if (isWK) {
|
||||
[nc removeObserver:self.webView name:UIKeyboardWillHideNotification object:nil];
|
||||
[nc removeObserver:self.webView name:UIKeyboardWillShowNotification object:nil];
|
||||
[nc removeObserver:self.webView name:UIKeyboardWillChangeFrameNotification object:nil];
|
||||
[nc removeObserver:self.webView name:UIKeyboardDidChangeFrameNotification object:nil];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)statusBarDidChangeFrame:(NSNotification*)notification
|
||||
{
|
||||
[self _updateFrame];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Keyboard events
|
||||
|
||||
- (void)resetScrollView
|
||||
{
|
||||
UIScrollView *scrollView = [self.webView scrollView];
|
||||
[scrollView setContentInset:UIEdgeInsetsZero];
|
||||
}
|
||||
|
||||
- (void)onKeyboardWillHide:(NSNotification *)sender
|
||||
{
|
||||
if (self.isWK) {
|
||||
[self setKeyboardHeight:0 delay:0.01];
|
||||
[self resetScrollView];
|
||||
}
|
||||
hideTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(fireOnHiding) userInfo:nil repeats:NO];
|
||||
}
|
||||
|
||||
- (void)fireOnHiding {
|
||||
[self.commandDelegate evalJs:@"Keyboard.fireOnHiding();"];
|
||||
}
|
||||
|
||||
- (void)onKeyboardWillShow:(NSNotification *)note
|
||||
{
|
||||
if (hideTimer != nil) {
|
||||
[hideTimer invalidate];
|
||||
}
|
||||
CGRect rect = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
double height = rect.size.height;
|
||||
|
||||
if (self.isWK) {
|
||||
double duration = [[note.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
||||
[self setKeyboardHeight:height delay:duration+0.2];
|
||||
[self resetScrollView];
|
||||
}
|
||||
|
||||
[self setKeyboardStyle:self.keyboardStyle];
|
||||
|
||||
NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnShowing(%d);", (int)height];
|
||||
[self.commandDelegate evalJs:js];
|
||||
}
|
||||
|
||||
- (void)onKeyboardDidShow:(NSNotification *)note
|
||||
{
|
||||
CGRect rect = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
double height = rect.size.height;
|
||||
|
||||
if (self.isWK) {
|
||||
[self resetScrollView];
|
||||
}
|
||||
|
||||
NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnShow(%d);", (int)height];
|
||||
[self.commandDelegate evalJs:js];
|
||||
}
|
||||
|
||||
- (void)onKeyboardDidHide:(NSNotification *)sender
|
||||
{
|
||||
[self.commandDelegate evalJs:@"Keyboard.fireOnHide();"];
|
||||
[self resetScrollView];
|
||||
}
|
||||
|
||||
- (void)setKeyboardHeight:(int)height delay:(NSTimeInterval)delay
|
||||
{
|
||||
if (self.keyboardResizes != ResizeNone) {
|
||||
[self setPaddingBottom: height delay:delay];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setPaddingBottom:(int)paddingBottom delay:(NSTimeInterval)delay
|
||||
{
|
||||
if (self.paddingBottom == paddingBottom) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.paddingBottom = paddingBottom;
|
||||
|
||||
__weak CDVIonicKeyboard* weakSelf = self;
|
||||
SEL action = @selector(_updateFrame);
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:action object:nil];
|
||||
if (delay == 0) {
|
||||
[self _updateFrame];
|
||||
} else {
|
||||
[weakSelf performSelector:action withObject:nil afterDelay:delay];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_updateFrame
|
||||
{
|
||||
CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
|
||||
int statusBarHeight = MIN(statusBarSize.width, statusBarSize.height);
|
||||
|
||||
int _paddingBottom = (int)self.paddingBottom;
|
||||
|
||||
if (statusBarHeight == 40) {
|
||||
_paddingBottom = _paddingBottom + 20;
|
||||
}
|
||||
NSLog(@"CDVIonicKeyboard: updating frame");
|
||||
// NOTE: to handle split screen correctly, the application's window bounds must be used as opposed to the screen's bounds.
|
||||
CGRect f = [[[[UIApplication sharedApplication] delegate] window] bounds];
|
||||
CGRect wf = self.webView.frame;
|
||||
switch (self.keyboardResizes) {
|
||||
case ResizeBody:
|
||||
{
|
||||
NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnResize(%d, %d, document.body);",
|
||||
_paddingBottom, (int)f.size.height];
|
||||
[self.commandDelegate evalJs:js];
|
||||
break;
|
||||
}
|
||||
case ResizeIonic:
|
||||
{
|
||||
NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnResize(%d, %d, document.querySelector('ion-app'));",
|
||||
_paddingBottom, (int)f.size.height];
|
||||
[self.commandDelegate evalJs:js];
|
||||
break;
|
||||
}
|
||||
case ResizeNative:
|
||||
{
|
||||
[self.webView setFrame:CGRectMake(wf.origin.x, wf.origin.y, f.size.width - wf.origin.x, f.size.height - wf.origin.y - self.paddingBottom)];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[self resetScrollView];
|
||||
}
|
||||
|
||||
#pragma mark Keyboard Style
|
||||
|
||||
- (void)setKeyboardStyle:(NSString*)style
|
||||
{
|
||||
IMP newImp = [style isEqualToString:@"dark"] ? imp_implementationWithBlock(^(id _s) {
|
||||
return UIKeyboardAppearanceDark;
|
||||
}) : imp_implementationWithBlock(^(id _s) {
|
||||
return UIKeyboardAppearanceLight;
|
||||
});
|
||||
|
||||
if (self.isWK) {
|
||||
for (NSString* classString in @[WKClassString, UITraitsClassString]) {
|
||||
Class c = NSClassFromString(classString);
|
||||
Method m = class_getInstanceMethod(c, @selector(keyboardAppearance));
|
||||
|
||||
if (m != NULL) {
|
||||
method_setImplementation(m, newImp);
|
||||
} else {
|
||||
class_addMethod(c, @selector(keyboardAppearance), newImp, "l@:");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (NSString* classString in @[UIClassString, UITraitsClassString]) {
|
||||
Class c = NSClassFromString(classString);
|
||||
Method m = class_getInstanceMethod(c, @selector(keyboardAppearance));
|
||||
|
||||
if (m != NULL) {
|
||||
method_setImplementation(m, newImp);
|
||||
} else {
|
||||
class_addMethod(c, @selector(keyboardAppearance), newImp, "l@:");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_keyboardStyle = style;
|
||||
}
|
||||
|
||||
#pragma mark HideFormAccessoryBar
|
||||
|
||||
static IMP UIOriginalImp;
|
||||
static IMP WKOriginalImp;
|
||||
|
||||
- (void)setHideFormAccessoryBar:(BOOL)hideFormAccessoryBar
|
||||
{
|
||||
if (hideFormAccessoryBar == _hideFormAccessoryBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
Method UIMethod = class_getInstanceMethod(NSClassFromString(UIClassString), @selector(inputAccessoryView));
|
||||
Method WKMethod = class_getInstanceMethod(NSClassFromString(WKClassString), @selector(inputAccessoryView));
|
||||
|
||||
if (hideFormAccessoryBar) {
|
||||
UIOriginalImp = method_getImplementation(UIMethod);
|
||||
WKOriginalImp = method_getImplementation(WKMethod);
|
||||
|
||||
IMP newImp = imp_implementationWithBlock(^(id _s) {
|
||||
return nil;
|
||||
});
|
||||
|
||||
method_setImplementation(UIMethod, newImp);
|
||||
method_setImplementation(WKMethod, newImp);
|
||||
} else {
|
||||
method_setImplementation(UIMethod, UIOriginalImp);
|
||||
method_setImplementation(WKMethod, WKOriginalImp);
|
||||
}
|
||||
|
||||
_hideFormAccessoryBar = hideFormAccessoryBar;
|
||||
}
|
||||
|
||||
#pragma mark scroll
|
||||
|
||||
- (void)setDisableScroll:(BOOL)disableScroll {
|
||||
if (disableScroll == _disableScroll) {
|
||||
return;
|
||||
}
|
||||
if (disableScroll) {
|
||||
self.webView.scrollView.scrollEnabled = NO;
|
||||
self.webView.scrollView.delegate = self;
|
||||
}
|
||||
else {
|
||||
self.webView.scrollView.scrollEnabled = YES;
|
||||
self.webView.scrollView.delegate = nil;
|
||||
}
|
||||
_disableScroll = disableScroll;
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
[scrollView setContentOffset: CGPointZero];
|
||||
}
|
||||
|
||||
#pragma mark Plugin interface
|
||||
|
||||
- (void)hideFormAccessoryBar:(CDVInvokedUrlCommand *)command
|
||||
{
|
||||
if (command.arguments.count > 0) {
|
||||
id value = [command.arguments objectAtIndex:0];
|
||||
if (!([value isKindOfClass:[NSNumber class]])) {
|
||||
value = [NSNumber numberWithBool:NO];
|
||||
}
|
||||
|
||||
self.hideFormAccessoryBar = [value boolValue];
|
||||
}
|
||||
|
||||
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.hideFormAccessoryBar]
|
||||
callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
- (void)hide:(CDVInvokedUrlCommand *)command
|
||||
{
|
||||
[self.webView endEditing:YES];
|
||||
}
|
||||
|
||||
- (void)setResizeMode:(CDVInvokedUrlCommand *)command
|
||||
{
|
||||
NSString * mode = [command.arguments objectAtIndex:0];
|
||||
if ([mode isEqualToString:@"ionic"]) {
|
||||
self.keyboardResizes = ResizeIonic;
|
||||
} else if ([mode isEqualToString:@"body"]) {
|
||||
self.keyboardResizes = ResizeBody;
|
||||
} else if ([mode isEqualToString:@"native"]) {
|
||||
self.keyboardResizes = ResizeNative;
|
||||
} else {
|
||||
self.keyboardResizes = ResizeNone;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyboardStyle:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
id value = [command.arguments objectAtIndex:0];
|
||||
if ([value isKindOfClass:[NSString class]]) {
|
||||
value = [(NSString*)value lowercaseString];
|
||||
} else {
|
||||
value = @"light";
|
||||
}
|
||||
|
||||
self.keyboardStyle = value;
|
||||
}
|
||||
|
||||
- (void)disableScroll:(CDVInvokedUrlCommand*)command {
|
||||
if (!command.arguments || ![command.arguments count]){
|
||||
return;
|
||||
}
|
||||
id value = [command.arguments objectAtIndex:0];
|
||||
if (value != [NSNull null]) {
|
||||
self.disableScroll = [value boolValue];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark dealloc
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,84 @@
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
var Keyboard = function () {};
|
||||
|
||||
Keyboard.fireOnShow = function (height) {
|
||||
Keyboard.isVisible = true;
|
||||
cordova.fireWindowEvent('keyboardDidShow', {
|
||||
'keyboardHeight': height
|
||||
});
|
||||
|
||||
// To support the keyboardAttach directive listening events
|
||||
// inside Ionic's main bundle
|
||||
cordova.fireWindowEvent('native.keyboardshow', {
|
||||
'keyboardHeight': height
|
||||
});
|
||||
};
|
||||
|
||||
Keyboard.fireOnHide = function () {
|
||||
Keyboard.isVisible = false;
|
||||
cordova.fireWindowEvent('keyboardDidHide');
|
||||
|
||||
// To support the keyboardAttach directive listening events
|
||||
// inside Ionic's main bundle
|
||||
cordova.fireWindowEvent('native.keyboardhide');
|
||||
};
|
||||
|
||||
Keyboard.fireOnHiding = function () {
|
||||
cordova.fireWindowEvent('keyboardWillHide');
|
||||
};
|
||||
|
||||
Keyboard.fireOnShowing = function (height) {
|
||||
cordova.fireWindowEvent('keyboardWillShow', {
|
||||
'keyboardHeight': height
|
||||
});
|
||||
};
|
||||
|
||||
Keyboard.hideFormAccessoryBar = Keyboard.hideKeyboardAccessoryBar = function (hide) {
|
||||
console.warn("Keyboard.hideKeyboardAccessoryBar() not supported in Android");
|
||||
};
|
||||
|
||||
Keyboard.hide = function () {
|
||||
exec(null, null, "CDVIonicKeyboard", "hide", []);
|
||||
};
|
||||
|
||||
Keyboard.show = function () {
|
||||
exec(null, null, "CDVIonicKeyboard", "show", []);
|
||||
};
|
||||
|
||||
Keyboard.disableScroll = function (disable) {
|
||||
console.warn("Keyboard.disableScroll() not supported in Android");
|
||||
};
|
||||
|
||||
Keyboard.setResizeMode = function (mode) {
|
||||
console.warn("Keyboard.setResizeMode() not supported in Android");
|
||||
}
|
||||
|
||||
Keyboard.setKeyboardStyle = function(style) {
|
||||
console.warn("Keyboard.setKeyboardStyle() not supported in Android");
|
||||
};
|
||||
|
||||
channel.onCordovaReady.subscribe(function () {
|
||||
exec(success, null, 'CDVIonicKeyboard', 'init', []);
|
||||
|
||||
function success(msg) {
|
||||
var action = msg.charAt(0);
|
||||
if (action === 'S') {
|
||||
var keyboardHeight = parseInt(msg.substr(1));
|
||||
Keyboard.fireOnShowing(keyboardHeight);
|
||||
Keyboard.fireOnShow(keyboardHeight);
|
||||
|
||||
} else if (action === 'H') {
|
||||
Keyboard.fireOnHiding();
|
||||
Keyboard.fireOnHide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Keyboard.isVisible = false;
|
||||
|
||||
module.exports = Keyboard;
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec');
|
||||
|
||||
var Keyboard = function () {};
|
||||
|
||||
Keyboard.fireOnShow = function (height) {
|
||||
Keyboard.isVisible = true;
|
||||
cordova.fireWindowEvent('keyboardDidShow', {
|
||||
'keyboardHeight': height
|
||||
});
|
||||
|
||||
// To support the keyboardAttach directive listening events
|
||||
// inside Ionic's main bundle
|
||||
cordova.fireWindowEvent('native.keyboardshow', {
|
||||
'keyboardHeight': height
|
||||
});
|
||||
};
|
||||
|
||||
Keyboard.fireOnHide = function () {
|
||||
Keyboard.isVisible = false;
|
||||
cordova.fireWindowEvent('keyboardDidHide');
|
||||
|
||||
// To support the keyboardAttach directive listening events
|
||||
// inside Ionic's main bundle
|
||||
cordova.fireWindowEvent('native.keyboardhide');
|
||||
};
|
||||
|
||||
Keyboard.fireOnHiding = function () {
|
||||
cordova.fireWindowEvent('keyboardWillHide');
|
||||
};
|
||||
|
||||
Keyboard.fireOnShowing = function (height) {
|
||||
cordova.fireWindowEvent('keyboardWillShow', {
|
||||
'keyboardHeight': height
|
||||
});
|
||||
};
|
||||
|
||||
Keyboard.fireOnResize = function (height, screenHeight, ele) {
|
||||
if (!ele) {
|
||||
return;
|
||||
}
|
||||
if (height === 0) {
|
||||
ele.style.height = null;
|
||||
} else {
|
||||
ele.style.height = (screenHeight - height) + 'px';
|
||||
}
|
||||
};
|
||||
|
||||
Keyboard.hideFormAccessoryBar = function (hide, success) {
|
||||
if (hide !== null && hide !== undefined) {
|
||||
exec(success, null, "CDVIonicKeyboard", "hideFormAccessoryBar", [hide]);
|
||||
} else {
|
||||
exec(success, null, "CDVIonicKeyboard", "hideFormAccessoryBar", []);
|
||||
}
|
||||
};
|
||||
|
||||
Keyboard.hide = function () {
|
||||
exec(null, null, "CDVIonicKeyboard", "hide", []);
|
||||
};
|
||||
|
||||
Keyboard.show = function () {
|
||||
console.warn('Showing keyboard not supported in iOS due to platform limitations.');
|
||||
console.warn('Instead, use input.focus(), and ensure that you have the following setting in your config.xml: \n');
|
||||
console.warn(' <preference name="KeyboardDisplayRequiresUserAction" value="false"/>\n');
|
||||
};
|
||||
|
||||
Keyboard.disableScroll = function (disable) {
|
||||
exec(null, null, "CDVIonicKeyboard", "disableScroll", [disable]);
|
||||
};
|
||||
|
||||
Keyboard.setResizeMode = function (mode) {
|
||||
exec(null, null, "CDVIonicKeyboard", "setResizeMode", [mode]);
|
||||
}
|
||||
|
||||
Keyboard.setKeyboardStyle = function(style) {
|
||||
exec(null, null, "CDVIonicKeyboard", "keyboardStyle", [style]);
|
||||
};
|
||||
|
||||
Keyboard.isVisible = false;
|
||||
|
||||
module.exports = Keyboard;
|
||||
@@ -0,0 +1,57 @@
|
||||
version: 2
|
||||
|
||||
aliases:
|
||||
- &restore-cache
|
||||
keys:
|
||||
- dependency-cache-{{ checksum "package.json" }}-1
|
||||
|
||||
- &save-cache
|
||||
key: dependency-cache-{{ checksum "package.json" }}-1
|
||||
paths:
|
||||
- node_modules
|
||||
|
||||
defaults: &defaults
|
||||
docker:
|
||||
- image: circleci/node:10
|
||||
working_directory: /tmp/workspace
|
||||
|
||||
jobs:
|
||||
build:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache: *restore-cache
|
||||
- run: npm install
|
||||
- save_cache: *save-cache
|
||||
- persist_to_workspace:
|
||||
root: /tmp/workspace
|
||||
paths:
|
||||
- "*"
|
||||
|
||||
deploy:
|
||||
<<: *defaults
|
||||
environment:
|
||||
GIT_AUTHOR_NAME: Ionitron
|
||||
GIT_AUTHOR_EMAIL: hi@ionicframework.com
|
||||
GIT_COMMITTER_NAME: Ionitron
|
||||
GIT_COMMITTER_EMAIL: hi@ionicframework.com
|
||||
steps:
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- "ae:6d:3a:f1:cf:39:e1:94:6e:22:2a:9f:54:f9:b0:1b" # ionitron user key
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- run: npx semantic-release
|
||||
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- build
|
||||
- deploy:
|
||||
requires: [build]
|
||||
filters:
|
||||
branches:
|
||||
only: stable
|
||||
@@ -0,0 +1,248 @@
|
||||
## [4.2.1](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v4.2.0...v4.2.1) (2020-04-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ios:** release userAgentLock for IAB compat ([#558](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/558)) ([4c027f3](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/4c027f3e1dadf790b1d699936b90b670b401db9e)), closes [#551](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/551)
|
||||
|
||||
# [4.2.0](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v4.1.3...v4.2.0) (2020-04-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ionassethandler.m:** fix startPath is getting null ([#463](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/463)) ([0bf16f1](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/0bf16f1b73b853f40781c5de83964457cc4493d5))
|
||||
* **ios:** avoid app scrolling to top on keyboard hide ([#533](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/533)) ([7974eb4](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/7974eb4160f5e83cf4b3e98905beba1f874464a6))
|
||||
* **ios:** Replace deprecated APIs ([#539](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/539)) ([27b9021](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/27b9021d5d76b3e6dc6bfc83ab46b98cd301e694))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **android:** proxy service worker requests through local server ([#452](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/452)) ([c672175](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/c672175b7527d64b077f7715b2ff145325524add))
|
||||
* **ios:** implement custom userAgent handling ([#537](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/537)) ([8587114](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/85871147ba8e5b23b693e518bf5ea800cccce8cc))
|
||||
|
||||
## [4.1.3](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v4.1.2...v4.1.3) (2019-10-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **android:** return proper mimeType for .mjs files ([#455](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/455)) ([173a313](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/173a313))
|
||||
* **ios:** mitigate media memory usage ([#459](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/459)) ([cbd526d](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/cbd526d))
|
||||
* **ios:** remove itms-services private scheme ([#464](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/464)) ([d7d2600](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/d7d2600))
|
||||
|
||||
## [4.1.2](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v4.1.1...v4.1.2) (2019-09-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **android:** allow schemes that start by https ([#437](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/437)) ([fab9d1f](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/fab9d1f))
|
||||
* **Android:** return proper mimeType for wasm files ([0eb8a37](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/0eb8a37))
|
||||
* **ios:** make programmatically focus work on iOS 13 ([#438](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/438)) ([7a514b0](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/7a514b0)), closes [#435](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/435)
|
||||
|
||||
## [4.1.1](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v4.1.0...v4.1.1) (2019-06-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ios:** show error message when app fails to load ([#382](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/382)) ([cb1f026](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/cb1f026))
|
||||
|
||||
# [4.1.0](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v4.0.1...v4.1.0) (2019-06-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **ios:** Add WKSuspendInBackground preference ([#356](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/356)) ([3613602](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/3613602))
|
||||
|
||||
## [4.0.1](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v4.0.0...v4.0.1) (2019-03-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ios:** Fix autofocus on iOS 12.2 ([#334](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/334)) ([cb4c491](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/cb4c491)), closes [#330](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/330)
|
||||
* account port on resolving uri path ([#321](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/321)) ([fdfe8aa](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/fdfe8aa))
|
||||
|
||||
# [4.0.0](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v3.1.2...v4.0.0) (2019-02-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **ios:** Make iOS app Scheme configurable with a preference ([#307](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/307)) ([d52d37e](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/d52d37e)), closes [#282](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/282)
|
||||
* **ios:** Remove WKSuspendInBackground preference ([#309](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/309)) ([73b6659](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/73b6659)), closes [#286](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/286)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **ios:** Remove the WKSuspendInBackground preference, so app relying on that prefere will
|
||||
not behave as expected
|
||||
|
||||
## [3.1.2](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v3.1.1...v3.1.2) (2019-02-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **Android:** Handle Range Requests for proper media file handling ([#298](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/298)) ([6f18248](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/6f18248)), closes [#248](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/248) [#205](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/205) [#141](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/141)
|
||||
|
||||
## [3.1.1](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v3.1.0...v3.1.1) (2019-01-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ios:** Remove unused code ([#281](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/281)) ([fc7ea27](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/fc7ea27))
|
||||
|
||||
# [3.1.0](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v3.0.0...v3.1.0) (2019-01-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ios:** Fix video playback of files with uppercase extension ([#264](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/264)) ([2c4b225](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/2c4b225)), closes [#260](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/260)
|
||||
* Set engines to require Cordova CLI 7.1.0 or newer ([#276](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/276)) ([40f42e1](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/40f42e1)), closes [#263](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/263)
|
||||
* Use a single scheme for all files ([#270](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/270)) ([3d1bcdd](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/3d1bcdd)), closes [#258](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/258)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **Android:** Make app Scheme configurable with a preference ([#274](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/274)) ([18d9f2c](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/18d9f2c)), closes [#269](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/269) [#255](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/255)
|
||||
|
||||
# [3.0.0](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.3.1...v3.0.0) (2019-01-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **iOS:** Remove unused code ([#247](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/247)) ([bceb17a](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/bceb17a))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Allows configuration of Mixed Content Mode ([#240](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/240)) ([486d412](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/486d412)), closes [#231](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/231)
|
||||
* **Android:** Implement ionic-file and ionic-content urls ([#242](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/242)) ([8ef0c30](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/8ef0c30)), closes [#204](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/204) [#183](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/183)
|
||||
* **iOS:** Remove GCDWebServer ([#244](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/244)) ([0dee0cf](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/0dee0cf))
|
||||
* **WebViewLocalServer.java:** return 404 error code when a local file is not found ([#217](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/217)) ([f7a551e](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/f7a551e)), closes [#216](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/216)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **iOS:** Sets deployment-target to 11, so will only work on iOS 11+
|
||||
|
||||
* Address changes
|
||||
* changes the default from 1 (never) to 0 (always)
|
||||
* **WebViewLocalServer.java:** Until now, the Android part of the plugin was returning a 200 http code even though
|
||||
the requested file didn't exist. This behavior was inconsistent with the historical behavior of the
|
||||
iOS webView. This change makes them both work in the same manner but introduces a breaking change
|
||||
for the current Android users that are expecting a 200 http code no matter what and are testing the
|
||||
not found error just by checking if the body is null.
|
||||
|
||||
## [2.3.1](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.3.0...v2.3.1) (2018-12-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Handle convertFileSrc when using ionic:// scheme ([#236](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/236)) ([89ce899](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/89ce899))
|
||||
|
||||
# [2.3.0](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.2.5...v2.3.0) (2018-12-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **ios:** Add URLSchemeHandler for iOS 11+ ([#221](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/221)) ([4a973f4](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/4a973f4))
|
||||
|
||||
## [2.2.5](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.2.4...v2.2.5) (2018-11-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Add option for Dark keyboard appearance ([#44](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/44)) ([6c0fe56](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/6c0fe56))
|
||||
|
||||
## [2.2.4](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.2.3...v2.2.4) (2018-11-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix keyboard displacement bug in iOS 12 WKWebView ([#201](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/201)) ([a670568](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/a670568))
|
||||
|
||||
## [2.2.3](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.2.2...v2.2.3) (2018-11-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Remove main and fix description ([d52db66](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/d52db66))
|
||||
|
||||
## [2.2.2](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.2.1...v2.2.2) (2018-11-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Add more server checks before loading urls or reloading ([#211](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/211)) ([60eff2f](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/60eff2f))
|
||||
|
||||
## [2.2.1](https://github.com/ionic-team/cordova-plugin-ionic-webview/compare/v2.2.0...v2.2.1) (2018-11-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Show error page if server is not running ([#207](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/207)) ([6a2e07e](https://github.com/ionic-team/cordova-plugin-ionic-webview/commit/6a2e07e))
|
||||
|
||||
<a name="2.2.0"></a>
|
||||
### 2.2.0 (2018-10-04)
|
||||
|
||||
* Fix issue where two apps running on the same port could conflict with each other ([#169](https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/165) & [#186](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/186))
|
||||
* Add kitkat support (API 19) ([#144](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/144)) [@leo6104](https://github.com/leo6104)
|
||||
* Fix issue where local server was being used if launch URL is external ([#169](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/169))
|
||||
|
||||
<a name="2.1.4"></a>
|
||||
### 2.1.4 (2018-09-13)
|
||||
|
||||
* Allow Ionic Deploy `DisableDeploy` preference to disable loading of deploy updates ([#172](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/172))
|
||||
|
||||
<a name="2.1.3"></a>
|
||||
### 2.1.3 (2018-09-06)
|
||||
|
||||
* Make server path relative ([#164](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/164))
|
||||
|
||||
<a name="2.1.2"></a>
|
||||
### 2.1.2 (2018-09-05)
|
||||
|
||||
* Return 404 response when file doesn't exist ([#162](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/162))
|
||||
* Load local assets if the app is a freshly installed binary ([#155](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/155))
|
||||
* Reset stored server path on new binary ([#161](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/161))
|
||||
|
||||
<a name="2.1.1"></a>
|
||||
### 2.1.1 (2018-09-04)
|
||||
|
||||
* Allow range requests for local files ([#154](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/154))
|
||||
|
||||
<a name="2.1.0"></a>
|
||||
### 2.1.0 (2018-08-23)
|
||||
|
||||
* Add support for `cordova-android` 6 ([#150](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/150))
|
||||
|
||||
<a name="2.0.3"></a>
|
||||
### 2.0.3 (2018-08-14)
|
||||
|
||||
* Fix nil reference by setting up the server URL before routes are set up. ([#135](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/135)) [@matejkramny](https://github.com/matejkramny)
|
||||
* Resolve issue when app is launched in background. ([#124](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/124)) [@ghenry22](https://github.com/ghenry22)
|
||||
|
||||
<a name="2.0.2"></a>
|
||||
### 2.0.2 (2018-07-30)
|
||||
|
||||
* Immediately load new server base path upon setting it. ([#132](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/132))
|
||||
|
||||
<a name="2.0.1"></a>
|
||||
### 2.0.1 (2018-07-25)
|
||||
|
||||
* Avoid "not modified" response on iOS by always overriding last modified date. ([#127](https://github.com/ionic-team/cordova-plugin-ionic-webview/pull/127))
|
||||
|
||||
<a name="2.0.0"></a>
|
||||
### 2.0.0 (2018-07-23)
|
||||
|
||||
* **BREAKING**: HTTP server now runs for iOS **and** Android, instead of just iOS. The server is configured the same for both platforms.
|
||||
* **BREAKING**: HTTP server now loads the app from a base href of `/`. The app URL behaves like `http://localhost:8080/index.html` instead of `http://localhost:8080/Users/.../index.html`.
|
||||
* **BREAKING**: HTTP server is configured to run in HTML5 routing mode (push state) by default.
|
||||
* **BREAKING**: File access through the Web View must be served by the HTTP server to avoid security errors in the Web View. Loading files via `file://` is not allowed by the Web View. The HTTP server will serve files via the `_file_` prefix, e.g. `http://localhost:8080/_file_/Users/.../file.png`.
|
||||
* `window.Ionic.normalizeURL()` has been deprecated. Use `window.Ionic.WebView.convertFileSrc()`.
|
||||
* iOS update HTTP server to latest upstream version (GCDwebserve 3.4.2)
|
||||
* iOS update HTTP server to restart sockets with error state when resuming from background
|
||||
* iOS enable HTTP server to continue running in background if the webview is running.
|
||||
* iOS enable Webview to continue running in background. Requires background mode capability enabled in xcode + valid use case as per app store requirements. If your app is not performing valid background tasks it will still be suspended by the OS as usual. As long as valid background tasks are running the webview will continue to function as expected.
|
||||
* iOS add config.xml options:
|
||||
* WKSuspendInBackground - defaults to true, if set to false then the webview and HTTP server will continue to run when the app is in the background or screen is locked
|
||||
* WKPort - defaults to 8080, define the port that the HTTP server will listen on
|
||||
* WKBind - defaults to localhost, if set to 127.0.0.1 then this IP will be used instead of the localhost hostname for the HTTP server
|
||||
|
||||
See [Github releases](https://github.com/ionic-team/cordova-plugin-ionic-webview/releases) for earlier changes.
|
||||
@@ -0,0 +1,32 @@
|
||||
# Contributing
|
||||
|
||||
:mega: **Support/Questions?**: Please see our [Support Page](https://ionicframework.com/support) for general support questions. The issues on GitHub should be reserved for bug reports and feature requests.
|
||||
|
||||
### Bug Reports
|
||||
|
||||
Please create an issue describing the bug in detail.
|
||||
|
||||
### Feature Requests
|
||||
|
||||
Please create an issue!
|
||||
|
||||
## Developing
|
||||
|
||||
Please familiarize yourself with [Cordova plugin development](https://cordova.apache.org/docs/en/latest/guide/hybrid/plugins/).
|
||||
|
||||
You can use `cordova plugin add` with a local directory to copy and compile plugin changes into a test project.
|
||||
|
||||
### Workflow
|
||||
|
||||
This repo uses [semantic-release](https://github.com/semantic-release/semantic-release), so it's important to follow a strict workflow to ensure properly automated releases.
|
||||
|
||||
* Work off of `master` branch (create new branch or fork)
|
||||
* Make changes
|
||||
* Use `npm run cz` (or `git cz` if [commitizen](https://github.com/commitizen/cz-cli) is installed globally) to make commits
|
||||
* Create a pull request
|
||||
* Pull requests will be approved and squashed into the `master` branch
|
||||
* Try to make pull requests with a single objective (don't have multiple features in one PR, don't mix fixes and features in one PR, etc.)
|
||||
|
||||
### Publishing
|
||||
|
||||
Releases are automated in CI using [semantic-release](https://github.com/semantic-release/semantic-release) when the `stable` branch is pushed to Github. Rebase `master` with `stable`. Commits in `master` should be appropriately formatted from the PR workflow (see [Workflow](#workflow)).
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,181 @@
|
||||
<!--
|
||||
# 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.
|
||||
-->
|
||||
|
||||
<!-- TODO: remove beta in README.md and CONTRIBUTING.md -->
|
||||
|
||||
[](https://github.com/semantic-release/semantic-release)
|
||||
[](https://dependabot.com)
|
||||
[](https://www.npmjs.com/package/cordova-plugin-ionic-webview)
|
||||
|
||||
# Ionic Web View for Cordova
|
||||
|
||||
A Web View plugin for Cordova, focused on providing the highest performance experience for Ionic apps (but can be used with any Cordova app).
|
||||
|
||||
This plugin uses WKWebView on iOS and the latest evergreen webview on Android. Additionally, this plugin makes it easy to use HTML5 style routing that web developers expect for building single-page apps.
|
||||
|
||||
Note: This repo and its documentation are for `cordova-plugin-ionic-webview` @ `4.x`, which uses the new features that may not work with all apps. See [Requirements](#plugin-requirements) and [Migrating to 4.x](#migrating-to-4x).
|
||||
|
||||
2.x documentation can be found [here](https://github.com/ionic-team/cordova-plugin-ionic-webview/blob/2.x/README.md).
|
||||
|
||||
:book: **Documentation**: [https://beta.ionicframework.com/docs/building/webview][ionic-webview-docs]
|
||||
|
||||
:mega: **Support/Questions?** Please see our [Support Page][ionic-support] for general support questions. The issues on GitHub should be reserved for bug reports and feature requests.
|
||||
|
||||
:sparkling_heart: **Want to contribute?** Please see [CONTRIBUTING.md](https://github.com/ionic-team/cordova-plugin-ionic-webview/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## Configuration
|
||||
|
||||
This plugin has several configuration options that can be set in `config.xml`.
|
||||
|
||||
### Android and iOS Preferences
|
||||
|
||||
Preferences available for both iOS and Android
|
||||
|
||||
#### Hostname
|
||||
|
||||
`<preference name="Hostname" value="app" />`
|
||||
|
||||
Default value is `localhost`.
|
||||
|
||||
Example `ionic://app` on iOS, `http://app` on Android.
|
||||
|
||||
If you change it, you'll need to add a new `allow-navigation` entry in the `config.xml` for the configured url (i.e `<allow-navigation href="http://app/*"/>` if `Hostname` is set to `app`).
|
||||
This is only needed for the Android url when using `http://`, `https://` or a custom scheme. All `ionic://` urls are whitelisted by the plugin.
|
||||
|
||||
### Android Preferences
|
||||
|
||||
Preferences only available Android platform
|
||||
|
||||
#### Scheme
|
||||
|
||||
```xml
|
||||
<preference name="Scheme" value="https" />
|
||||
```
|
||||
|
||||
Default value is `http`
|
||||
|
||||
Configures the Scheme the app uses to load the content.
|
||||
|
||||
#### ResolveServiceWorkerRequests
|
||||
|
||||
```xml
|
||||
<preference name="ResolveServiceWorkerRequests" value="true" />
|
||||
```
|
||||
|
||||
Default value is `false`
|
||||
|
||||
Enable to resolve requests made by Service Workers through the local server.
|
||||
|
||||
#### MixedContentMode
|
||||
|
||||
```xml
|
||||
<preference name="MixedContentMode" value="2" />
|
||||
```
|
||||
|
||||
Configures the WebView's behavior when an origin attempts to load a resource from a different origin.
|
||||
|
||||
Default value is `0` (`MIXED_CONTENT_ALWAYS_ALLOW`), which allows loading resources from other origins.
|
||||
|
||||
Other possible values are `1` (`MIXED_CONTENT_NEVER_ALLOW`) and `2` (`MIXED_CONTENT_COMPATIBILITY_MODE`)
|
||||
|
||||
|
||||
[Android documentation](https://developer.android.com/reference/android/webkit/WebSettings.html#setMixedContentMode(int))
|
||||
|
||||
|
||||
### iOS Preferences
|
||||
|
||||
Preferences only available for iOS platform
|
||||
|
||||
#### iosScheme
|
||||
|
||||
```xml
|
||||
<preference name="iosScheme" value="httpsionic" />
|
||||
```
|
||||
|
||||
Default value is `ionic`
|
||||
|
||||
Configures the Scheme the app uses to load the content.
|
||||
|
||||
Values like `http`, `https` or `file` are not valid and will use default value instead.
|
||||
|
||||
If you change it, you'll need to add a new `allow-navigation` entry in the `config.xml` for the configured scheme (i.e `<allow-navigation href="httpsionic://*"/>` if `iosScheme` is set to `httpsionic`).
|
||||
|
||||
#### WKSuspendInBackground
|
||||
|
||||
```xml
|
||||
<preference name="WKSuspendInBackground" value="false" />
|
||||
```
|
||||
|
||||
Default value is `true` (suspend).
|
||||
|
||||
Set to false to stop WKWebView suspending in background too eagerly.
|
||||
|
||||
#### KeyboardAppearanceDark
|
||||
|
||||
```xml
|
||||
<preference name="KeyboardAppearanceDark" value="false" />
|
||||
```
|
||||
|
||||
Whether to use a dark styled keyboard on iOS
|
||||
|
||||
#### ScrollEnabled
|
||||
|
||||
```xml
|
||||
<preference name="ScrollEnabled" value="true" />
|
||||
```
|
||||
|
||||
Ionic apps work better if the WKWebView is not scrollable, so the scroll is disabled by default, but can be enabled with this preference. This only affects the main ScrollView of the WKWebView, so only affects the body, not other scrollable components.
|
||||
|
||||
## Plugin Requirements
|
||||
|
||||
* **Cordova CLI**: 7.1.0+
|
||||
* **iOS**: iOS 11+ and `cordova-ios` 4+
|
||||
* **Android**: Android 4.4+ and `cordova-android` 6.4+
|
||||
|
||||
## Migrating to 4.x
|
||||
|
||||
1. Remove and re-add the Web View plugin:
|
||||
|
||||
```
|
||||
cordova plugin rm cordova-plugin-ionic-webview
|
||||
cordova plugin add cordova-plugin-ionic-webview@latest
|
||||
```
|
||||
|
||||
1. Apps are now served from HTTP on Android by default.
|
||||
|
||||
* The default origin for requests from the Android WebView is `http://localhost`. If `Hostname` and `Scheme` preferences are set, then origin will be `schemeValue://HostnameValue`.
|
||||
|
||||
1. Apps are now served from `ionic://` scheme on iOS by default.
|
||||
|
||||
* The default origin for requests from the iOS WebView is `ionic://localhost`. If `Hostname` and `iosScheme` preferences are set, then origin will be `iosSchemeValue://HostnameValue`.
|
||||
|
||||
1. The WebView is not able to display images, videos or other files from file or content protocols or if it doesn't have protocol at all. For those cases use `window.Ionic.WebView.convertFileSrc()` to get the proper url.
|
||||
|
||||
1. Replace any usages of `window.Ionic.normalizeURL()` with `window.Ionic.WebView.convertFileSrc()`.
|
||||
|
||||
* For Ionic Angular projects, there is an [Ionic Native wrapper](https://beta.ionicframework.com/docs/native/ionic-webview):
|
||||
|
||||
```
|
||||
npm install @ionic-native/ionic-webview@beta
|
||||
```
|
||||
|
||||
[ionic-homepage]: https://ionicframework.com
|
||||
[ionic-docs]: https://ionicframework.com/docs
|
||||
[ionic-webview-docs]: https://beta.ionicframework.com/docs/building/webview
|
||||
[ionic-support]: https://ionicframework.com/support
|
||||
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"_from": "cordova-plugin-ionic-webview@^4.0.0",
|
||||
"_id": "cordova-plugin-ionic-webview@4.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-7KrmqLaOGq1RP8N2z1ezN1kqkWFzTwwMvQ3/qAkd+exxFZuOe3DIN4eaU1gdNphsxdirI8Ajnr9q4So5vQbWqw==",
|
||||
"_location": "/cordova-plugin-ionic-webview",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "cordova-plugin-ionic-webview@^4.0.0",
|
||||
"name": "cordova-plugin-ionic-webview",
|
||||
"escapedName": "cordova-plugin-ionic-webview",
|
||||
"rawSpec": "^4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/",
|
||||
"#USER"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cordova-plugin-ionic-webview/-/cordova-plugin-ionic-webview-4.2.1.tgz",
|
||||
"_shasum": "42a67bef248472659d421494feb8245ef27becfa",
|
||||
"_spec": "cordova-plugin-ionic-webview@^4.0.0",
|
||||
"_where": "/home/saherelm/Documents/My Projects/xFrameworkTest",
|
||||
"author": {
|
||||
"name": "Ionic Team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ionic-team/cordova-plugin-ionic-webview/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Ionic Web View Engine Plugin",
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^3.0.0",
|
||||
"@semantic-release/exec": "^3.3.0",
|
||||
"@semantic-release/git": "^7.0.4",
|
||||
"@semantic-release/github": "^5.0.6",
|
||||
"@semantic-release/npm": "^5.0.4",
|
||||
"commitizen": "^4.0.3",
|
||||
"cz-conventional-changelog": "^3.0.2",
|
||||
"semantic-release": "^15.9.17",
|
||||
"sync-cordova-xml": "^0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
"2.0.0": {
|
||||
"cordova-android": ">=6.4.0",
|
||||
"cordova-ios": ">=4.0.0-dev"
|
||||
},
|
||||
"3.1.0": {
|
||||
"cordova": ">=7.1.0",
|
||||
"cordova-android": ">=6.4.0",
|
||||
"cordova-ios": ">=4.0.0-dev"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homepage": "https://github.com/ionic-team/cordova-plugin-ionic-webview#readme",
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"wkwebview"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"name": "cordova-plugin-ionic-webview",
|
||||
"release": {
|
||||
"branch": "stable",
|
||||
"verifyConditions": [
|
||||
"@semantic-release/changelog",
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/git",
|
||||
"@semantic-release/github"
|
||||
],
|
||||
"prepare": [
|
||||
"@semantic-release/changelog",
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/exec",
|
||||
"@semantic-release/git"
|
||||
],
|
||||
"publish": [
|
||||
"@semantic-release/github",
|
||||
"@semantic-release/npm"
|
||||
],
|
||||
"success": [
|
||||
"@semantic-release/github"
|
||||
],
|
||||
"failure": [
|
||||
"@semantic-release/github"
|
||||
],
|
||||
"prepareCmd": "npm run version"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ionic-team/cordova-plugin-ionic-webview.git"
|
||||
},
|
||||
"scripts": {
|
||||
"cz": "git-cz",
|
||||
"sync_plugin_xml": "sync-cordova-xml package.json plugin.xml --output=plugin.xml",
|
||||
"version": "npm run sync_plugin_xml && git add plugin.xml"
|
||||
},
|
||||
"version": "4.2.1"
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?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-ionic-webview" version="4.2.1">
|
||||
<name>cordova-plugin-ionic-webview</name>
|
||||
<description>Ionic Web View Engine Plugin</description>
|
||||
<license>Apache-2.0</license>
|
||||
<keywords>cordova,wkwebview</keywords>
|
||||
<repo>https://github.com/ionic-team/cordova-plugin-ionic-webview</repo>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=7.1.0"/>
|
||||
<engine name="cordova-ios" version=">=4.0.0-dev"/>
|
||||
<engine name="apple-ios" version=">=11.0"/>
|
||||
<engine name="cordova-android" version=">=6.4.0"/>
|
||||
</engines>
|
||||
|
||||
<js-module src="src/www/util.js" name="IonicWebView">
|
||||
<clobbers target="Ionic.WebView"/>
|
||||
</js-module>
|
||||
|
||||
<platform name="android">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<allow-navigation href="http://localhost/*"/>
|
||||
<allow-navigation href="https://localhost/*"/>
|
||||
<allow-navigation href="ionic://*"/>
|
||||
<preference name="webView" value="com.ionicframework.cordova.webview.IonicWebViewEngine"/>
|
||||
<feature name="IonicWebView">
|
||||
<param name="android-package" value="com.ionicframework.cordova.webview.IonicWebView"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
<source-file src="src/android/com/ionicframework/cordova/webview/IonicWebViewEngine.java" target-dir="src/com/ionicframework/cordova/webview"/>
|
||||
<source-file src="src/android/com/ionicframework/cordova/webview/IonicWebView.java" target-dir="src/com/ionicframework/cordova/webview"/>
|
||||
<source-file src="src/android/com/ionicframework/cordova/webview/AndroidProtocolHandler.java" target-dir="src/com/ionicframework/cordova/webview"/>
|
||||
<source-file src="src/android/com/ionicframework/cordova/webview/UriMatcher.java" target-dir="src/com/ionicframework/cordova/webview"/>
|
||||
<source-file src="src/android/com/ionicframework/cordova/webview/WebViewLocalServer.java" target-dir="src/com/ionicframework/cordova/webview"/>
|
||||
<preference name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" default="27.+"/>
|
||||
<framework src="com.android.support:support-annotations:$ANDROID_SUPPORT_ANNOTATIONS_VERSION"/>
|
||||
</platform>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
<js-module src="src/www/ios/ios-wkwebview-exec.js" name="ios-wkwebview-exec">
|
||||
<clobbers target="cordova.exec"/>
|
||||
</js-module>
|
||||
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<allow-navigation href="ionic://*"/>
|
||||
<preference name="deployment-target" value="11.0"/>
|
||||
<feature name="IonicWebView">
|
||||
<param name="ios-package" value="CDVWKWebViewEngine"/>
|
||||
</feature>
|
||||
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine"/>
|
||||
</config-file>
|
||||
|
||||
<framework src="WebKit.framework" weak="true"/>
|
||||
|
||||
<header-file src="src/ios/CDVWKWebViewEngine.h"/>
|
||||
<source-file src="src/ios/CDVWKWebViewEngine.m"/>
|
||||
<header-file src="src/ios/CDVWKWebViewUIDelegate.h"/>
|
||||
<source-file src="src/ios/CDVWKWebViewUIDelegate.m"/>
|
||||
<header-file src="src/ios/CDVWKProcessPoolFactory.h"/>
|
||||
<source-file src="src/ios/CDVWKProcessPoolFactory.m"/>
|
||||
<header-file src="src/ios/IONAssetHandler.h"/>
|
||||
<source-file src="src/ios/IONAssetHandler.m"/>
|
||||
<asset src="src/ios/wk-plugin.js" target="wk-plugin.js"/>
|
||||
</platform>
|
||||
<issue>https://github.com/ionic-team/cordova-plugin-ionic-webview/issues</issue>
|
||||
<author>Ionic Team</author>
|
||||
</plugin>
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package com.ionicframework.cordova.webview;
|
||||
|
||||
// Copyright 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AndroidProtocolHandler {
|
||||
private static final String TAG = "AndroidProtocolHandler";
|
||||
|
||||
private Context context;
|
||||
|
||||
public AndroidProtocolHandler(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public InputStream openAsset(String path) throws IOException {
|
||||
return context.getAssets().open(path, AssetManager.ACCESS_STREAMING);
|
||||
}
|
||||
|
||||
public InputStream openResource(Uri uri) {
|
||||
assert uri.getPath() != null;
|
||||
// The path must be of the form ".../asset_type/asset_name.ext".
|
||||
List<String> pathSegments = uri.getPathSegments();
|
||||
String assetType = pathSegments.get(pathSegments.size() - 2);
|
||||
String assetName = pathSegments.get(pathSegments.size() - 1);
|
||||
|
||||
// Drop the file extension.
|
||||
assetName = assetName.split("\\.")[0];
|
||||
try {
|
||||
// Use the application context for resolving the resource package name so that we do
|
||||
// not use the browser's own resources. Note that if 'context' here belongs to the
|
||||
// test suite, it does not have a separate application context. In that case we use
|
||||
// the original context object directly.
|
||||
if (context.getApplicationContext() != null) {
|
||||
context = context.getApplicationContext();
|
||||
}
|
||||
int fieldId = getFieldId(context, assetType, assetName);
|
||||
int valueType = getValueType(context, fieldId);
|
||||
if (valueType == TypedValue.TYPE_STRING) {
|
||||
return context.getResources().openRawResource(fieldId);
|
||||
} else {
|
||||
Log.e(TAG, "Asset not of type string: " + uri);
|
||||
return null;
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e(TAG, "Unable to open resource URL: " + uri, e);
|
||||
return null;
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e(TAG, "Unable to open resource URL: " + uri, e);
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(TAG, "Unable to open resource URL: " + uri, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public InputStream openFile(String filePath) throws IOException {
|
||||
String realPath = filePath.replace(WebViewLocalServer.fileStart, "");
|
||||
File localFile = new File(realPath);
|
||||
return new FileInputStream(localFile);
|
||||
}
|
||||
|
||||
public InputStream openContentUrl(Uri uri) throws IOException {
|
||||
Integer port = uri.getPort();
|
||||
String realPath;
|
||||
if (port == -1) {
|
||||
realPath = uri.toString().replace(uri.getScheme() + "://" + uri.getHost() + WebViewLocalServer.contentStart, "content:/");
|
||||
} else {
|
||||
realPath = uri.toString().replace(uri.getScheme() + "://" + uri.getHost() + ":" + port + WebViewLocalServer.contentStart, "content:/");
|
||||
}
|
||||
InputStream stream = null;
|
||||
try {
|
||||
stream = context.getContentResolver().openInputStream(Uri.parse(realPath));
|
||||
} catch (SecurityException e) {
|
||||
Log.e(TAG, "Unable to open content URL: " + uri, e);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
private static int getFieldId(Context context, String assetType, String assetName)
|
||||
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
|
||||
Class<?> d = context.getClassLoader()
|
||||
.loadClass(context.getPackageName() + ".R$" + assetType);
|
||||
java.lang.reflect.Field field = d.getField(assetName);
|
||||
int id = field.getInt(null);
|
||||
return id;
|
||||
}
|
||||
|
||||
private static int getValueType(Context context, int fieldId) {
|
||||
TypedValue value = new TypedValue();
|
||||
context.getResources().getValue(fieldId, value, true);
|
||||
return value.type;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.ionicframework.cordova.webview;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
public class IonicWebView extends CordovaPlugin {
|
||||
|
||||
public static final String WEBVIEW_PREFS_NAME = "WebViewSettings";
|
||||
public static final String CDV_SERVER_PATH = "serverBasePath";
|
||||
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
|
||||
if (action.equals("setServerBasePath")) {
|
||||
final String path = args.getString(0);
|
||||
cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
((IonicWebViewEngine)webView.getEngine()).setServerBasePath(path);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
} else if (action.equals("getServerBasePath")) {
|
||||
callbackContext.success(((IonicWebViewEngine)webView.getEngine()).getServerBasePath());
|
||||
return true;
|
||||
} else if (action.equals("persistServerBasePath")) {
|
||||
String path = ((IonicWebViewEngine)webView.getEngine()).getServerBasePath();
|
||||
SharedPreferences prefs = cordova.getActivity().getApplicationContext().getSharedPreferences(WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(CDV_SERVER_PATH, path);
|
||||
editor.apply();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
package com.ionicframework.cordova.webview;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.util.Log;
|
||||
import android.webkit.ServiceWorkerController;
|
||||
import android.webkit.ServiceWorkerClient;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import org.apache.cordova.ConfigXmlParser;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.apache.cordova.CordovaPreferences;
|
||||
import org.apache.cordova.CordovaResourceApi;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.CordovaWebViewEngine;
|
||||
import org.apache.cordova.NativeToJsMessageQueue;
|
||||
import org.apache.cordova.PluginManager;
|
||||
import org.apache.cordova.engine.SystemWebViewClient;
|
||||
import org.apache.cordova.engine.SystemWebViewEngine;
|
||||
import org.apache.cordova.engine.SystemWebView;
|
||||
|
||||
public class IonicWebViewEngine extends SystemWebViewEngine {
|
||||
public static final String TAG = "IonicWebViewEngine";
|
||||
|
||||
private WebViewLocalServer localServer;
|
||||
private String CDV_LOCAL_SERVER;
|
||||
private String scheme;
|
||||
private static final String LAST_BINARY_VERSION_CODE = "lastBinaryVersionCode";
|
||||
private static final String LAST_BINARY_VERSION_NAME = "lastBinaryVersionName";
|
||||
|
||||
/**
|
||||
* Used when created via reflection.
|
||||
*/
|
||||
public IonicWebViewEngine(Context context, CordovaPreferences preferences) {
|
||||
super(new SystemWebView(context), preferences);
|
||||
Log.d(TAG, "Ionic Web View Engine Starting Right Up 1...");
|
||||
}
|
||||
|
||||
public IonicWebViewEngine(SystemWebView webView) {
|
||||
super(webView, null);
|
||||
Log.d(TAG, "Ionic Web View Engine Starting Right Up 2...");
|
||||
}
|
||||
|
||||
public IonicWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
|
||||
super(webView, preferences);
|
||||
Log.d(TAG, "Ionic Web View Engine Starting Right Up 3...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(CordovaWebView parentWebView, CordovaInterface cordova, final CordovaWebViewEngine.Client client,
|
||||
CordovaResourceApi resourceApi, PluginManager pluginManager,
|
||||
NativeToJsMessageQueue nativeToJsMessageQueue) {
|
||||
ConfigXmlParser parser = new ConfigXmlParser();
|
||||
parser.parse(cordova.getActivity());
|
||||
|
||||
String hostname = preferences.getString("Hostname", "localhost");
|
||||
scheme = preferences.getString("Scheme", "http");
|
||||
CDV_LOCAL_SERVER = scheme + "://" + hostname;
|
||||
|
||||
localServer = new WebViewLocalServer(cordova.getActivity(), hostname, true, parser, scheme);
|
||||
localServer.hostAssets("www");
|
||||
|
||||
webView.setWebViewClient(new ServerClient(this, parser));
|
||||
|
||||
super.init(parentWebView, cordova, client, resourceApi, pluginManager, nativeToJsMessageQueue);
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
final WebSettings settings = webView.getSettings();
|
||||
int mode = preferences.getInteger("MixedContentMode", 0);
|
||||
settings.setMixedContentMode(mode);
|
||||
}
|
||||
SharedPreferences prefs = cordova.getActivity().getApplicationContext().getSharedPreferences(IonicWebView.WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE);
|
||||
String path = prefs.getString(IonicWebView.CDV_SERVER_PATH, null);
|
||||
if (!isDeployDisabled() && !isNewBinary() && path != null && !path.isEmpty()) {
|
||||
setServerBasePath(path);
|
||||
}
|
||||
|
||||
boolean setAsServiceWorkerClient = preferences.getBoolean("ResolveServiceWorkerRequests", false);
|
||||
ServiceWorkerController controller = null;
|
||||
|
||||
if (setAsServiceWorkerClient && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
controller = ServiceWorkerController.getInstance();
|
||||
controller.setServiceWorkerClient(new ServiceWorkerClient(){
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
|
||||
return localServer.shouldInterceptRequest(request.getUrl(), request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNewBinary() {
|
||||
String versionCode = "";
|
||||
String versionName = "";
|
||||
SharedPreferences prefs = cordova.getActivity().getApplicationContext().getSharedPreferences(IonicWebView.WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE);
|
||||
String lastVersionCode = prefs.getString(LAST_BINARY_VERSION_CODE, null);
|
||||
String lastVersionName = prefs.getString(LAST_BINARY_VERSION_NAME, null);
|
||||
|
||||
try {
|
||||
PackageInfo pInfo = this.cordova.getActivity().getPackageManager().getPackageInfo(this.cordova.getActivity().getPackageName(), 0);
|
||||
versionCode = Integer.toString(pInfo.versionCode);
|
||||
versionName = pInfo.versionName;
|
||||
} catch(Exception ex) {
|
||||
Log.e(TAG, "Unable to get package info", ex);
|
||||
}
|
||||
|
||||
if (!versionCode.equals(lastVersionCode) || !versionName.equals(lastVersionName)) {
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString(LAST_BINARY_VERSION_CODE, versionCode);
|
||||
editor.putString(LAST_BINARY_VERSION_NAME, versionName);
|
||||
editor.putString(IonicWebView.CDV_SERVER_PATH, "");
|
||||
editor.apply();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isDeployDisabled() {
|
||||
return preferences.getBoolean("DisableDeploy", false);
|
||||
}
|
||||
private class ServerClient extends SystemWebViewClient {
|
||||
private ConfigXmlParser parser;
|
||||
|
||||
public ServerClient(SystemWebViewEngine parentEngine, ConfigXmlParser parser) {
|
||||
super(parentEngine);
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
||||
return localServer.shouldInterceptRequest(request.getUrl(), request);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||
return localServer.shouldInterceptRequest(Uri.parse(url), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
String launchUrl = parser.getLaunchUrl();
|
||||
if (!launchUrl.contains(WebViewLocalServer.httpsScheme) && !launchUrl.contains(WebViewLocalServer.httpScheme) && url.equals(launchUrl)) {
|
||||
view.stopLoading();
|
||||
// When using a custom scheme the app won't load if server start url doesn't end in /
|
||||
String startUrl = CDV_LOCAL_SERVER;
|
||||
if (!scheme.equalsIgnoreCase(WebViewLocalServer.httpsScheme) && !scheme.equalsIgnoreCase(WebViewLocalServer.httpScheme)) {
|
||||
startUrl += "/";
|
||||
}
|
||||
view.loadUrl(startUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
view.loadUrl("javascript:(function() { " +
|
||||
"window.WEBVIEW_SERVER_URL = '" + CDV_LOCAL_SERVER + "';" +
|
||||
"})()");
|
||||
}
|
||||
}
|
||||
|
||||
public void setServerBasePath(String path) {
|
||||
localServer.hostFiles(path);
|
||||
webView.loadUrl(CDV_LOCAL_SERVER);
|
||||
}
|
||||
|
||||
public String getServerBasePath() {
|
||||
return this.localServer.getBasePath();
|
||||
}
|
||||
}
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
package com.ionicframework.cordova.webview;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
//package com.google.webviewlocalserver.third_party.android;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class UriMatcher {
|
||||
/**
|
||||
* Creates the root node of the URI tree.
|
||||
*
|
||||
* @param code the code to match for the root URI
|
||||
*/
|
||||
public UriMatcher(Object code) {
|
||||
mCode = code;
|
||||
mWhich = -1;
|
||||
mChildren = new ArrayList<UriMatcher>();
|
||||
mText = null;
|
||||
}
|
||||
|
||||
private UriMatcher() {
|
||||
mCode = null;
|
||||
mWhich = -1;
|
||||
mChildren = new ArrayList<UriMatcher>();
|
||||
mText = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a URI to match, and the code to return when this URI is
|
||||
* matched. URI nodes may be exact match string, the token "*"
|
||||
* that matches any text, or the token "#" that matches only
|
||||
* numbers.
|
||||
* <p>
|
||||
* Starting from API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2},
|
||||
* this method will accept a leading slash in the path.
|
||||
*
|
||||
* @param authority the authority to match
|
||||
* @param path the path to match. * may be used as a wild card for
|
||||
* any text, and # may be used as a wild card for numbers.
|
||||
* @param code the code that is returned when a URI is matched
|
||||
* against the given components. Must be positive.
|
||||
*/
|
||||
public void addURI(String scheme, String authority, String path, Object code) {
|
||||
if (code == null) {
|
||||
throw new IllegalArgumentException("Code can't be null");
|
||||
}
|
||||
|
||||
String[] tokens = null;
|
||||
if (path != null) {
|
||||
String newPath = path;
|
||||
// Strip leading slash if present.
|
||||
if (path.length() > 0 && path.charAt(0) == '/') {
|
||||
newPath = path.substring(1);
|
||||
}
|
||||
tokens = PATH_SPLIT_PATTERN.split(newPath);
|
||||
}
|
||||
|
||||
int numTokens = tokens != null ? tokens.length : 0;
|
||||
UriMatcher node = this;
|
||||
for (int i = -2; i < numTokens; i++) {
|
||||
String token;
|
||||
if (i == -2)
|
||||
token = scheme;
|
||||
else if (i == -1)
|
||||
token = authority;
|
||||
else
|
||||
token = tokens[i];
|
||||
ArrayList<UriMatcher> children = node.mChildren;
|
||||
int numChildren = children.size();
|
||||
UriMatcher child;
|
||||
int j;
|
||||
for (j = 0; j < numChildren; j++) {
|
||||
child = children.get(j);
|
||||
if (token.equals(child.mText)) {
|
||||
node = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == numChildren) {
|
||||
// Child not found, create it
|
||||
child = new UriMatcher();
|
||||
if (token.equals("**")) {
|
||||
child.mWhich = REST;
|
||||
} else if (token.equals("*")) {
|
||||
child.mWhich = TEXT;
|
||||
} else {
|
||||
child.mWhich = EXACT;
|
||||
}
|
||||
child.mText = token;
|
||||
node.mChildren.add(child);
|
||||
node = child;
|
||||
}
|
||||
}
|
||||
node.mCode = code;
|
||||
}
|
||||
|
||||
static final Pattern PATH_SPLIT_PATTERN = Pattern.compile("/");
|
||||
|
||||
/**
|
||||
* Try to match against the path in a url.
|
||||
*
|
||||
* @param uri The url whose path we will match against.
|
||||
* @return The code for the matched node (added using addURI),
|
||||
* or null if there is no matched node.
|
||||
*/
|
||||
public Object match(Uri uri) {
|
||||
final List<String> pathSegments = uri.getPathSegments();
|
||||
final int li = pathSegments.size();
|
||||
|
||||
UriMatcher node = this;
|
||||
|
||||
if (li == 0 && uri.getAuthority() == null) {
|
||||
return this.mCode;
|
||||
}
|
||||
|
||||
for (int i = -2; i < li; i++) {
|
||||
String u;
|
||||
if (i == -2)
|
||||
u = uri.getScheme();
|
||||
else if (i == -1)
|
||||
u = uri.getAuthority();
|
||||
else
|
||||
u = pathSegments.get(i);
|
||||
ArrayList<UriMatcher> list = node.mChildren;
|
||||
if (list == null) {
|
||||
break;
|
||||
}
|
||||
node = null;
|
||||
int lj = list.size();
|
||||
for (int j = 0; j < lj; j++) {
|
||||
UriMatcher n = list.get(j);
|
||||
which_switch:
|
||||
switch (n.mWhich) {
|
||||
case EXACT:
|
||||
if (n.mText.equals(u)) {
|
||||
node = n;
|
||||
}
|
||||
break;
|
||||
case TEXT:
|
||||
node = n;
|
||||
break;
|
||||
case REST:
|
||||
return n.mCode;
|
||||
}
|
||||
if (node != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node.mCode;
|
||||
}
|
||||
|
||||
private static final int EXACT = 0;
|
||||
private static final int TEXT = 1;
|
||||
private static final int REST = 2;
|
||||
|
||||
private Object mCode;
|
||||
private int mWhich;
|
||||
private String mText;
|
||||
private ArrayList<UriMatcher> mChildren;
|
||||
}
|
||||
+645
@@ -0,0 +1,645 @@
|
||||
/*
|
||||
Copyright 2015 Google Inc. All rights reserved.
|
||||
|
||||
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.
|
||||
*/
|
||||
package com.ionicframework.cordova.webview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
|
||||
import org.apache.cordova.ConfigXmlParser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Helper class meant to be used with the android.webkit.WebView class to enable hosting assets,
|
||||
* resources and other data on 'virtual' http(s):// URL.
|
||||
* Hosting assets and resources on http(s):// URLs is desirable as it is compatible with the
|
||||
* Same-Origin policy.
|
||||
* <p>
|
||||
* This class is intended to be used from within the
|
||||
* {@link android.webkit.WebViewClient#shouldInterceptRequest(android.webkit.WebView, String)} and
|
||||
* {@link android.webkit.WebViewClient#shouldInterceptRequest(android.webkit.WebView,
|
||||
* android.webkit.WebResourceRequest)}
|
||||
* methods.
|
||||
*/
|
||||
public class WebViewLocalServer {
|
||||
private static String TAG = "WebViewAssetServer";
|
||||
private String basePath;
|
||||
public final static String httpScheme = "http";
|
||||
public final static String httpsScheme = "https";
|
||||
public final static String fileStart = "/_app_file_";
|
||||
public final static String contentStart = "/_app_content_";
|
||||
|
||||
private final UriMatcher uriMatcher;
|
||||
private final AndroidProtocolHandler protocolHandler;
|
||||
private final String authority;
|
||||
private final String customScheme;
|
||||
// Whether we're serving local files or proxying (for example, when doing livereload on a
|
||||
// non-local endpoint (will be false in that case)
|
||||
private boolean isAsset;
|
||||
// Whether to route all requests to paths without extensions back to `index.html`
|
||||
private final boolean html5mode;
|
||||
private ConfigXmlParser parser;
|
||||
|
||||
public String getAuthority() { return authority; }
|
||||
|
||||
/**
|
||||
* A handler that produces responses for paths on the virtual asset server.
|
||||
* <p>
|
||||
* Methods of this handler will be invoked on a background thread and care must be taken to
|
||||
* correctly synchronize access to any shared state.
|
||||
* <p>
|
||||
* On Android KitKat and above these methods may be called on more than one thread. This thread
|
||||
* may be different than the thread on which the shouldInterceptRequest method was invoke.
|
||||
* This means that on Android KitKat and above it is possible to block in this method without
|
||||
* blocking other resources from loading. The number of threads used to parallelize loading
|
||||
* is an internal implementation detail of the WebView and may change between updates which
|
||||
* means that the amount of time spend blocking in this method should be kept to an absolute
|
||||
* minimum.
|
||||
*/
|
||||
public abstract static class PathHandler {
|
||||
protected String mimeType;
|
||||
private String encoding;
|
||||
private String charset;
|
||||
private int statusCode;
|
||||
private String reasonPhrase;
|
||||
private Map<String, String> responseHeaders;
|
||||
|
||||
public PathHandler() {
|
||||
this(null, null, 200, "OK", null);
|
||||
}
|
||||
|
||||
public PathHandler(String encoding, String charset, int statusCode,
|
||||
String reasonPhrase, Map<String, String> responseHeaders) {
|
||||
this.encoding = encoding;
|
||||
this.charset = charset;
|
||||
this.statusCode = statusCode;
|
||||
this.reasonPhrase = reasonPhrase;
|
||||
Map<String, String> tempResponseHeaders;
|
||||
if (responseHeaders == null) {
|
||||
tempResponseHeaders = new HashMap<String, String>();
|
||||
} else {
|
||||
tempResponseHeaders = responseHeaders;
|
||||
}
|
||||
tempResponseHeaders.put("Cache-Control", "no-cache");
|
||||
this.responseHeaders = tempResponseHeaders;
|
||||
}
|
||||
|
||||
abstract public InputStream handle(Uri url);
|
||||
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getReasonPhrase() {
|
||||
return reasonPhrase;
|
||||
}
|
||||
|
||||
public Map<String, String> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about the URLs used to host the assets in the WebView.
|
||||
*/
|
||||
public static class AssetHostingDetails {
|
||||
private Uri httpPrefix;
|
||||
private Uri httpsPrefix;
|
||||
|
||||
/*package*/ AssetHostingDetails(Uri httpPrefix, Uri httpsPrefix) {
|
||||
this.httpPrefix = httpPrefix;
|
||||
this.httpsPrefix = httpsPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the http: scheme prefix at which assets are hosted.
|
||||
*
|
||||
* @return the http: scheme prefix at which assets are hosted. Can return null.
|
||||
*/
|
||||
public Uri getHttpPrefix() {
|
||||
return httpPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the https: scheme prefix at which assets are hosted.
|
||||
*
|
||||
* @return the https: scheme prefix at which assets are hosted. Can return null.
|
||||
*/
|
||||
public Uri getHttpsPrefix() {
|
||||
return httpsPrefix;
|
||||
}
|
||||
}
|
||||
|
||||
WebViewLocalServer(Context context, String authority, boolean html5mode, ConfigXmlParser parser, String customScheme) {
|
||||
uriMatcher = new UriMatcher(null);
|
||||
this.html5mode = html5mode;
|
||||
this.parser = parser;
|
||||
this.protocolHandler = new AndroidProtocolHandler(context.getApplicationContext());
|
||||
this.authority = authority;
|
||||
this.customScheme = customScheme;
|
||||
}
|
||||
|
||||
private static Uri parseAndVerifyUrl(String url) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
Uri uri = Uri.parse(url);
|
||||
if (uri == null) {
|
||||
Log.e(TAG, "Malformed URL: " + url);
|
||||
return null;
|
||||
}
|
||||
String path = uri.getPath();
|
||||
if (path == null || path.length() == 0) {
|
||||
Log.e(TAG, "URL does not have a path: " + url);
|
||||
return null;
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
private static WebResourceResponse createWebResourceResponse(String mimeType, String encoding, int statusCode, String reasonPhrase, Map<String, String> responseHeaders, InputStream data) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
int finalStatusCode = statusCode;
|
||||
try {
|
||||
if (data.available() == 0) {
|
||||
finalStatusCode = 404;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
finalStatusCode = 500;
|
||||
}
|
||||
return new WebResourceResponse(mimeType, encoding, finalStatusCode, reasonPhrase, responseHeaders, data);
|
||||
} else {
|
||||
return new WebResourceResponse(mimeType, encoding, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to retrieve the WebResourceResponse associated with the given <code>request</code>.
|
||||
* This method should be invoked from within
|
||||
* {@link android.webkit.WebViewClient#shouldInterceptRequest(android.webkit.WebView,
|
||||
* android.webkit.WebResourceRequest)}.
|
||||
*
|
||||
* @param uri the request Uri to process.
|
||||
* @return a response if the request URL had a matching handler, null if no handler was found.
|
||||
*/
|
||||
public WebResourceResponse shouldInterceptRequest(Uri uri, WebResourceRequest request) {
|
||||
PathHandler handler;
|
||||
synchronized (uriMatcher) {
|
||||
handler = (PathHandler) uriMatcher.match(uri);
|
||||
}
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isLocalFile(uri) || uri.getAuthority().equals(this.authority)) {
|
||||
Log.d("SERVER", "Handling local request: " + uri.toString());
|
||||
return handleLocalRequest(uri, handler, request);
|
||||
} else {
|
||||
return handleProxyRequest(uri, handler);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLocalFile(Uri uri) {
|
||||
String path = uri.getPath();
|
||||
if (path.startsWith(contentStart) || path.startsWith(fileStart)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private WebResourceResponse handleLocalRequest(Uri uri, PathHandler handler, WebResourceRequest request) {
|
||||
String path = uri.getPath();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && request != null && request.getRequestHeaders().get("Range") != null) {
|
||||
InputStream responseStream = new LollipopLazyInputStream(handler, uri);
|
||||
String mimeType = getMimeType(path, responseStream);
|
||||
Map<String, String> tempResponseHeaders = handler.getResponseHeaders();
|
||||
int statusCode = 206;
|
||||
try {
|
||||
int totalRange = responseStream.available();
|
||||
String rangeString = request.getRequestHeaders().get("Range");
|
||||
String[] parts = rangeString.split("=");
|
||||
String[] streamParts = parts[1].split("-");
|
||||
String fromRange = streamParts[0];
|
||||
int range = totalRange-1;
|
||||
if (streamParts.length > 1) {
|
||||
range = Integer.parseInt(streamParts[1]);
|
||||
}
|
||||
tempResponseHeaders.put("Accept-Ranges", "bytes");
|
||||
tempResponseHeaders.put("Content-Range", "bytes " + fromRange + "-" + range + "/" + totalRange);
|
||||
} catch (IOException e) {
|
||||
statusCode = 404;
|
||||
}
|
||||
return createWebResourceResponse(mimeType, handler.getEncoding(),
|
||||
statusCode, handler.getReasonPhrase(), tempResponseHeaders, responseStream);
|
||||
}
|
||||
if (isLocalFile(uri)) {
|
||||
InputStream responseStream = new LollipopLazyInputStream(handler, uri);
|
||||
String mimeType = getMimeType(path, responseStream);
|
||||
return createWebResourceResponse(mimeType, handler.getEncoding(),
|
||||
handler.getStatusCode(), handler.getReasonPhrase(), handler.getResponseHeaders(), responseStream);
|
||||
}
|
||||
|
||||
if (path.equals("") || path.equals("/") || (!uri.getLastPathSegment().contains(".") && html5mode)) {
|
||||
InputStream stream;
|
||||
String launchURL = parser.getLaunchUrl();
|
||||
String launchFile = launchURL.substring(launchURL.lastIndexOf("/") + 1, launchURL.length());
|
||||
try {
|
||||
String startPath = this.basePath + "/" + launchFile;
|
||||
if (isAsset) {
|
||||
stream = protocolHandler.openAsset(startPath);
|
||||
} else {
|
||||
stream = protocolHandler.openFile(startPath);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Unable to open " + launchFile, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return createWebResourceResponse("text/html", handler.getEncoding(),
|
||||
handler.getStatusCode(), handler.getReasonPhrase(), handler.getResponseHeaders(), stream);
|
||||
}
|
||||
|
||||
int periodIndex = path.lastIndexOf(".");
|
||||
if (periodIndex >= 0) {
|
||||
InputStream responseStream = new LollipopLazyInputStream(handler, uri);
|
||||
String mimeType = getMimeType(path, responseStream);
|
||||
return createWebResourceResponse(mimeType, handler.getEncoding(),
|
||||
handler.getStatusCode(), handler.getReasonPhrase(), handler.getResponseHeaders(), responseStream);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of reading files from the filesystem/assets, proxy through to the URL
|
||||
* and let an external server handle it.
|
||||
* @param uri
|
||||
* @param handler
|
||||
* @return
|
||||
*/
|
||||
private WebResourceResponse handleProxyRequest(Uri uri, PathHandler handler) {
|
||||
try {
|
||||
String path = uri.getPath();
|
||||
URL url = new URL(uri.toString());
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setReadTimeout(30 * 1000);
|
||||
conn.setConnectTimeout(30 * 1000);
|
||||
|
||||
InputStream stream = conn.getInputStream();
|
||||
|
||||
if (path.equals("/") || (!uri.getLastPathSegment().contains(".") && html5mode)) {
|
||||
return createWebResourceResponse("text/html", handler.getEncoding(),
|
||||
handler.getStatusCode(), handler.getReasonPhrase(), handler.getResponseHeaders(), stream);
|
||||
}
|
||||
|
||||
int periodIndex = path.lastIndexOf(".");
|
||||
if (periodIndex >= 0) {
|
||||
String ext = path.substring(path.lastIndexOf("."), path.length());
|
||||
|
||||
// TODO: Conjure up a bit more subtlety than this
|
||||
if (ext.equals(".html")) {
|
||||
}
|
||||
|
||||
String mimeType = getMimeType(path, stream);
|
||||
|
||||
return createWebResourceResponse(mimeType, handler.getEncoding(),
|
||||
handler.getStatusCode(), handler.getReasonPhrase(), handler.getResponseHeaders(), stream);
|
||||
}
|
||||
|
||||
return createWebResourceResponse("", handler.getEncoding(),
|
||||
handler.getStatusCode(), handler.getReasonPhrase(), handler.getResponseHeaders(), stream);
|
||||
|
||||
} catch (SocketTimeoutException ex) {
|
||||
// bridge.handleAppUrlLoadError(ex);
|
||||
} catch (Exception ex) {
|
||||
// bridge.handleAppUrlLoadError(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getMimeType(String path, InputStream stream) {
|
||||
String mimeType = null;
|
||||
try {
|
||||
mimeType = URLConnection.guessContentTypeFromName(path); // Does not recognize *.js
|
||||
if (mimeType != null && path.endsWith(".js") && mimeType.equals("image/x-icon")) {
|
||||
Log.d(IonicWebViewEngine.TAG, "We shouldn't be here");
|
||||
}
|
||||
if (mimeType == null) {
|
||||
if (path.endsWith(".js") || path.endsWith(".mjs")) {
|
||||
// Make sure JS files get the proper mimetype to support ES modules
|
||||
mimeType = "application/javascript";
|
||||
} else if (path.endsWith(".wasm")) {
|
||||
mimeType = "application/wasm";
|
||||
} else {
|
||||
mimeType = URLConnection.guessContentTypeFromStream(stream);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Unable to get mime type" + path, ex);
|
||||
}
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a handler for the given <code>uri</code>. The <code>handler</code> will be invoked
|
||||
* every time the <code>shouldInterceptRequest</code> method of the instance is called with
|
||||
* a matching <code>uri</code>.
|
||||
*
|
||||
* @param uri the uri to use the handler for. The scheme and authority (domain) will be matched
|
||||
* exactly. The path may contain a '*' element which will match a single element of
|
||||
* a path (so a handler registered for /a/* will be invoked for /a/b and /a/c.html
|
||||
* but not for /a/b/b) or the '**' element which will match any number of path
|
||||
* elements.
|
||||
* @param handler the handler to use for the uri.
|
||||
*/
|
||||
void register(Uri uri, PathHandler handler) {
|
||||
synchronized (uriMatcher) {
|
||||
uriMatcher.addURI(uri.getScheme(), uri.getAuthority(), uri.getPath(), handler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosts the application's assets on an http(s):// URL. Assets from the local path
|
||||
* <code>assetPath/...</code> will be available under
|
||||
* <code>http(s)://{uuid}.androidplatform.net/assets/...</code>.
|
||||
*
|
||||
* @param assetPath the local path in the application's asset folder which will be made
|
||||
* available by the server (for example "/www").
|
||||
*/
|
||||
public void hostAssets(String assetPath) {
|
||||
hostAssets(authority, assetPath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hosts the application's assets on an http(s):// URL. Assets from the local path
|
||||
* <code>assetPath/...</code> will be available under
|
||||
* <code>http(s)://{domain}/{virtualAssetPath}/...</code>.
|
||||
*
|
||||
* @param domain custom domain on which the assets should be hosted (for example "example.com").
|
||||
* @param assetPath the local path in the application's asset folder which will be made
|
||||
* available by the server (for example "/www").
|
||||
* @return prefixes under which the assets are hosted.
|
||||
*/
|
||||
public void hostAssets(final String domain,
|
||||
final String assetPath) {
|
||||
this.isAsset = true;
|
||||
this.basePath = assetPath;
|
||||
|
||||
createHostingDetails();
|
||||
}
|
||||
|
||||
private void createHostingDetails() {
|
||||
final String assetPath = this.basePath;
|
||||
|
||||
if (assetPath.indexOf('*') != -1) {
|
||||
throw new IllegalArgumentException("assetPath cannot contain the '*' character.");
|
||||
}
|
||||
|
||||
PathHandler handler = new PathHandler() {
|
||||
@Override
|
||||
public InputStream handle(Uri url) {
|
||||
InputStream stream = null;
|
||||
String path = url.getPath();
|
||||
try {
|
||||
if (path.startsWith(contentStart)) {
|
||||
stream = protocolHandler.openContentUrl(url);
|
||||
} else if (path.startsWith(fileStart) || !isAsset) {
|
||||
if (!path.startsWith(fileStart)) {
|
||||
path = basePath + url.getPath();
|
||||
}
|
||||
stream = protocolHandler.openFile(path);
|
||||
} else {
|
||||
stream = protocolHandler.openAsset(assetPath + path);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Unable to open asset URL: " + url);
|
||||
return null;
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
registerUriForScheme(httpScheme, handler, authority);
|
||||
registerUriForScheme(httpsScheme, handler, authority);
|
||||
if (!customScheme.equals(httpScheme) && !customScheme.equals(httpsScheme)) {
|
||||
registerUriForScheme(customScheme, handler, authority);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void registerUriForScheme(String scheme, PathHandler handler, String authority) {
|
||||
Uri.Builder uriBuilder = new Uri.Builder();
|
||||
uriBuilder.scheme(scheme);
|
||||
uriBuilder.authority(authority);
|
||||
uriBuilder.path("");
|
||||
Uri uriPrefix = uriBuilder.build();
|
||||
|
||||
register(Uri.withAppendedPath(uriPrefix, "/"), handler);
|
||||
register(Uri.withAppendedPath(uriPrefix, "**"), handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosts the application's resources on an http(s):// URL. Resources
|
||||
* <code>http(s)://{uuid}.androidplatform.net/res/{resource_type}/{resource_name}</code>.
|
||||
*
|
||||
* @return prefixes under which the resources are hosted.
|
||||
*/
|
||||
public AssetHostingDetails hostResources() {
|
||||
return hostResources(authority, "/res", true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosts the application's resources on an http(s):// URL. Resources
|
||||
* <code>http(s)://{uuid}.androidplatform.net/{virtualResourcesPath}/{resource_type}/{resource_name}</code>.
|
||||
*
|
||||
* @param virtualResourcesPath the path on the local server under which the resources
|
||||
* should be hosted.
|
||||
* @param enableHttp whether to enable hosting using the http scheme.
|
||||
* @param enableHttps whether to enable hosting using the https scheme.
|
||||
* @return prefixes under which the resources are hosted.
|
||||
*/
|
||||
public AssetHostingDetails hostResources(final String virtualResourcesPath, boolean enableHttp,
|
||||
boolean enableHttps) {
|
||||
return hostResources(authority, virtualResourcesPath, enableHttp, enableHttps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosts the application's resources on an http(s):// URL. Resources
|
||||
* <code>http(s)://{domain}/{virtualResourcesPath}/{resource_type}/{resource_name}</code>.
|
||||
*
|
||||
* @param domain custom domain on which the assets should be hosted (for example "example.com").
|
||||
* If untrusted content is to be loaded into the WebView it is advised to make
|
||||
* this random.
|
||||
* @param virtualResourcesPath the path on the local server under which the resources
|
||||
* should be hosted.
|
||||
* @param enableHttp whether to enable hosting using the http scheme.
|
||||
* @param enableHttps whether to enable hosting using the https scheme.
|
||||
* @return prefixes under which the resources are hosted.
|
||||
*/
|
||||
public AssetHostingDetails hostResources(final String domain,
|
||||
final String virtualResourcesPath, boolean enableHttp,
|
||||
boolean enableHttps) {
|
||||
if (virtualResourcesPath.indexOf('*') != -1) {
|
||||
throw new IllegalArgumentException(
|
||||
"virtualResourcesPath cannot contain the '*' character.");
|
||||
}
|
||||
|
||||
Uri.Builder uriBuilder = new Uri.Builder();
|
||||
uriBuilder.scheme(httpScheme);
|
||||
uriBuilder.authority(domain);
|
||||
uriBuilder.path(virtualResourcesPath);
|
||||
|
||||
Uri httpPrefix = null;
|
||||
Uri httpsPrefix = null;
|
||||
|
||||
PathHandler handler = new PathHandler() {
|
||||
@Override
|
||||
public InputStream handle(Uri url) {
|
||||
InputStream stream = protocolHandler.openResource(url);
|
||||
String mimeType = null;
|
||||
try {
|
||||
mimeType = URLConnection.guessContentTypeFromStream(stream);
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Unable to get mime type" + url);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
if (enableHttp) {
|
||||
httpPrefix = uriBuilder.build();
|
||||
register(Uri.withAppendedPath(httpPrefix, "**"), handler);
|
||||
}
|
||||
if (enableHttps) {
|
||||
uriBuilder.scheme(httpsScheme);
|
||||
httpsPrefix = uriBuilder.build();
|
||||
register(Uri.withAppendedPath(httpsPrefix, "**"), handler);
|
||||
}
|
||||
return new AssetHostingDetails(httpPrefix, httpsPrefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hosts the application's files on an http(s):// URL. Files from the basePath
|
||||
* <code>basePath/...</code> will be available under
|
||||
* <code>http(s)://{uuid}.androidplatform.net/...</code>.
|
||||
*
|
||||
* @param basePath the local path in the application's data folder which will be made
|
||||
* available by the server (for example "/www").
|
||||
*/
|
||||
public void hostFiles(final String basePath) {
|
||||
this.isAsset = false;
|
||||
this.basePath = basePath;
|
||||
createHostingDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* The KitKat WebView reads the InputStream on a separate threadpool. We can use that to
|
||||
* parallelize loading.
|
||||
*/
|
||||
private static abstract class LazyInputStream extends InputStream {
|
||||
protected final PathHandler handler;
|
||||
private InputStream is = null;
|
||||
|
||||
public LazyInputStream(PathHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
private InputStream getInputStream() {
|
||||
if (is == null) {
|
||||
is = handle();
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
protected abstract InputStream handle();
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
InputStream is = getInputStream();
|
||||
return (is != null) ? is.available() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
InputStream is = getInputStream();
|
||||
return (is != null) ? is.read() : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte b[]) throws IOException {
|
||||
InputStream is = getInputStream();
|
||||
return (is != null) ? is.read(b) : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
InputStream is = getInputStream();
|
||||
return (is != null) ? is.read(b, off, len) : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long skip(long n) throws IOException {
|
||||
InputStream is = getInputStream();
|
||||
return (is != null) ? is.skip(n) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// For L and above.
|
||||
private static class LollipopLazyInputStream extends LazyInputStream {
|
||||
private Uri uri;
|
||||
private InputStream is;
|
||||
|
||||
public LollipopLazyInputStream(PathHandler handler, Uri uri) {
|
||||
super(handler);
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream handle() {
|
||||
return handler.handle(uri);
|
||||
}
|
||||
}
|
||||
|
||||
public String getBasePath(){
|
||||
return this.basePath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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 <WebKit/WebKit.h>
|
||||
|
||||
@interface CDVWKProcessPoolFactory : NSObject
|
||||
@property (nonatomic, retain) WKProcessPool* sharedPool;
|
||||
|
||||
+(instancetype) sharedFactory;
|
||||
-(WKProcessPool*) sharedProcessPool;
|
||||
@end
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
#import "CDVWKProcessPoolFactory.h"
|
||||
|
||||
static CDVWKProcessPoolFactory *factory = nil;
|
||||
|
||||
@implementation CDVWKProcessPoolFactory
|
||||
|
||||
+ (instancetype)sharedFactory
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
factory = [[CDVWKProcessPoolFactory alloc] init];
|
||||
});
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_sharedPool = [[WKProcessPool alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (WKProcessPool*) sharedProcessPool {
|
||||
return _sharedPool;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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 <WebKit/WebKit.h>
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
@interface CDVWKWebViewEngine : CDVPlugin <CDVWebViewEngineProtocol, WKScriptMessageHandler, WKNavigationDelegate>
|
||||
|
||||
@property (nonatomic, strong, readonly) id <WKUIDelegate> uiDelegate;
|
||||
@property (nonatomic, strong) NSString * basePath;
|
||||
|
||||
-(void)setServerBasePath:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getServerBasePath:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,825 @@
|
||||
/*
|
||||
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/NSDictionary+CordovaPreferences.h>
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <objc/message.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "CDVWKWebViewEngine.h"
|
||||
#import "CDVWKWebViewUIDelegate.h"
|
||||
#import "CDVWKProcessPoolFactory.h"
|
||||
#import "IONAssetHandler.h"
|
||||
|
||||
#define CDV_BRIDGE_NAME @"cordova"
|
||||
#define CDV_IONIC_STOP_SCROLL @"stopScroll"
|
||||
#define CDV_SERVER_PATH @"serverBasePath"
|
||||
#define LAST_BINARY_VERSION_CODE @"lastBinaryVersionCode"
|
||||
#define LAST_BINARY_VERSION_NAME @"lastBinaryVersionName"
|
||||
|
||||
@implementation UIScrollView (BugIOS11)
|
||||
|
||||
+ (void)load {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
Class class = [self class];
|
||||
SEL originalSelector = @selector(init);
|
||||
SEL swizzledSelector = @selector(xxx_init);
|
||||
|
||||
Method originalMethod = class_getInstanceMethod(class, originalSelector);
|
||||
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
|
||||
|
||||
BOOL didAddMethod =
|
||||
class_addMethod(class,
|
||||
originalSelector,
|
||||
method_getImplementation(swizzledMethod),
|
||||
method_getTypeEncoding(swizzledMethod));
|
||||
|
||||
if (didAddMethod) {
|
||||
class_replaceMethod(class,
|
||||
swizzledSelector,
|
||||
method_getImplementation(originalMethod),
|
||||
method_getTypeEncoding(originalMethod));
|
||||
} else {
|
||||
method_exchangeImplementations(originalMethod, swizzledMethod);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Method Swizzling
|
||||
|
||||
- (id)xxx_init {
|
||||
id a = [self xxx_init];
|
||||
NSArray *stack = [NSThread callStackSymbols];
|
||||
for(NSString *trace in stack) {
|
||||
if([trace containsString:@"WebKit"]) {
|
||||
[a setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface CDVWKWeakScriptMessageHandler : NSObject <WKScriptMessageHandler>
|
||||
|
||||
@property (nonatomic, weak, readonly) id<WKScriptMessageHandler>scriptMessageHandler;
|
||||
|
||||
- (instancetype)initWithScriptMessageHandler:(id<WKScriptMessageHandler>)scriptMessageHandler;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface CDVWKWebViewEngine ()
|
||||
|
||||
@property (nonatomic, strong, readwrite) UIView* engineWebView;
|
||||
@property (nonatomic, strong, readwrite) id <WKUIDelegate> uiDelegate;
|
||||
@property (nonatomic, weak) id <WKScriptMessageHandler> weakScriptMessageHandler;
|
||||
@property (nonatomic, readwrite) CGRect frame;
|
||||
@property (nonatomic, strong) NSString *userAgentCreds;
|
||||
@property (nonatomic, strong) IONAssetHandler * handler;
|
||||
|
||||
@property (nonatomic, readwrite) NSString *CDV_LOCAL_SERVER;
|
||||
@end
|
||||
|
||||
// expose private configuration value required for background operation
|
||||
@interface WKWebViewConfiguration ()
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// see forwardingTargetForSelector: selector comment for the reason for this pragma
|
||||
#pragma clang diagnostic ignored "-Wprotocol"
|
||||
|
||||
@implementation CDVWKWebViewEngine
|
||||
|
||||
@synthesize engineWebView = _engineWebView;
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (NSClassFromString(@"WKWebView") == nil) {
|
||||
return nil;
|
||||
}
|
||||
// add to keyWindow to ensure it is 'active'
|
||||
[UIApplication.sharedApplication.keyWindow addSubview:self.engineWebView];
|
||||
|
||||
self.frame = frame;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSString *) getStartPath {
|
||||
NSString * wwwPath = [[NSBundle mainBundle] pathForResource:@"www" ofType: nil];
|
||||
|
||||
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
NSString * persistedPath = [userDefaults objectForKey:CDV_SERVER_PATH];
|
||||
if (![self isDeployDisabled] && ![self isNewBinary] && persistedPath && ![persistedPath isEqualToString:@""]) {
|
||||
NSString *libPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
NSString * cordovaDataDirectory = [libPath stringByAppendingPathComponent:@"NoCloud"];
|
||||
NSString * snapshots = [cordovaDataDirectory stringByAppendingPathComponent:@"ionic_built_snapshots"];
|
||||
wwwPath = [snapshots stringByAppendingPathComponent:[persistedPath lastPathComponent]];
|
||||
}
|
||||
self.basePath = wwwPath;
|
||||
return wwwPath;
|
||||
}
|
||||
|
||||
-(BOOL) isNewBinary
|
||||
{
|
||||
NSString * versionCode = [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"];
|
||||
NSString * versionName = [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"];
|
||||
NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
|
||||
NSString * lastVersionCode = [prefs stringForKey:LAST_BINARY_VERSION_CODE];
|
||||
NSString * lastVersionName = [prefs stringForKey:LAST_BINARY_VERSION_NAME];
|
||||
if (![versionCode isEqualToString:lastVersionCode] || ![versionName isEqualToString:lastVersionName]) {
|
||||
[prefs setObject:versionCode forKey:LAST_BINARY_VERSION_CODE];
|
||||
[prefs setObject:versionName forKey:LAST_BINARY_VERSION_NAME];
|
||||
[prefs setObject:@"" forKey:CDV_SERVER_PATH];
|
||||
[prefs synchronize];
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
-(BOOL) isDeployDisabled {
|
||||
return [[self.commandDelegate.settings objectForKey:[@"DisableDeploy" lowercaseString]] boolValue];
|
||||
}
|
||||
|
||||
- (WKWebViewConfiguration*) createConfigurationFromSettings:(NSDictionary*)settings
|
||||
{
|
||||
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
|
||||
configuration.processPool = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
|
||||
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
|
||||
|
||||
if (settings == nil) {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
if(![settings cordovaBoolSettingForKey:@"WKSuspendInBackground" defaultValue:YES]){
|
||||
NSString* _BGStatus;
|
||||
if (@available(iOS 12.2, *)) {
|
||||
// do stuff for iOS 12.2 and newer
|
||||
NSLog(@"iOS 12.2+ detected");
|
||||
NSString* str = @"YWx3YXlzUnVuc0F0Rm9yZWdyb3VuZFByaW9yaXR5";
|
||||
NSData* data = [[NSData alloc] initWithBase64EncodedString:str options:0];
|
||||
_BGStatus = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
} else {
|
||||
// do stuff for iOS 12.1 and older
|
||||
NSLog(@"iOS Below 12.2 detected");
|
||||
NSString* str = @"X2Fsd2F5c1J1bnNBdEZvcmVncm91bmRQcmlvcml0eQ==";
|
||||
NSData* data = [[NSData alloc] initWithBase64EncodedString:str options:0];
|
||||
_BGStatus = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
[configuration setValue:[NSNumber numberWithBool:YES]
|
||||
forKey:_BGStatus];
|
||||
}
|
||||
NSString *userAgent = configuration.applicationNameForUserAgent;
|
||||
if (
|
||||
[settings cordovaSettingForKey:@"OverrideUserAgent"] == nil &&
|
||||
[settings cordovaSettingForKey:@"AppendUserAgent"] != nil
|
||||
) {
|
||||
userAgent = [NSString stringWithFormat:@"%@ %@", userAgent, [settings cordovaSettingForKey:@"AppendUserAgent"]];
|
||||
}
|
||||
configuration.applicationNameForUserAgent = userAgent;
|
||||
configuration.allowsInlineMediaPlayback = [settings cordovaBoolSettingForKey:@"AllowInlineMediaPlayback" defaultValue:YES];
|
||||
configuration.suppressesIncrementalRendering = [settings cordovaBoolSettingForKey:@"SuppressesIncrementalRendering" defaultValue:NO];
|
||||
configuration.allowsAirPlayForMediaPlayback = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay" defaultValue:YES];
|
||||
return configuration;
|
||||
}
|
||||
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
// viewController would be available now. we attempt to set all possible delegates to it, by default
|
||||
NSDictionary* settings = self.commandDelegate.settings;
|
||||
NSString *bind = [settings cordovaSettingForKey:@"Hostname"];
|
||||
if(bind == nil){
|
||||
bind = @"localhost";
|
||||
}
|
||||
NSString *scheme = [settings cordovaSettingForKey:@"iosScheme"];
|
||||
if(scheme == nil || [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"file"]){
|
||||
scheme = @"ionic";
|
||||
}
|
||||
self.CDV_LOCAL_SERVER = [NSString stringWithFormat:@"%@://%@", scheme, bind];
|
||||
|
||||
self.uiDelegate = [[CDVWKWebViewUIDelegate alloc] initWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
|
||||
|
||||
CDVWKWeakScriptMessageHandler *weakScriptMessageHandler = [[CDVWKWeakScriptMessageHandler alloc] initWithScriptMessageHandler:self];
|
||||
|
||||
WKUserContentController* userContentController = [[WKUserContentController alloc] init];
|
||||
[userContentController addScriptMessageHandler:weakScriptMessageHandler name:CDV_BRIDGE_NAME];
|
||||
[userContentController addScriptMessageHandler:weakScriptMessageHandler name:CDV_IONIC_STOP_SCROLL];
|
||||
|
||||
// Inject XHR Polyfill
|
||||
NSLog(@"CDVWKWebViewEngine: trying to inject XHR polyfill");
|
||||
WKUserScript *wkScript = [self wkPluginScript];
|
||||
if (wkScript) {
|
||||
[userContentController addUserScript:wkScript];
|
||||
}
|
||||
|
||||
WKUserScript *configScript = [self configScript];
|
||||
if (configScript) {
|
||||
[userContentController addUserScript:configScript];
|
||||
}
|
||||
|
||||
BOOL autoCordova = [settings cordovaBoolSettingForKey:@"AutoInjectCordova" defaultValue:NO];
|
||||
if (autoCordova){
|
||||
NSLog(@"CDVWKWebViewEngine: trying to inject XHR polyfill");
|
||||
WKUserScript *cordova = [self autoCordovify];
|
||||
if (cordova) {
|
||||
[userContentController addUserScript:cordova];
|
||||
}
|
||||
}
|
||||
|
||||
BOOL audioCanMix = [settings cordovaBoolSettingForKey:@"AudioCanMix" defaultValue:NO];
|
||||
if (audioCanMix) {
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
|
||||
withOptions:AVAudioSessionCategoryOptionMixWithOthers
|
||||
error:nil];
|
||||
}
|
||||
|
||||
WKWebViewConfiguration* configuration = [self createConfigurationFromSettings:settings];
|
||||
configuration.userContentController = userContentController;
|
||||
|
||||
self.handler = [[IONAssetHandler alloc] initWithBasePath:[self getStartPath] andScheme:scheme];
|
||||
[configuration setURLSchemeHandler:self.handler forURLScheme:scheme];
|
||||
|
||||
// re-create WKWebView, since we need to update configuration
|
||||
// remove from keyWindow before recreating
|
||||
[self.engineWebView removeFromSuperview];
|
||||
WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:self.frame configuration:configuration];
|
||||
|
||||
[wkWebView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
|
||||
|
||||
wkWebView.UIDelegate = self.uiDelegate;
|
||||
self.engineWebView = wkWebView;
|
||||
// add to keyWindow to ensure it is 'active'
|
||||
[UIApplication.sharedApplication.keyWindow addSubview:self.engineWebView];
|
||||
|
||||
NSString * overrideUserAgent = [settings cordovaSettingForKey:@"OverrideUserAgent"];
|
||||
if (overrideUserAgent != nil) {
|
||||
wkWebView.customUserAgent = overrideUserAgent;
|
||||
}
|
||||
|
||||
if ([self.viewController conformsToProtocol:@protocol(WKUIDelegate)]) {
|
||||
wkWebView.UIDelegate = (id <WKUIDelegate>)self.viewController;
|
||||
}
|
||||
|
||||
if ([self.viewController conformsToProtocol:@protocol(WKNavigationDelegate)]) {
|
||||
wkWebView.navigationDelegate = (id <WKNavigationDelegate>)self.viewController;
|
||||
} else {
|
||||
wkWebView.navigationDelegate = (id <WKNavigationDelegate>)self;
|
||||
}
|
||||
|
||||
if ([self.viewController conformsToProtocol:@protocol(WKScriptMessageHandler)]) {
|
||||
[wkWebView.configuration.userContentController addScriptMessageHandler:(id < WKScriptMessageHandler >)self.viewController name:CDV_BRIDGE_NAME];
|
||||
}
|
||||
|
||||
[self keyboardDisplayDoesNotRequireUserAction];
|
||||
|
||||
if ([settings cordovaBoolSettingForKey:@"KeyboardAppearanceDark" defaultValue:NO]) {
|
||||
[self setKeyboardAppearanceDark];
|
||||
}
|
||||
|
||||
[self updateSettings:settings];
|
||||
|
||||
// check if content thread has died on resume
|
||||
NSLog(@"%@", @"CDVWKWebViewEngine will reload WKWebView if required on resume");
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(onAppWillEnterForeground:)
|
||||
name:UIApplicationWillEnterForegroundNotification object:nil];
|
||||
|
||||
// If less than ios 13.4
|
||||
if (@available(iOS 13.4, *)) {} else {
|
||||
// For keyboard dismissal leaving viewport shifted (can potentially be removed when apple releases the fix for the issue discussed here: https://github.com/apache/cordova-ios/issues/417#issuecomment-423340885)
|
||||
// Apple has released a fix in 13.4, but not in 12.x (as of 12.4.6)
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(keyboardWillHide)
|
||||
name:UIKeyboardWillHideNotification object:nil];
|
||||
}
|
||||
|
||||
NSLog(@"Using Ionic WKWebView");
|
||||
|
||||
}
|
||||
|
||||
// https://github.com/Telerik-Verified-Plugins/WKWebView/commit/04e8296adeb61f289f9c698045c19b62d080c7e3#L609-L620
|
||||
- (void) keyboardDisplayDoesNotRequireUserAction {
|
||||
Class class = NSClassFromString(@"WKContentView");
|
||||
NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
|
||||
NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
|
||||
NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
|
||||
char * methodSignature = "_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
|
||||
|
||||
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_13_0_0]) {
|
||||
methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:";
|
||||
} else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
|
||||
methodSignature = "_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:";
|
||||
}
|
||||
|
||||
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
|
||||
SEL selector = sel_getUid(methodSignature);
|
||||
Method method = class_getInstanceMethod(class, selector);
|
||||
IMP original = method_getImplementation(method);
|
||||
IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
|
||||
((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
|
||||
});
|
||||
method_setImplementation(method, override);
|
||||
} else {
|
||||
SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
|
||||
Method method = class_getInstanceMethod(class, selector);
|
||||
IMP original = method_getImplementation(method);
|
||||
IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
|
||||
((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
|
||||
});
|
||||
method_setImplementation(method, override);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setKeyboardAppearanceDark
|
||||
{
|
||||
IMP darkImp = imp_implementationWithBlock(^(id _s) {
|
||||
return UIKeyboardAppearanceDark;
|
||||
});
|
||||
for (NSString* classString in @[@"WKContentView", @"UITextInputTraits"]) {
|
||||
Class c = NSClassFromString(classString);
|
||||
Method m = class_getInstanceMethod(c, @selector(keyboardAppearance));
|
||||
if (m != NULL) {
|
||||
method_setImplementation(m, darkImp);
|
||||
} else {
|
||||
class_addMethod(c, @selector(keyboardAppearance), darkImp, "l@:");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)onAppWillEnterForeground:(NSNotification *)notification {
|
||||
if ([self shouldReloadWebView]) {
|
||||
NSLog(@"%@", @"CDVWKWebViewEngine reloading!");
|
||||
[(WKWebView*)_engineWebView reload];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)keyboardWillHide
|
||||
{
|
||||
// For keyboard dismissal leaving viewport shifted (can potentially be removed when apple releases the fix for the issue discussed here: https://github.com/apache/cordova-ios/issues/417#issuecomment-423340885)
|
||||
UIScrollView * scrollView = self.webView.scrollView;
|
||||
// Calculate some vars for convenience
|
||||
CGFloat contentLengthWithInsets = scrollView.contentSize.height + scrollView.adjustedContentInset.top + scrollView.adjustedContentInset.bottom;
|
||||
CGFloat contentOffsetY = scrollView.contentOffset.y;
|
||||
CGFloat screenHeight = scrollView.frame.size.height;
|
||||
CGFloat maxAllowedOffsetY = fmax(contentLengthWithInsets - screenHeight, 0); // 0 is for the case where content is shorter than screen
|
||||
|
||||
// If the keyboard allowed the user to get to an offset beyond the max
|
||||
if (contentOffsetY > maxAllowedOffsetY) {
|
||||
// Reset the scroll to the max allowed so that there is no additional empty white space at the bottom where the keyboard occupied!
|
||||
CGPoint bottomOfPage = CGPointMake(scrollView.contentOffset.x, maxAllowedOffsetY);
|
||||
[scrollView setContentOffset:bottomOfPage];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldReloadWebView
|
||||
{
|
||||
WKWebView* wkWebView = (WKWebView*)_engineWebView;
|
||||
return [self shouldReloadWebView:wkWebView.URL title:wkWebView.title];
|
||||
}
|
||||
|
||||
- (BOOL)shouldReloadWebView:(NSURL *)location title:(NSString*)title
|
||||
{
|
||||
BOOL title_is_nil = (title == nil);
|
||||
BOOL location_is_blank = [[location absoluteString] isEqualToString:@"about:blank"];
|
||||
|
||||
BOOL reload = (title_is_nil || location_is_blank);
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%@", @"CDVWKWebViewEngine shouldReloadWebView::");
|
||||
NSLog(@"CDVWKWebViewEngine shouldReloadWebView title: %@", title);
|
||||
NSLog(@"CDVWKWebViewEngine shouldReloadWebView location: %@", [location absoluteString]);
|
||||
NSLog(@"CDVWKWebViewEngine shouldReloadWebView reload: %u", reload);
|
||||
#endif
|
||||
|
||||
return reload;
|
||||
}
|
||||
|
||||
|
||||
- (id)loadRequest:(NSURLRequest *)request
|
||||
{
|
||||
if (request.URL.fileURL) {
|
||||
NSURL* startURL = [NSURL URLWithString:((CDVViewController *)self.viewController).startPage];
|
||||
NSString* startFilePath = [self.commandDelegate pathForResource:[startURL path]];
|
||||
NSURL *url = [[NSURL URLWithString:self.CDV_LOCAL_SERVER] URLByAppendingPathComponent:request.URL.path];
|
||||
if ([request.URL.path isEqualToString:startFilePath]) {
|
||||
url = [NSURL URLWithString:self.CDV_LOCAL_SERVER];
|
||||
}
|
||||
if(request.URL.query) {
|
||||
url = [NSURL URLWithString:[@"?" stringByAppendingString:request.URL.query] relativeToURL:url];
|
||||
}
|
||||
if(request.URL.fragment) {
|
||||
url = [NSURL URLWithString:[@"#" stringByAppendingString:request.URL.fragment] relativeToURL:url];
|
||||
}
|
||||
request = [NSURLRequest requestWithURL:url];
|
||||
}
|
||||
return [(WKWebView*)_engineWebView loadRequest:request];
|
||||
}
|
||||
|
||||
- (id)loadHTMLString:(NSString *)string baseURL:(NSURL*)baseURL
|
||||
{
|
||||
return [(WKWebView*)_engineWebView loadHTMLString:string baseURL:baseURL];
|
||||
}
|
||||
|
||||
- (NSURL*) URL
|
||||
{
|
||||
return [(WKWebView*)_engineWebView URL];
|
||||
}
|
||||
|
||||
- (BOOL)canLoadRequest:(NSURLRequest *)request
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
- (void)updateSettings:(NSDictionary *)settings
|
||||
{
|
||||
WKWebView* wkWebView = (WKWebView *)_engineWebView;
|
||||
|
||||
// By default, DisallowOverscroll is false (thus bounce is allowed)
|
||||
BOOL bounceAllowed = !([settings cordovaBoolSettingForKey:@"DisallowOverscroll" defaultValue:NO]);
|
||||
|
||||
// prevent webView from bouncing
|
||||
if (!bounceAllowed) {
|
||||
if ([wkWebView respondsToSelector:@selector(scrollView)]) {
|
||||
((UIScrollView*)[wkWebView scrollView]).bounces = NO;
|
||||
} else {
|
||||
for (id subview in wkWebView.subviews) {
|
||||
if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
|
||||
((UIScrollView*)subview).bounces = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wkWebView.configuration.preferences.minimumFontSize = [settings cordovaFloatSettingForKey:@"MinimumFontSize" defaultValue:0.0];
|
||||
wkWebView.allowsLinkPreview = [settings cordovaBoolSettingForKey:@"AllowLinkPreview" defaultValue:NO];
|
||||
wkWebView.scrollView.scrollEnabled = [settings cordovaBoolSettingForKey:@"ScrollEnabled" defaultValue:NO];
|
||||
wkWebView.allowsBackForwardNavigationGestures = [settings cordovaBoolSettingForKey:@"AllowBackForwardNavigationGestures" defaultValue:NO];
|
||||
}
|
||||
|
||||
- (void)updateWithInfo:(NSDictionary *)info
|
||||
{
|
||||
NSDictionary* scriptMessageHandlers = [info objectForKey:kCDVWebViewEngineScriptMessageHandlers];
|
||||
NSDictionary* settings = [info objectForKey:kCDVWebViewEngineWebViewPreferences];
|
||||
id navigationDelegate = [info objectForKey:kCDVWebViewEngineWKNavigationDelegate];
|
||||
id uiDelegate = [info objectForKey:kCDVWebViewEngineWKUIDelegate];
|
||||
|
||||
WKWebView* wkWebView = (WKWebView*)_engineWebView;
|
||||
|
||||
if (scriptMessageHandlers && [scriptMessageHandlers isKindOfClass:[NSDictionary class]]) {
|
||||
NSArray* allKeys = [scriptMessageHandlers allKeys];
|
||||
|
||||
for (NSString* key in allKeys) {
|
||||
id object = [scriptMessageHandlers objectForKey:key];
|
||||
if ([object conformsToProtocol:@protocol(WKScriptMessageHandler)]) {
|
||||
[wkWebView.configuration.userContentController addScriptMessageHandler:object name:key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (navigationDelegate && [navigationDelegate conformsToProtocol:@protocol(WKNavigationDelegate)]) {
|
||||
wkWebView.navigationDelegate = navigationDelegate;
|
||||
}
|
||||
|
||||
if (uiDelegate && [uiDelegate conformsToProtocol:@protocol(WKUIDelegate)]) {
|
||||
wkWebView.UIDelegate = uiDelegate;
|
||||
}
|
||||
|
||||
if (settings && [settings isKindOfClass:[NSDictionary class]]) {
|
||||
[self updateSettings:settings];
|
||||
}
|
||||
}
|
||||
|
||||
// This forwards the methods that are in the header that are not implemented here.
|
||||
// loadHTMLString:baseURL:
|
||||
// loadRequest:
|
||||
- (id)forwardingTargetForSelector:(SEL)aSelector
|
||||
{
|
||||
return _engineWebView;
|
||||
}
|
||||
|
||||
- (UIView *)webView
|
||||
{
|
||||
return self.engineWebView;
|
||||
}
|
||||
|
||||
- (WKUserScript *)wkPluginScript
|
||||
{
|
||||
NSString *scriptFile = [[NSBundle mainBundle] pathForResource:@"www/wk-plugin" ofType:@"js"];
|
||||
if (scriptFile == nil) {
|
||||
NSLog(@"CDVWKWebViewEngine: WK plugin was not found");
|
||||
return nil;
|
||||
}
|
||||
NSError *error = nil;
|
||||
NSString *source = [NSString stringWithContentsOfFile:scriptFile encoding:NSUTF8StringEncoding error:&error];
|
||||
if (source == nil || error != nil) {
|
||||
NSLog(@"CDVWKWebViewEngine: WK plugin can not be loaded: %@", error);
|
||||
return nil;
|
||||
}
|
||||
source = [source stringByAppendingString:[NSString stringWithFormat:@"window.WEBVIEW_SERVER_URL = '%@';", self.CDV_LOCAL_SERVER]];
|
||||
|
||||
return [[WKUserScript alloc] initWithSource:source
|
||||
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
|
||||
forMainFrameOnly:YES];
|
||||
}
|
||||
|
||||
- (WKUserScript *)configScript
|
||||
{
|
||||
Class keyboard = NSClassFromString(@"CDVIonicKeyboard");
|
||||
BOOL keyboardPlugin = keyboard != nil;
|
||||
if(!keyboardPlugin) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
BOOL keyboardResizes = [self.commandDelegate.settings cordovaBoolSettingForKey:@"KeyboardResize" defaultValue:YES];
|
||||
NSString *source = [NSString stringWithFormat:
|
||||
@"window.Ionic = window.Ionic || {};"
|
||||
@"window.Ionic.keyboardPlugin=true;"
|
||||
@"window.Ionic.keyboardResizes=%@",
|
||||
keyboardResizes ? @"true" : @"false"];
|
||||
|
||||
return [[WKUserScript alloc] initWithSource:source
|
||||
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
|
||||
forMainFrameOnly:YES];
|
||||
}
|
||||
|
||||
- (WKUserScript *)autoCordovify
|
||||
{
|
||||
NSURL *cordovaURL = [[NSBundle mainBundle] URLForResource:@"www/cordova" withExtension:@"js"];
|
||||
if (cordovaURL == nil) {
|
||||
NSLog(@"CDVWKWebViewEngine: cordova.js WAS NOT FOUND");
|
||||
return nil;
|
||||
}
|
||||
NSError *error = nil;
|
||||
NSString *source = [NSString stringWithContentsOfURL:cordovaURL encoding:NSUTF8StringEncoding error:&error];
|
||||
if (source == nil || error != nil) {
|
||||
NSLog(@"CDVWKWebViewEngine: cordova.js can not be loaded: %@", error);
|
||||
return nil;
|
||||
}
|
||||
NSLog(@"CDVWKWebViewEngine: auto injecting cordova");
|
||||
NSString *cordovaPath = [self.CDV_LOCAL_SERVER stringByAppendingString:cordovaURL.URLByDeletingLastPathComponent.path];
|
||||
NSString *replacement = [NSString stringWithFormat:@"var pathPrefix = '%@/';", cordovaPath];
|
||||
source = [source stringByReplacingOccurrencesOfString:@"var pathPrefix = findCordovaPath();" withString:replacement];
|
||||
|
||||
return [[WKUserScript alloc] initWithSource:source
|
||||
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
|
||||
forMainFrameOnly:YES];
|
||||
}
|
||||
|
||||
#pragma mark WKScriptMessageHandler implementation
|
||||
|
||||
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
|
||||
{
|
||||
if ([message.name isEqualToString:CDV_BRIDGE_NAME]) {
|
||||
[self handleCordovaMessage: message];
|
||||
} else if ([message.name isEqualToString:CDV_IONIC_STOP_SCROLL]) {
|
||||
[self handleStopScroll];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleCordovaMessage:(WKScriptMessage*)message
|
||||
{
|
||||
CDVViewController *vc = (CDVViewController*)self.viewController;
|
||||
|
||||
NSArray *jsonEntry = message.body; // NSString:callbackId, NSString:service, NSString:action, NSArray:args
|
||||
CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonEntry];
|
||||
CDV_EXEC_LOG(@"Exec(%@): Calling %@.%@", command.callbackId, command.className, command.methodName);
|
||||
|
||||
if (![vc.commandQueue execute:command]) {
|
||||
#ifdef DEBUG
|
||||
NSError* error = nil;
|
||||
NSString* commandJson = nil;
|
||||
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:jsonEntry
|
||||
options:0
|
||||
error:&error];
|
||||
|
||||
if (error == nil) {
|
||||
commandJson = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
static NSUInteger maxLogLength = 1024;
|
||||
NSString* commandString = ([commandJson length] > maxLogLength) ?
|
||||
[NSString stringWithFormat : @"%@[...]", [commandJson substringToIndex:maxLogLength]] :
|
||||
commandJson;
|
||||
|
||||
NSLog(@"FAILED pluginJSON = %@", commandString);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleStopScroll
|
||||
{
|
||||
WKWebView* wkWebView = (WKWebView*)_engineWebView;
|
||||
NSLog(@"CDVWKWebViewEngine: handleStopScroll");
|
||||
[self recursiveStopScroll:[wkWebView scrollView]];
|
||||
[wkWebView evaluateJavaScript:@"window.IonicStopScroll.fire()" completionHandler:nil];
|
||||
}
|
||||
|
||||
- (void)recursiveStopScroll:(UIView *)node
|
||||
{
|
||||
if([node isKindOfClass: [UIScrollView class]]) {
|
||||
UIScrollView *nodeAsScroll = (UIScrollView *)node;
|
||||
|
||||
if([nodeAsScroll isScrollEnabled] && ![nodeAsScroll isHidden]) {
|
||||
[nodeAsScroll setScrollEnabled: NO];
|
||||
[nodeAsScroll setScrollEnabled: YES];
|
||||
}
|
||||
}
|
||||
|
||||
// iterate tree recursivelly
|
||||
for (UIView *child in [node subviews]) {
|
||||
[self recursiveStopScroll:child];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark WKNavigationDelegate implementation
|
||||
|
||||
- (void)webView:(WKWebView*)webView didStartProvisionalNavigation:(WKNavigation*)navigation
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginResetNotification object:webView]];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation
|
||||
{
|
||||
#ifndef __CORDOVA_6_0_0
|
||||
CDVViewController* vc = (CDVViewController*)self.viewController;
|
||||
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
|
||||
#endif
|
||||
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:webView]];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView*)theWebView didFailProvisionalNavigation:(WKNavigation*)navigation withError:(NSError*)error
|
||||
{
|
||||
[self webView:theWebView didFailNavigation:navigation withError:error];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView*)theWebView didFailNavigation:(WKNavigation*)navigation withError:(NSError*)error
|
||||
{
|
||||
CDVViewController* vc = (CDVViewController*)self.viewController;
|
||||
#ifndef __CORDOVA_6_0_0
|
||||
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
|
||||
#endif
|
||||
|
||||
NSString* message = [NSString stringWithFormat:@"Failed to load webpage with error: %@", [error localizedDescription]];
|
||||
NSLog(@"%@", message);
|
||||
|
||||
NSURL* errorUrl = vc.errorURL;
|
||||
if (errorUrl) {
|
||||
NSCharacterSet *charSet = [NSCharacterSet URLFragmentAllowedCharacterSet];
|
||||
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [message stringByAddingPercentEncodingWithAllowedCharacters:charSet]] relativeToURL:errorUrl];
|
||||
NSLog(@"%@", [errorUrl absoluteString]);
|
||||
[theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
|
||||
}
|
||||
#ifdef DEBUG
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] message:message preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:nil]];
|
||||
[vc presentViewController:alertController animated:YES completion:nil];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView
|
||||
{
|
||||
[webView reload];
|
||||
}
|
||||
|
||||
- (BOOL)defaultResourcePolicyForURL:(NSURL*)url
|
||||
{
|
||||
// all file:// urls are allowed
|
||||
if ([url isFileURL]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
|
||||
{
|
||||
NSURL* url = [navigationAction.request URL];
|
||||
CDVViewController* vc = (CDVViewController*)self.viewController;
|
||||
|
||||
/*
|
||||
* Give plugins the chance to handle the url
|
||||
*/
|
||||
BOOL anyPluginsResponded = NO;
|
||||
BOOL shouldAllowRequest = NO;
|
||||
|
||||
for (NSString* pluginName in vc.pluginObjects) {
|
||||
CDVPlugin* plugin = [vc.pluginObjects objectForKey:pluginName];
|
||||
SEL selector = NSSelectorFromString(@"shouldOverrideLoadWithRequest:navigationType:");
|
||||
if ([plugin respondsToSelector:selector]) {
|
||||
anyPluginsResponded = YES;
|
||||
// https://issues.apache.org/jira/browse/CB-12497
|
||||
int navType = (int)navigationAction.navigationType;
|
||||
if (WKNavigationTypeOther == navigationAction.navigationType) {
|
||||
#ifdef __CORDOVA_6_0_0
|
||||
navType = -1;
|
||||
#else
|
||||
navType = 5;
|
||||
#endif
|
||||
}
|
||||
shouldAllowRequest = (((BOOL (*)(id, SEL, id, int))objc_msgSend)(plugin, selector, navigationAction.request, navType));
|
||||
if (!shouldAllowRequest) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyPluginsResponded) {
|
||||
/*
|
||||
* Handle all other types of urls (tel:, sms:), and requests to load a url in the main webview.
|
||||
*/
|
||||
shouldAllowRequest = [self defaultResourcePolicyForURL:url];
|
||||
if (!shouldAllowRequest) {
|
||||
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldAllowRequest) {
|
||||
NSString *scheme = url.scheme;
|
||||
if ([scheme isEqualToString:@"tel"] ||
|
||||
[scheme isEqualToString:@"mailto"] ||
|
||||
[scheme isEqualToString:@"facetime"] ||
|
||||
[scheme isEqualToString:@"sms"] ||
|
||||
[scheme isEqualToString:@"maps"]) {
|
||||
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
|
||||
decisionHandler(WKNavigationActionPolicyCancel);
|
||||
} else {
|
||||
decisionHandler(WKNavigationActionPolicyAllow);
|
||||
}
|
||||
} else {
|
||||
decisionHandler(WKNavigationActionPolicyCancel);
|
||||
}
|
||||
}
|
||||
|
||||
-(void)getServerBasePath:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:self.basePath] callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
-(void)setServerBasePath:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSString * path = [command argumentAtIndex:0];
|
||||
self.basePath = path;
|
||||
[self.handler setAssetPath:path];
|
||||
|
||||
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.CDV_LOCAL_SERVER]];
|
||||
[(WKWebView*)_engineWebView loadRequest:request];
|
||||
}
|
||||
|
||||
-(void)persistServerBasePath:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
[userDefaults setObject:[self.basePath lastPathComponent] forKey:CDV_SERVER_PATH];
|
||||
[userDefaults synchronize];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - CDVWKWeakScriptMessageHandler
|
||||
|
||||
@implementation CDVWKWeakScriptMessageHandler
|
||||
|
||||
- (instancetype)initWithScriptMessageHandler:(id<WKScriptMessageHandler>)scriptMessageHandler
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_scriptMessageHandler = scriptMessageHandler;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
|
||||
{
|
||||
[self.scriptMessageHandler userContentController:userContentController didReceiveScriptMessage:message];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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 <WebKit/WebKit.h>
|
||||
|
||||
@interface CDVWKWebViewUIDelegate : NSObject <WKUIDelegate>
|
||||
|
||||
@property (nonatomic, copy) NSString* title;
|
||||
|
||||
- (instancetype)initWithTitle:(NSString*)title;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
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 "CDVWKWebViewUIDelegate.h"
|
||||
|
||||
@implementation CDVWKWebViewUIDelegate
|
||||
|
||||
- (instancetype)initWithTitle:(NSString*)title
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.title = title;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView*)webView runJavaScriptAlertPanelWithMessage:(NSString*)message
|
||||
initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)(void))completionHandler
|
||||
{
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler();
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
|
||||
[alert addAction:ok];
|
||||
|
||||
UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
|
||||
[rootController presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView*)webView runJavaScriptConfirmPanelWithMessage:(NSString*)message
|
||||
initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)(BOOL result))completionHandler
|
||||
{
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(YES);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
|
||||
[alert addAction:ok];
|
||||
|
||||
UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(NO);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
[alert addAction:cancel];
|
||||
|
||||
UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
|
||||
[rootController presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView*)webView runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt
|
||||
defaultText:(NSString*)defaultText initiatedByFrame:(WKFrameInfo*)frame
|
||||
completionHandler:(void (^)(NSString* result))completionHandler
|
||||
{
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title
|
||||
message:prompt
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(((UITextField*)alert.textFields[0]).text);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
|
||||
[alert addAction:ok];
|
||||
|
||||
UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(nil);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
[alert addAction:cancel];
|
||||
|
||||
[alert addTextFieldWithConfigurationHandler:^(UITextField* textField) {
|
||||
textField.text = defaultText;
|
||||
}];
|
||||
|
||||
UIViewController* rootController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
|
||||
[rootController presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
@interface IONAssetHandler : NSObject <WKURLSchemeHandler>
|
||||
|
||||
@property (nonatomic, strong) NSString * basePath;
|
||||
@property (nonatomic, strong) NSString * scheme;
|
||||
|
||||
-(void)setAssetPath:(NSString *)assetPath;
|
||||
- (instancetype)initWithBasePath:(NSString *)basePath andScheme:(NSString *)scheme;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,92 @@
|
||||
#import "IONAssetHandler.h"
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
#import "CDVWKWebViewEngine.h"
|
||||
|
||||
@implementation IONAssetHandler
|
||||
|
||||
-(void)setAssetPath:(NSString *)assetPath {
|
||||
self.basePath = assetPath;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBasePath:(NSString *)basePath andScheme:(NSString *)scheme {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_basePath = basePath;
|
||||
_scheme = scheme;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
|
||||
{
|
||||
NSString * startPath = @"";
|
||||
NSURL * url = urlSchemeTask.request.URL;
|
||||
NSString * stringToLoad = url.path;
|
||||
NSString * scheme = url.scheme;
|
||||
|
||||
if ([scheme isEqualToString:self.scheme]) {
|
||||
if ([stringToLoad hasPrefix:@"/_app_file_"]) {
|
||||
startPath = [stringToLoad stringByReplacingOccurrencesOfString:@"/_app_file_" withString:@""];
|
||||
} else {
|
||||
startPath = self.basePath ? self.basePath : @"";
|
||||
if ([stringToLoad isEqualToString:@""] || [url.pathExtension isEqualToString:@""]) {
|
||||
startPath = [startPath stringByAppendingString:@"/index.html"];
|
||||
} else {
|
||||
startPath = [startPath stringByAppendingString:stringToLoad];
|
||||
}
|
||||
}
|
||||
}
|
||||
NSError * fileError = nil;
|
||||
NSData * data = nil;
|
||||
if ([self isMediaExtension:url.pathExtension]) {
|
||||
data = [NSData dataWithContentsOfFile:startPath options:NSDataReadingMappedIfSafe error:&fileError];
|
||||
}
|
||||
if (!data || fileError) {
|
||||
data = [[NSData alloc] initWithContentsOfFile:startPath];
|
||||
}
|
||||
NSInteger statusCode = 200;
|
||||
if (!data) {
|
||||
statusCode = 404;
|
||||
}
|
||||
NSURL * localUrl = [NSURL URLWithString:url.absoluteString];
|
||||
NSString * mimeType = [self getMimeType:url.pathExtension];
|
||||
id response = nil;
|
||||
if (data && [self isMediaExtension:url.pathExtension]) {
|
||||
response = [[NSURLResponse alloc] initWithURL:localUrl MIMEType:mimeType expectedContentLength:data.length textEncodingName:nil];
|
||||
} else {
|
||||
NSDictionary * headers = @{ @"Content-Type" : mimeType, @"Cache-Control": @"no-cache"};
|
||||
response = [[NSHTTPURLResponse alloc] initWithURL:localUrl statusCode:statusCode HTTPVersion:nil headerFields:headers];
|
||||
}
|
||||
|
||||
[urlSchemeTask didReceiveResponse:response];
|
||||
[urlSchemeTask didReceiveData:data];
|
||||
[urlSchemeTask didFinish];
|
||||
|
||||
}
|
||||
|
||||
- (void)webView:(nonnull WKWebView *)webView stopURLSchemeTask:(nonnull id<WKURLSchemeTask>)urlSchemeTask
|
||||
{
|
||||
NSLog(@"stop");
|
||||
}
|
||||
|
||||
-(NSString *) getMimeType:(NSString *)fileExtension {
|
||||
if (fileExtension && ![fileExtension isEqualToString:@""]) {
|
||||
NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExtension, NULL);
|
||||
NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType);
|
||||
return contentType ? contentType : @"application/octet-stream";
|
||||
} else {
|
||||
return @"text/html";
|
||||
}
|
||||
}
|
||||
|
||||
-(BOOL) isMediaExtension:(NSString *) pathExtension {
|
||||
NSArray * mediaExtensions = @[@"m4v", @"mov", @"mp4",
|
||||
@"aac", @"ac3", @"aiff", @"au", @"flac", @"m4a", @"mp3", @"wav"];
|
||||
if ([mediaExtensions containsObject:pathExtension.lowercaseString]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012 Niklas von Hertzen
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
(function _wk_plugin() {
|
||||
// Check if we are running in WKWebView
|
||||
if (!window.webkit || !window.webkit.messageHandlers) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize Ionic
|
||||
window.Ionic = window.Ionic || {};
|
||||
|
||||
function normalizeURL(url) {
|
||||
console.warn('normalizeURL is deprecated, use window.Ionic.WebView.convertFileSrc');
|
||||
return window.Ionic.WebView.convertFileSrc(url);
|
||||
}
|
||||
if (typeof window.wkRewriteURL === 'undefined') {
|
||||
window.wkRewriteURL = function (url) {
|
||||
console.warn('wkRewriteURL is deprecated, use window.Ionic.WebView.convertFileSrc instead');
|
||||
return window.Ionic.WebView.convertFileSrc(url);
|
||||
}
|
||||
}
|
||||
window.Ionic.normalizeURL = normalizeURL;
|
||||
|
||||
var stopScrollHandler = window.webkit.messageHandlers.stopScroll;
|
||||
if (!stopScrollHandler) {
|
||||
console.error('Can not find stopScroll handler');
|
||||
return;
|
||||
}
|
||||
|
||||
var stopScrollFunc = null;
|
||||
var stopScroll = {
|
||||
stop: function stop(callback) {
|
||||
if (!stopScrollFunc) {
|
||||
stopScrollFunc = callback;
|
||||
stopScrollHandler.postMessage('');
|
||||
}
|
||||
},
|
||||
fire: function fire() {
|
||||
stopScrollFunc && stopScrollFunc();
|
||||
stopScrollFunc = null;
|
||||
},
|
||||
cancel: function cancel() {
|
||||
stopScrollFunc = null;
|
||||
}
|
||||
};
|
||||
|
||||
window.Ionic.StopScroll = stopScroll;
|
||||
// deprecated
|
||||
window.IonicStopScroll = stopScroll;
|
||||
|
||||
console.debug("Ionic Stop Scroll injected!");
|
||||
})();
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates the exec bridge used to notify the native code of
|
||||
* commands.
|
||||
*/
|
||||
var cordova = require('cordova');
|
||||
var utils = require('cordova/utils');
|
||||
var base64 = require('cordova/base64');
|
||||
|
||||
function massageArgsJsToNative (args) {
|
||||
if (!args || utils.typeName(args) !== 'Array') {
|
||||
return args;
|
||||
}
|
||||
var ret = [];
|
||||
args.forEach(function (arg, i) {
|
||||
if (utils.typeName(arg) === 'ArrayBuffer') {
|
||||
ret.push({
|
||||
'CDVType': 'ArrayBuffer',
|
||||
'data': base64.fromArrayBuffer(arg)
|
||||
});
|
||||
} else {
|
||||
ret.push(arg);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
function massageMessageNativeToJs (message) {
|
||||
if (message.CDVType === 'ArrayBuffer') {
|
||||
var stringToArrayBuffer = function (str) {
|
||||
var ret = new Uint8Array(str.length);
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
ret[i] = str.charCodeAt(i);
|
||||
}
|
||||
return ret.buffer;
|
||||
};
|
||||
var base64ToArrayBuffer = function (b64) {
|
||||
return stringToArrayBuffer(atob(b64)); // eslint-disable-line no-undef
|
||||
};
|
||||
message = base64ToArrayBuffer(message.data);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
function convertMessageToArgsNativeToJs (message) {
|
||||
var args = [];
|
||||
if (!message || !message.hasOwnProperty('CDVType')) {
|
||||
args.push(message);
|
||||
} else if (message.CDVType === 'MultiPart') {
|
||||
message.messages.forEach(function (e) {
|
||||
args.push(massageMessageNativeToJs(e));
|
||||
});
|
||||
} else {
|
||||
args.push(massageMessageNativeToJs(message));
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
var iOSExec = function () {
|
||||
// detect change in bridge, if there is a change, we forward to new bridge
|
||||
|
||||
// if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova && window.webkit.messageHandlers.cordova.postMessage) {
|
||||
// bridgeMode = jsToNativeModes.WK_WEBVIEW_BINDING;
|
||||
// }
|
||||
|
||||
var successCallback, failCallback, service, action, actionArgs;
|
||||
var callbackId = null;
|
||||
if (typeof arguments[0] !== 'string') {
|
||||
// FORMAT ONE
|
||||
successCallback = arguments[0];
|
||||
failCallback = arguments[1];
|
||||
service = arguments[2];
|
||||
action = arguments[3];
|
||||
actionArgs = arguments[4];
|
||||
|
||||
// Since we need to maintain backwards compatibility, we have to pass
|
||||
// an invalid callbackId even if no callback was provided since plugins
|
||||
// will be expecting it. The Cordova.exec() implementation allocates
|
||||
// an invalid callbackId and passes it even if no callbacks were given.
|
||||
callbackId = 'INVALID';
|
||||
} else {
|
||||
throw new Error('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' + // eslint-disable-line
|
||||
'cordova.exec(null, null, \'Service\', \'action\', [ arg1, arg2 ]);');
|
||||
}
|
||||
|
||||
// If actionArgs is not provided, default to an empty array
|
||||
actionArgs = actionArgs || [];
|
||||
|
||||
// Register the callbacks and add the callbackId to the positional
|
||||
// arguments if given.
|
||||
if (successCallback || failCallback) {
|
||||
callbackId = service + cordova.callbackId++;
|
||||
cordova.callbacks[callbackId] =
|
||||
{success: successCallback, fail: failCallback};
|
||||
}
|
||||
|
||||
actionArgs = massageArgsJsToNative(actionArgs);
|
||||
|
||||
// CB-10133 DataClone DOM Exception 25 guard (fast function remover)
|
||||
var command = [callbackId, service, action, JSON.parse(JSON.stringify(actionArgs))];
|
||||
window.webkit.messageHandlers.cordova.postMessage(command);
|
||||
};
|
||||
|
||||
iOSExec.nativeCallback = function (callbackId, status, message, keepCallback, debug) {
|
||||
var success = status === 0 || status === 1;
|
||||
var args = convertMessageToArgsNativeToJs(message);
|
||||
Promise.resolve().then(function () {
|
||||
cordova.callbackFromNative(callbackId, success, status, args, keepCallback); // eslint-disable-line
|
||||
});
|
||||
};
|
||||
|
||||
// for backwards compatibility
|
||||
iOSExec.nativeEvalAndFetch = function (func) {
|
||||
try {
|
||||
func();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
|
||||
// Proxy the exec for bridge changes. See CB-10106
|
||||
|
||||
function cordovaExec () {
|
||||
var cexec = require('cordova/exec');
|
||||
var cexec_valid = (typeof cexec.nativeFetchMessages === 'function') && (typeof cexec.nativeEvalAndFetch === 'function') && (typeof cexec.nativeCallback === 'function');
|
||||
return (cexec_valid && execProxy !== cexec) ? cexec : iOSExec;
|
||||
}
|
||||
|
||||
function execProxy () {
|
||||
cordovaExec().apply(null, arguments);
|
||||
}
|
||||
|
||||
execProxy.nativeFetchMessages = function () {
|
||||
return cordovaExec().nativeFetchMessages.apply(null, arguments);
|
||||
};
|
||||
|
||||
execProxy.nativeEvalAndFetch = function () {
|
||||
return cordovaExec().nativeEvalAndFetch.apply(null, arguments);
|
||||
};
|
||||
|
||||
execProxy.nativeCallback = function () {
|
||||
return cordovaExec().nativeCallback.apply(null, arguments);
|
||||
};
|
||||
|
||||
module.exports = execProxy;
|
||||
|
||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova && window.webkit.messageHandlers.cordova.postMessage) {
|
||||
// unregister the old bridge
|
||||
cordova.define.remove('cordova/exec');
|
||||
// redefine bridge to our new bridge
|
||||
cordova.define('cordova/exec', function (require, exports, module) {
|
||||
module.exports = execProxy;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var WebView = {
|
||||
convertFileSrc: function(url) {
|
||||
if (!url) {
|
||||
return url;
|
||||
}
|
||||
if (url.indexOf('/')===0) {
|
||||
return window.WEBVIEW_SERVER_URL + '/_app_file_' + url;
|
||||
}
|
||||
if (url.indexOf('file://')===0) {
|
||||
return window.WEBVIEW_SERVER_URL + url.replace('file://', '/_app_file_');
|
||||
}
|
||||
if (url.indexOf('content://')===0) {
|
||||
return window.WEBVIEW_SERVER_URL + url.replace('content:/', '/_app_content_');
|
||||
}
|
||||
return url;
|
||||
},
|
||||
setServerBasePath: function(path) {
|
||||
exec(null, null, 'IonicWebView', 'setServerBasePath', [path]);
|
||||
},
|
||||
getServerBasePath: function(callback) {
|
||||
exec(callback, null, 'IonicWebView', 'getServerBasePath', []);
|
||||
},
|
||||
persistServerBasePath: function() {
|
||||
exec(null, null, 'IonicWebView', 'persistServerBasePath', []);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WebView;
|
||||
@@ -0,0 +1,28 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
max_jobs: 1
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
nodejs_version: "4"
|
||||
matrix:
|
||||
- PLATFORM: windows-10-store
|
||||
JUST_BUILD: --justBuild
|
||||
install:
|
||||
- npm cache clean -f
|
||||
- node --version
|
||||
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
|
||||
- npm install -g cordova
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%
|
||||
@@ -0,0 +1,22 @@
|
||||
<!--
|
||||
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
|
||||
is intended as a quick reference, for complete details please see our Contributor Guidelines:
|
||||
|
||||
http://cordova.apache.org/contribute/contribute_guidelines.html
|
||||
|
||||
Thanks!
|
||||
-->
|
||||
|
||||
### Platforms affected
|
||||
|
||||
|
||||
### What does this PR do?
|
||||
|
||||
|
||||
### What testing has been done on this change?
|
||||
|
||||
|
||||
### Checklist
|
||||
- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
|
||||
- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
|
||||
- [ ] Added automated test coverage as appropriate for this change.
|
||||
@@ -0,0 +1 @@
|
||||
tests/ios
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"browser": true
|
||||
, "devel": true
|
||||
, "bitwise": true
|
||||
, "undef": true
|
||||
, "trailing": true
|
||||
, "quotmark": false
|
||||
, "indent": 4
|
||||
, "unused": "vars"
|
||||
, "latedef": "nofunc"
|
||||
, "globals": {
|
||||
"module": false,
|
||||
"exports": false,
|
||||
"require": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#If ignorance is bliss, then somebody knock the smile off my face
|
||||
|
||||
*.csproj.user
|
||||
*.suo
|
||||
*.cache
|
||||
Thumbs.db
|
||||
*.DS_Store
|
||||
|
||||
*.bak
|
||||
*.cache
|
||||
*.log
|
||||
*.swp
|
||||
*.user
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
node_modules
|
||||
|
||||
/tests/ios/CDVSplashScreenTest/CDVSplashScreenTest.xcodeproj/xcuserdata/
|
||||
|
||||
/tests/ios/CDVSplashScreenTest.xcworkspace/xcuserdata/
|
||||
@@ -0,0 +1,98 @@
|
||||
sudo: false
|
||||
addons:
|
||||
jwt:
|
||||
secure: UmbBQ73ydIzhTCfaTb/g0beTwnOHjYxlILmQYK2Tl9Gna/KbpawiVmbloX1eZakevkeYgzQmAHEF0LyDINy5AUk97azYeP0Sz/IOjIDfXAdc6U6sZb7BScneBMt6ET/hCprG4f3mbmleQ+gx+dmNWez6rlb3Xu+XWfJuwDfAWm0=
|
||||
env:
|
||||
global:
|
||||
- SAUCE_USERNAME=snay
|
||||
- TRAVIS_NODE_VERSION="4.2"
|
||||
matrix:
|
||||
include:
|
||||
- env: PLATFORM=browser-chrome
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-firefox
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-safari
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=browser-edge
|
||||
os: linux
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: TEST_DIR=.
|
||||
language: objective-c
|
||||
osx_image: xcode7
|
||||
- env: TEST_DIR=./tests/ios
|
||||
language: objective-c
|
||||
osx_image: xcode7
|
||||
- env: PLATFORM=ios-9.3
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=ios-10.0
|
||||
os: osx
|
||||
osx_image: xcode7.3
|
||||
language: node_js
|
||||
node_js: '4.2'
|
||||
- env: PLATFORM=android-4.4
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-5.1
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-6.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
- build-tools-26.0.2
|
||||
- env: PLATFORM=android-7.0
|
||||
os: linux
|
||||
language: android
|
||||
jdk: oraclejdk8
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- extra-android-m2repository
|
||||
- build-tools-26.0.2
|
||||
before_install:
|
||||
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
|
||||
&& git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
|
||||
install $TRAVIS_NODE_VERSION
|
||||
- node --version
|
||||
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
|
||||
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
|
||||
- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26;
|
||||
fi
|
||||
- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic
|
||||
&& npm install && popd
|
||||
- npm install -g cordova
|
||||
install:
|
||||
- npm install
|
||||
script:
|
||||
- if [[ "$TEST_DIR" != "" ]];
|
||||
then cd $TEST_DIR && npm install && (npm test || npm test);
|
||||
else node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce
|
||||
--buildName travis-plugin-splashscreen-$TRAVIS_JOB_NUMBER;
|
||||
fi
|
||||
@@ -0,0 +1,37 @@
|
||||
<!--
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
-->
|
||||
|
||||
# Contributing to Apache Cordova
|
||||
|
||||
Anyone can contribute to Cordova. And we need your contributions.
|
||||
|
||||
There are multiple ways to contribute: report bugs, improve the docs, and
|
||||
contribute code.
|
||||
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/contribute/).
|
||||
|
||||
The details are explained there, but the important items are:
|
||||
- Sign and submit an Apache ICLA (Contributor License Agreement).
|
||||
- Have a Jira issue open that corresponds to your contribution.
|
||||
- Run the tests so your patch doesn't break existing functionality.
|
||||
|
||||
We look forward to your contributions!
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,5 @@
|
||||
Apache Cordova
|
||||
Copyright 2012 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
@@ -0,0 +1,522 @@
|
||||
---
|
||||
title: Splashscreen
|
||||
description: Control the splash screen for your app.
|
||||
---
|
||||
<!--
|
||||
# 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|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-splashscreen)|[](https://travis-ci.org/apache/cordova-plugin-splashscreen)|
|
||||
|
||||
# cordova-plugin-splashscreen
|
||||
|
||||
This plugin is required to work with splash screens. This plugin displays and hides a splash screen during application launch.
|
||||
|
||||
Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cordova issue tracker].
|
||||
|
||||
## Installation
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows (`cordova-windows` version >= 4.4.0 is required)
|
||||
- Browser
|
||||
|
||||
__Note__: Extended splashscreen does not require the plugin on Windows (as opposed to Android and iOS) in case you don't use the plugin API, i.e. programmatic hide/show.
|
||||
|
||||
### iOS-specific information
|
||||
|
||||
There are two mechanisms for displaying a launch screen on iOS:
|
||||
|
||||
1. Legacy launch images: images are sized exactly for the device's screen size. Does not support the iPad Pro 12.9's native resolution or split-screen/slide-over multitasking.
|
||||
|
||||
2. Launch storyboard images: Images are sized based on scale, idiom, and size classes. Supports all devices, and can be used with split-screen/slide-over multitasking.
|
||||
|
||||
Apple is moving away from legacy launch images. There is no official support for providing a native-resolution launch image for the iPad Pro 12.9 or for providing launch images that work with split-screen multitasking or slide-over. If your app doesn't need to support these contexts, then you can continue to use legacy launch images for as long as you like.
|
||||
|
||||
The preferred method of providing launch images is to use a launch storyboard. For native app developers, the ideal launch storyboard is an unpopulated version of the app's user interface at launch. For non-native app developers who don't wish to learn Interface Builder, however, this plugin simulates the legacy launch image method as much as is feasible.
|
||||
|
||||
#### Legacy launch images
|
||||
|
||||
If you choose to use legacy launch images, you will use the following syntax in `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
|
||||
<splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
|
||||
<splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
|
||||
<splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
|
||||
<splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
|
||||
<splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
|
||||
<splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
|
||||
<splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>
|
||||
<splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>
|
||||
```
|
||||
|
||||
Technically the filename for the `src` attribute can be anything you want; the filenames are used because they match what will be used when your project is compiled. The width and height attributes determine which launch images are displayed on which devices as follows:
|
||||
|
||||
| width | height | device (orientation) |
|
||||
|:-----------:|:------------:|:--------------------------------:|
|
||||
| 320 | 480 | All non-retina iPhones and iPods |
|
||||
| 640 | 960 | iPhone 4/4s (portrait) |
|
||||
| 640 | 1136 | iPhone 5/5s/SE (portrait) |
|
||||
| 750 | 1334 | iPhone 6/6s/7 (portrait) |
|
||||
| 1242 | 2208 | iPhone 6+/6s+/7+ (portrait) |
|
||||
| 2208 | 1242 | iPhone 6+/6s+/7+ (landscape) |
|
||||
| 768 | 1024 | All non-retina iPads (portrait) |
|
||||
| 1024 | 768 | All non-retina iPads (landscape) |
|
||||
| 1536 | 2048 | All retina iPads (portrait) |
|
||||
| 2048 | 1536 | All retina iPads (landscape) |
|
||||
|
||||
Note: It is vitally important that the source image actually matches the size specified in the `width` and `height` attributes. If it does not, the device may fail to render it properly, if at all.
|
||||
|
||||
#### Launch storyboard images
|
||||
|
||||
In order to support newer form factors and split-screen/slide-over multitasking, you should use launch storyboard images. These are similar to the legacy launch images above, but there are crucial differences:
|
||||
|
||||
- images are not specific to a given device.
|
||||
|
||||
- images are scaled to fill the available viewport (while maintaining the aspect ratio).
|
||||
|
||||
- the outer edges of the images will be cropped, and the amount will vary based on device an viewport.
|
||||
|
||||
- there is no need to provide an image for each possible device, viewport, and orientation; iOS will choose the best image for the situation automatically.
|
||||
|
||||
##### Designing launch storyboard images
|
||||
|
||||
The key to designing a launch storyboard image is understanding that the edges of the image will almost certainly be cropped. Therefore, one should not place any important information near the edges of any images provided to the launch storyboard. Only the center is a safe area, and this all but guarantees that following Apple's advice of presenting an unpopulated user interface will not work well.
|
||||
|
||||
Instead, the following tips should enable you to create a launch image that works across a multitude of form factors, viewports, and orientations:
|
||||
|
||||
- Important graphics (logos, icons, titles) should be centered. The safe bounding region will vary, so you will need to test to ensure that the important graphics are never cropped. Better yet, don't supply any important graphics in the first place.
|
||||
|
||||
- You _can_ fine-tune the placement and size of these graphics, but you don't have the same fine-grained control as you did with legacy launch images.
|
||||
|
||||
- Use a simple color wash. If you use two colors, you'll want one color to fill the top half of the image, and the second to fill the bottom half. If you use a gradient, you'll probably want to ensure that the middle of the gradient lines up with the center of the image.
|
||||
|
||||
- Don't worry about pixel perfection -- because the images are scaled, there's almost no chance the images will be perfectly fit to the pixel grid. Since all supported iOS devices use retina screens, users will be hard pressed to notice it anyway.
|
||||
|
||||
It is important to understand the concept of scale, idiom, and size class traits in order to use launch storyboard images effectively. Of the images supplied to the launch storyboard, iOS will choose the image that best matches the device and viewport and render that image. It is possible to supply only one launch image if so desired, but it is also possible to fine-tune the displayed launch image based on traits. When fine-tuning, one can ignore traits that aren't targeted or supported by the app.
|
||||
|
||||
> Note: If you are using launch storyboard images, there is no need to include legacy images. If you do, the legacy images will be copied, but not used.
|
||||
|
||||
##### Scale
|
||||
|
||||
| scale | devices |
|
||||
|:-----------:|:----------------------:|
|
||||
| 1x | All non-retina devices |
|
||||
| 2x | Most retina devices |
|
||||
| 3x | iPhone 6+/6s+,7s+ |
|
||||
|
||||
In general, you'll want to supply 2x and 3x images. Cordova only supports retina devices now, so there's no point in supplying 1x images.
|
||||
|
||||
##### Idioms
|
||||
|
||||
| idiom | devices |
|
||||
|:-----------:|:-------------:|
|
||||
| ipad | All iPads |
|
||||
| iphone | All iPhones and iPod Touches |
|
||||
| universal | All devices |
|
||||
|
||||
You only need to provide universal images unless you need to fine-tune for a specific device idiom.
|
||||
|
||||
##### Size classes
|
||||
|
||||
There are two size classes applies to both screen axes. Narrow viewports are considered to be the "compact" size class, and remaining viewports are considered "regular". When supplying images to Xcode, however, one must choose between "any & compact" and "any & regular". To stay consistent with the native terminology, this feature will match based on "any" and "compact". `any` will match regular-sized viewports.
|
||||
|
||||
Note: this feature uses `com` as an abbreviation for "compact" classes.
|
||||
|
||||
The following classes are supported by this feature:
|
||||
|
||||
| width | height | orientation |
|
||||
|:-----------:|:------------:|:-----------------:|
|
||||
| any | any | any |
|
||||
| com | any | portrait |
|
||||
| any | com | landscape (wide) |
|
||||
| com | com | landscape (narrow)|
|
||||
|
||||
To see the complete list of size classes associated with devices and viewports, see <http://www.sizeclasses.com>.
|
||||
|
||||
##### Single-image launch screen
|
||||
|
||||
If your launch image is simple, you may be able to avoid creating a lot of different launch images and supply only one. The launch image needs to meet the following requirements:
|
||||
|
||||
- the image should be square
|
||||
|
||||
- the image should be large enough to fit on an iPad Pro 12.9": 2732x2732
|
||||
|
||||
- anything important should fit within the center
|
||||
|
||||
Keep in mind that the image will be cropped, possibly quite severely, depending upon the viewport.
|
||||
|
||||
Once the image is created, you can include it in your project by adding the following to `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default@2x~universal~anyany.png" />
|
||||
```
|
||||
|
||||
Because only one image is provided, iOS will utilize it in every context.
|
||||
|
||||
##### Multi-image launch screen
|
||||
|
||||
If a single launch image won't meet your needs, you will probably need to supply at least six images, if not more. Furthermore, keep in mind that it will not be possible to fine tune the image to a specific device, but only to a device class, display factor, and viewport size.
|
||||
|
||||
If you don't need to target images to a specific idiom, you should create six images, as follows:
|
||||
|
||||
| scale | idiom | width | height | size | filename |
|
||||
|:-----------:|:-----------:|:-----------:|:------------:|:----------:|:--------------:|
|
||||
| 2x* | universal | any | any | 2732x2732 | `Default@2x~universal~anyany.png` |
|
||||
| 2x | universal | com | any | 1278x2732 | `Default@2x~universal~comany.png` |
|
||||
| 2x | universal | com | com | 1334x750 | `Default@2x~universal~comcom.png` |
|
||||
| 3x* | universal | any | any | 2208x2208 | `Default@3x~universal~anyany.png` |
|
||||
| 3x | universal | any | com | 2208x1242 | `Default@3x~universal~anycom.png` |
|
||||
| 3x | universal | com | any | 1242x2208 | `Default@3x~universal~comany.png` |
|
||||
|
||||
\* this image is required in order for iOS utilize the other images within this scale and idiom.
|
||||
|
||||
> Note: If the 3x sizes look small too you, that's because there's only one device class that currently has a 3x density: the iPhone 6+/6s+/7+.
|
||||
|
||||
The above looks like the following snippet when present in `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default@2x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comcom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anycom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~comany.png" />
|
||||
```
|
||||
|
||||
Should one need to further fine tune based upon device idiom, one can do so. This might look like so:
|
||||
|
||||
| scale | idiom | width | height | size | filename |
|
||||
|:-----------:|:-----------:|:-----------:|:------------:|:----------:|:--------------:|
|
||||
| 2x* | iphone | any | any | 1334x1334 | `Default@2x~iphone~anyany.png` |
|
||||
| 2x | iphone | com | any | 750x1334 | `Default@2x~iphone~comany.png` |
|
||||
| 2x | iphone | com | com | 1334x750 | `Default@2x~iphone~comcom.png` |
|
||||
| 3x* | iphone | any | any | 2208x2208 | `Default@3x~iphone~anyany.png` |
|
||||
| 3x | iphone | any | com | 2208x1242 | `Default@3x~iphone~anycom.png` |
|
||||
| 3x | iphone | com | any | 1242x2208 | `Default@3x~iphone~comany.png` |
|
||||
| 2x* | ipad | any | any | 2732x2732 | `Default@2x~ipad~anyany.png` |
|
||||
| 2x | ipad | com | any | 1278x2732 | `Default@2x~ipad~comany.png` |
|
||||
|
||||
\* this image is required in order for iOS utilize the other images within this scale and idiom.
|
||||
|
||||
The above looks like the following in `config.xml`:
|
||||
|
||||
```
|
||||
<splash src="res/screen/ios/Default@2x~iphone~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~iphone~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~iphone~comcom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~iphone~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@3x~iphone~anycom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~iphone~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~ipad~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~ipad~comany.png" />
|
||||
```
|
||||
|
||||
##### Quirks and Known Issues
|
||||
|
||||
1. **App on target may not reflect changes to images**
|
||||
Once you run the app on a target, iOS caches the launch image. Unfortunately, when you chance the images, iOS does _not_ invalidate the cache, which means you'll still see the old launch image. You should either: delete the app, or reset content & settings (simulator).
|
||||
|
||||
2. **Simulator may not show expected images when launched from CLI**
|
||||
When Xcode deploys to a specific simulator, it only copies the assets that match the simulator's characteristics. For example, if you try to run an app on the iPhone 6s Plus simulator, only @3x launch images are copied. When compiling from the CLI, however, the default is to assume an iPhone 5s, which means only @2x launch images are copied. Unless your launch images are markedly different, chances are good the difference would go unnoticed, but this does mean that the only accurate method of testing is to test on a physical device.
|
||||
|
||||
3. **`anyany` must be provided for other variations to be used**
|
||||
If you don't provide an `anyany` version of the launch image for a specific scale and idiom, the other variations (like `anycom`, `comany`, and `comcom`) will ignored.
|
||||
|
||||
## Windows-specific information
|
||||
|
||||
Splash screen images can be defined using the [MRT](https://cordova.apache.org/docs/en/dev/config_ref/images.html#windows) concept.
|
||||
If you specify src="res/windows/splashscreen.png" the following files will be copied into the application's images folder:
|
||||
`res/windows/splashscreen.png` | `res/windows/splashscreen.scale-100.png`, `res/windows/splashscreen.scale-125.png`, etc.
|
||||
The following are supported:
|
||||
|
||||
| Scale, % | Project | Width | Height | Filename |
|
||||
|:------------:|:-------------------:|:-----------:|:------------:|:---------------------------------:|
|
||||
| 100 | Windows 10/8.1 | 620 | 300 | `splashscreen.png` \| `splashscreen.scale-100.png` |
|
||||
| 125 | Windows 10 | 775 | 375 | `splashscreen.scale-125.png` |
|
||||
| 150 | Windows 10 | 930 | 450 | `splashscreen.scale-150.png` |
|
||||
| 200 | Windows 10 | 1240 | 600 | `splashscreen.scale-200.png` |
|
||||
| 400 | Windows 10 | 2480 | 1200 | `splashscreen.scale-400.png` |
|
||||
| 140 | Windows 8.1 | 868 | 420 | `splashscreen.scale-140.png` |
|
||||
| 180 | Windows 8.1 | 1116 | 540 | `splashscreen.scale-180.png` |
|
||||
| 100 | Windows Phone 8.1 | 480 | 800 | `splashscreenphone.png` \| `splashscreenphone.scale-100.png` |
|
||||
| 140 | Windows Phone 8.1 | 672 | 1120 | `splashscreenphone.scale-140.png` |
|
||||
| 240 | Windows Phone 8.1 | 1152 | 1920 | `splashscreenphone.scale-240.png` |
|
||||
|
||||
__Note__: SplashScreens size for Windows 10 project should not exceed 200 KBytes.
|
||||
__Note__: Supported formats are `.png`, `.jpg`, `.jpeg`. Mixing of the extensions within a target is not supported. I.e. you can have `splashscreen.jpg` and `splashscreenphone.png` but not `splashscreen.scale-100.png`, `splashscreen.scale-400.jpg`.
|
||||
__Note__: You may need to reopen Visual Studio solution after changing the images and doing a `cordova prepare` for the changes to take effect.
|
||||
|
||||
## Example Configuration
|
||||
In the top-level `config.xml` file (not the one in `platforms`), add configuration elements like those specified here.
|
||||
|
||||
Please notice that the value of the "src" attribute is relative to the project root directory and not to the www directory (see `Directory structure` below). You can name the source image whatever you like. The internal name in the app is determined by Cordova.
|
||||
|
||||
Directory structure:
|
||||
|
||||
```
|
||||
projectRoot
|
||||
hooks
|
||||
platforms
|
||||
plugins
|
||||
www
|
||||
css
|
||||
img
|
||||
js
|
||||
res
|
||||
screen
|
||||
android
|
||||
ios
|
||||
windows
|
||||
```
|
||||
|
||||
```xml
|
||||
<platform name="android">
|
||||
<!-- you can use any density that exists in the Android project -->
|
||||
<splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi"/>
|
||||
<splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi"/>
|
||||
<splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi"/>
|
||||
<splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi"/>
|
||||
|
||||
<splash src="res/screen/android/splash-port-hdpi.png" density="port-hdpi"/>
|
||||
<splash src="res/screen/android/splash-port-ldpi.png" density="port-ldpi"/>
|
||||
<splash src="res/screen/android/splash-port-mdpi.png" density="port-mdpi"/>
|
||||
<splash src="res/screen/android/splash-port-xhdpi.png" density="port-xhdpi"/>
|
||||
</platform>
|
||||
|
||||
<platform name="ios">
|
||||
<!-- There are two mechanisms for showing launch images.
|
||||
-- Legacy method (supports all devices except iPad Pro 12.9):
|
||||
-- Note: Images are determined by width and height. The following are supported -->
|
||||
<splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
|
||||
<splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
|
||||
<splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
|
||||
<splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
|
||||
<splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
|
||||
<splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
|
||||
<splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
|
||||
<splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>
|
||||
<splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>
|
||||
<splash src="res/screen/ios/Default-Landscape-736h.png" width="2208" height="1242"/>
|
||||
<!-- Storyboard method (supports all devices):
|
||||
-- Important: If you use the storyboard method, legacy images are
|
||||
-- copied but ignored.
|
||||
-- Note: images are determined by scale, idiom, and size traits. The following
|
||||
-- are suggested based on current device form factors -->
|
||||
<splash src="res/screen/ios/Default@2x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comany.png" />
|
||||
<splash src="res/screen/ios/Default@2x~universal~comcom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anyany.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~anycom.png" />
|
||||
<splash src="res/screen/ios/Default@3x~universal~comany.png" />
|
||||
|
||||
</platform>
|
||||
|
||||
<!-- Configuration using MRT concept (Recommended, see "Windows-specific information" section for details): -->
|
||||
<platform name="windows">
|
||||
<splash src="res/screen/windows/splashscreen.png" target="SplashScreen"/>
|
||||
<splash src="res/screen/windows/splashscreenphone.png" target="SplashScreenPhone"/>
|
||||
</platform>
|
||||
|
||||
<!-- Configuration using image size: -->
|
||||
<!--<platform name="windows">
|
||||
<splash src="res/screen/windows/splashscreen.png" width="620" height="300"/>
|
||||
<splash src="res/screen/windows/splashscreenphone.png" width="1152" height="1920"/>
|
||||
</platform>-->
|
||||
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
```
|
||||
|
||||
## Preferences
|
||||
|
||||
#### config.xml
|
||||
|
||||
- `AutoHideSplashScreen` (boolean, default to `true`). Indicates whether to hide splash screen automatically or not. Splash screen hidden after amount of time specified in the `SplashScreenDelay` preference.
|
||||
|
||||
```xml
|
||||
<preference name="AutoHideSplashScreen" value="true" />
|
||||
```
|
||||
|
||||
- `SplashScreenDelay` (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.
|
||||
|
||||
```xml
|
||||
<preference name="SplashScreenDelay" value="3000" />
|
||||
```
|
||||
|
||||
Note also that this value used to be seconds, and not milliseconds, so values less than 30 will still be treated as seconds. ( Consider this a deprecated patch that will disapear in some future version. )
|
||||
|
||||
To disable the splashscreen add the following preference to `config.xml`:
|
||||
```xml
|
||||
<preference name="SplashScreenDelay" value="0"/>
|
||||
```
|
||||
|
||||
**Windows Quirk**: You should disable the splashscreen in case you are updating the entire document body dynamically (f.e. with a SPA router) to avoid affecting UI/controls.
|
||||
Note that you should also directly reference `WinJS/base.js` in the page HTML in this case to avoid the issues with activation context ([CB-11658](https://issues.apache.org/jira/browse/CB-11658)).
|
||||
|
||||
**iOS Quirk**: to disable the splashscreen on `ios` platform you should also add `<preference name="FadeSplashScreenDuration" value="0"/>` to `config.xml`.
|
||||
|
||||
- `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to
|
||||
prevent the splash screen from fading in and out when its display
|
||||
state changes.
|
||||
|
||||
```xml
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
```
|
||||
|
||||
- `FadeSplashScreenDuration` (float, defaults to `500`): Specifies the
|
||||
number of milliseconds for the splash screen fade effect to execute.
|
||||
|
||||
```xml
|
||||
<preference name="FadeSplashScreenDuration" value="750"/>
|
||||
```
|
||||
|
||||
_Note_: `FadeSplashScreenDuration` is included into `SplashScreenDelay`, for example if you have `<preference name="SplashScreenDelay" value="3000" />` and `<preference name="FadeSplashScreenDuration" value="1000"/>` defined in `config.xml`:
|
||||
|
||||
- 00:00 - splashscreen is shown
|
||||
- 00:02 - fading has started
|
||||
- 00:03 - splashscreen is hidden
|
||||
|
||||
Turning the fading off via `<preference name="FadeSplashScreen" value="false"/>` technically means fading duration to be `0` so that in this example the overall splash delay will still be 3 seconds.
|
||||
|
||||
_Note_: This only applies to the app startup - you need to take the fading timeout into account when manually showing/hiding the splashscreen in the code:
|
||||
|
||||
```javascript
|
||||
navigator.splashscreen.show();
|
||||
window.setTimeout(function () {
|
||||
navigator.splashscreen.hide();
|
||||
}, splashDuration - fadeDuration);
|
||||
```
|
||||
|
||||
- `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false`
|
||||
to hide the splash-screen spinner.
|
||||
|
||||
```xml
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
```
|
||||
|
||||
### Android Quirks
|
||||
|
||||
In your `config.xml`, you can add the following preferences:
|
||||
|
||||
```xml
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
<preference name="SplashShowOnlyFirstTime" value="true|false" />
|
||||
<preference name="SplashScreenSpinnerColor" value="white" />
|
||||
```
|
||||
|
||||
"SplashMaintainAspectRatio" preference is optional. If set to true, splash screen drawable is not stretched to fit screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios.
|
||||
|
||||
The plugin reloads splash drawable whenever orientation changes, so you can specify different drawables for portrait and landscape orientations.
|
||||
|
||||
"SplashShowOnlyFirstTime" preference is also optional and defaults to `true`. When set to `true` splash screen will only appear on application launch. However, if you plan to use `navigator.app.exitApp()` to close application and force splash screen appear on next launch, you should set this property to `false` (this also applies to closing the App with Back button).
|
||||
|
||||
"SplashScreenSpinnerColor" preference is also optional and is ignored when not set. Setting it to a valid color name or HEX color code will change the color of the spinner on Android 5.0+ devices.
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
You can use the following preferences in your `config.xml`:
|
||||
|
||||
```xml
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="/images/browser/splashscreen.jpg" /> <!-- defaults to "/img/logo.png" -->
|
||||
<preference name="AutoHideSplashScreen" value="true" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenDelay" value="3000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
```
|
||||
|
||||
__Note__: `SplashScreen` value should be absolute in order to work in a sub-page. The `SplashScreen` value is used only for the browser platform. The value will be ignored for other platforms.
|
||||
|
||||
### iOS Quirks
|
||||
|
||||
- In iOS, the splashscreen images are called launch images. These images are mandatory on iOS.
|
||||
|
||||
### Windows Quirks
|
||||
|
||||
- `SplashScreenSpinnerColor` (string, defaults to system accent color): hash, rgb notation or CSS color name.
|
||||
|
||||
```xml
|
||||
<preference name="SplashScreenSpinnerColor" value="#242424"/>
|
||||
<preference name="SplashScreenSpinnerColor" value="DarkRed"/>
|
||||
<preference name="SplashScreenSpinnerColor" value="rgb(50,128,128)"/>
|
||||
```
|
||||
|
||||
- `SplashScreenBackgroundColor` (string, defaults to #464646): hex notation.
|
||||
|
||||
```xml
|
||||
<preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
- splashscreen.show
|
||||
- splashscreen.hide
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
Dismiss the splash screen.
|
||||
|
||||
```js
|
||||
navigator.splashscreen.hide();
|
||||
```
|
||||
|
||||
|
||||
### iOS Quirk
|
||||
|
||||
The `config.xml` file's `AutoHideSplashScreen` setting must be
|
||||
`false`. To delay hiding the splash screen for two seconds, add a
|
||||
timer such as the following in the `deviceready` event handler:
|
||||
|
||||
```js
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
```
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
Displays the splash screen.
|
||||
|
||||
```js
|
||||
navigator.splashscreen.show();
|
||||
```
|
||||
|
||||
Your application cannot call `navigator.splashscreen.show()` until the app has
|
||||
started and the `deviceready` event has fired. But since typically the splash
|
||||
screen is meant to be visible before your app has started, that would seem to
|
||||
defeat the purpose of the splash screen. Providing some configuration in
|
||||
`config.xml` will automatically `show` the splash screen immediately after your
|
||||
app launch and before it has fully started and received the `deviceready`
|
||||
event. For this reason, it is unlikely you need to call `navigator.splashscreen.show()` to make the splash
|
||||
screen visible for app startup.
|
||||
|
||||
[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%20Splashscreen%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC
|
||||
@@ -0,0 +1,238 @@
|
||||
<!--
|
||||
#
|
||||
# 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
|
||||
|
||||
### 5.0.2 (Jan 24, 2018)
|
||||
* [CB-13750](https://issues.apache.org/jira/browse/CB-13750) Add build-tools-26.0.2 to travis
|
||||
* [CB-13737](https://issues.apache.org/jira/browse/CB-13737) (iOS): fix Splash screen images for iPhone X
|
||||
|
||||
### 5.0.1 (Dec 27, 2017)
|
||||
* [CB-13709](https://issues.apache.org/jira/browse/CB-13709) Fix to allow 5.0.0 version install (#144)
|
||||
|
||||
### 5.0.0 (Dec 15, 2017)
|
||||
* [CB-13677](https://issues.apache.org/jira/browse/CB-13677) Remove deprecated platforms
|
||||
|
||||
### 4.1.0 (Nov 06, 2017)
|
||||
* [CB-13473](https://issues.apache.org/jira/browse/CB-13473) (CI) Removed **Browser** builds from AppVeyor
|
||||
* [CB-12011](https://issues.apache.org/jira/browse/CB-12011) (android) added the possibility to change the spinner color on **Android 5.0**+ apps
|
||||
* [CB-13028](https://issues.apache.org/jira/browse/CB-13028) (CI) **Browser** builds on Travis and AppVeyor
|
||||
* [CB-13094](https://issues.apache.org/jira/browse/CB-13094) (android) Don't show splash when activity being finished
|
||||
* [CB-11487](https://issues.apache.org/jira/browse/CB-11487) (browser) Documented `AutoHideSplashScreen` for **Browser**
|
||||
* [CB-11488](https://issues.apache.org/jira/browse/CB-11488) (browser) The `hide()` call became non re-entrant after the addition of fade out. This fixes the issue.
|
||||
* [CB-11487](https://issues.apache.org/jira/browse/CB-11487) (browser) The standard `AutoHideSplashScreen` `config.xml` property is now supported by the **Browser** platform.
|
||||
* [CB-11486](https://issues.apache.org/jira/browse/CB-11486) (browser) `splashScreenDelay` now feed through `parseInt` to ensure it is an integer by the time it's value is passed in to `setTimeout()` in `hide()`.
|
||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
||||
|
||||
### 4.0.3 (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
|
||||
|
||||
### 4.0.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
|
||||
|
||||
### 4.0.1 (Dec 07, 2016)
|
||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 4.0.1
|
||||
* [CB-11751](https://issues.apache.org/jira/browse/CB-11751) 'extendedSplashScreen' is undefined Document that splashscreen needs to be disabled on Windows in case of updating entire document body
|
||||
* [CB-9287](https://issues.apache.org/jira/browse/CB-9287) Not enough Icons and Splashscreens for **Windows 8.1** and Windows Phone 8.1
|
||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been submitted…"
|
||||
* [CB-11830](https://issues.apache.org/jira/browse/CB-11830) (iOS) Fix doc typos in PR#114
|
||||
* [CB-11829](https://issues.apache.org/jira/browse/CB-11829) (iOS) Support for CB-9762; docs (CB-11830)
|
||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
||||
|
||||
### 4.0.0 (Sep 08, 2016)
|
||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
|
||||
* [CB-11326](https://issues.apache.org/jira/browse/CB-11326) Prevent crash when initializing plugin after navigating to another URL
|
||||
* Fix crash on **iOS** when reloading page from remote **Safari**
|
||||
* Add badges for paramedic builds on Jenkins
|
||||
* Add pull request template.
|
||||
* [CB-11179](https://issues.apache.org/jira/browse/CB-11179) Extend the windows-splashscreen docs
|
||||
* [CB-11159](https://issues.apache.org/jira/browse/CB-11159) Fix flaky splashscreen native tests
|
||||
* [CB-11156](https://issues.apache.org/jira/browse/CB-11156) Change default `FadeSplashScreenDuration` value
|
||||
* [CB-8056](https://issues.apache.org/jira/browse/CB-8056) Updated the dependency version, added it to the docs
|
||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
|
||||
* [CB-8056](https://issues.apache.org/jira/browse/CB-8056) Implement splashscreen for **Windows** platform
|
||||
* [CB-6498](https://issues.apache.org/jira/browse/CB-6498) Misleading documentation in **Android** Quirks
|
||||
|
||||
### 3.2.2 (Apr 15, 2016)
|
||||
* [CB-10979](https://issues.apache.org/jira/browse/CB-10979) Fix splashscreen **iOS** native tests. Added `jshintignore` for tests/ios
|
||||
* [CB-10895](https://issues.apache.org/jira/browse/CB-10895) Transparent Splashscreen view sometimes remains
|
||||
* [CB-10562](https://issues.apache.org/jira/browse/CB-10562) `hide()` not working in latest splashscreen plug in 3.1.0 in **iOS**
|
||||
* [CB-10688](https://issues.apache.org/jira/browse/CB-10688) Plugin Splashscreen Readme must have examples.
|
||||
* [CB-10864](https://issues.apache.org/jira/browse/CB-10864) Run **iOS** native tests on Travis
|
||||
|
||||
### 3.2.1 (Mar 09, 2016)
|
||||
* [CB-10764](https://issues.apache.org/jira/browse/CB-10764) Remove emoji in cordova-plugin-splashscreen
|
||||
* [CB-10650](https://issues.apache.org/jira/browse/CB-10650) Non-index content.src causes Splashscreen to be not displayed on **Browser**
|
||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins
|
||||
* [CB-10606](https://issues.apache.org/jira/browse/CB-10606) fix deprecation warning for interfaceOrientation on **iOS**
|
||||
* chore: edit package.json license to match SPDX id
|
||||
|
||||
### 3.2.0 (Feb 09, 2016)
|
||||
* [CB-10422](https://issues.apache.org/jira/browse/CB-10422) Splashscreen displays black screen with no image on Android
|
||||
* [CB-10412](https://issues.apache.org/jira/browse/CB-10412) AutoHideSplashScreen "false" isn't taken in account on iOS
|
||||
* [CB-9516](https://issues.apache.org/jira/browse/CB-9516) Android SplashScreen - Spinner Does Not Display
|
||||
* [CB-9094](https://issues.apache.org/jira/browse/CB-9094) Smarter autohide logic on Android
|
||||
* [CB-8396](https://issues.apache.org/jira/browse/CB-8396) Add AutoHideSplashScreen logic to Android's Splashscreen
|
||||
|
||||
### 3.1.0 (Jan 15, 2016)
|
||||
* [CB-9538](https://issues.apache.org/jira/browse/CB-9538) Implementing `FadeSplashScreen` feature for **Android**
|
||||
* [CB-9240](https://issues.apache.org/jira/browse/CB-9240) Cordova splash screen plugin **iPad** landscape mode issue
|
||||
* [CB-10263](https://issues.apache.org/jira/browse/CB-10263) Fix splashscreen plugin filenames for Asset Catalog
|
||||
* [CB-9374](https://issues.apache.org/jira/browse/CB-9374) **Android** add `SplashShowOnlyFirstTime` as preference
|
||||
* [CB-10244](https://issues.apache.org/jira/browse/CB-10244) Don't rotate the **iPhone 6 Plus** splash
|
||||
* [CB-9043](https://issues.apache.org/jira/browse/CB-9043) Fix the **ios** splashscreen being deformed on orientation change
|
||||
* [CB-10079](https://issues.apache.org/jira/browse/CB-10079) Splashscreen plugin does not honor `SplashScreenDelay` on **iOS**
|
||||
* [CB-10231](https://issues.apache.org/jira/browse/CB-10231) Fix `FadeSplashScreen` to default to true on **iOS**
|
||||
|
||||
### 3.0.0 (Nov 18, 2015)
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
||||
* Fixing contribute link.
|
||||
* [CB-9750](https://issues.apache.org/jira/browse/CB-9750) `FadeSplashDuration` is now in `msecs`
|
||||
* [CB-8875](https://issues.apache.org/jira/browse/CB-8875) `FadeSplashScreen` was not fading
|
||||
* [CB-9467](https://issues.apache.org/jira/browse/CB-9467) SplashScreen does not show any image in hosted app on **Windows 10**
|
||||
* [CB-7282](https://issues.apache.org/jira/browse/CB-7282) Document `AutoHideSplashScreenpreference`
|
||||
* [CB-9327](https://issues.apache.org/jira/browse/CB-9327) - Splashscreen not receiving `CDVPageLoadNotification`
|
||||
* WP8: Avoid config `value` of a wrong element.
|
||||
|
||||
### 2.1.0 (Jun 17, 2015)
|
||||
* added missing license headers
|
||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-splashscreen documentation translation: cordova-plugin-splashscreen
|
||||
* fix npm md issue
|
||||
* Fixed iOS unit tests.
|
||||
* [CB-3562](https://issues.apache.org/jira/browse/CB-3562): Disable screen rotation for iPhone when splash screen is shown. (closes #47)
|
||||
* [CB-8988](https://issues.apache.org/jira/browse/CB-8988): Fix rotation on iOS/iPad (closes #46)
|
||||
* [CB-8904](https://issues.apache.org/jira/browse/CB-8904): Don't reset the static variable when it's destroyed, otherwise we might as well just have a member variable
|
||||
* Removed wp7 from `plugin.xml` and package.json
|
||||
* [CB-8750](https://issues.apache.org/jira/browse/CB-8750) [wp8]: Rewrite resoultion helper
|
||||
* [CB-8750](https://issues.apache.org/jira/browse/CB-8750) [wp8]: Allow resolution-specific splashscreen images
|
||||
* [CB-8758](https://issues.apache.org/jira/browse/CB-8758) [wp8]: UnauthorizedAccessException on hide()
|
||||
|
||||
### 2.0.0 (Apr 15, 2015)
|
||||
* give users a way to install the bleeding edge.
|
||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
|
||||
* [CB-8797](https://issues.apache.org/jira/browse/CB-8797) - Splashscreen preferences FadeSplashScreenDuration and FadeSplashScreen (iOS) are missing
|
||||
* [CB-8836](https://issues.apache.org/jira/browse/CB-8836) - Crashes after animating splashscreen
|
||||
* [CB-8753](https://issues.apache.org/jira/browse/CB-8753) android: Fix missing import in previous commit
|
||||
* [CB-8753](https://issues.apache.org/jira/browse/CB-8753) android: Adds `SplashMaintainAspectRatio` preference (close #43)
|
||||
* [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
|
||||
* [CB-8345](https://issues.apache.org/jira/browse/CB-8345) Make default for splashscreen resource "screen" (which is what template and CLI assume it to be)
|
||||
* Revert "CB-8345 android: Make "splash" the default resource ID instead of null"
|
||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
||||
* [CB-8345](https://issues.apache.org/jira/browse/CB-8345) android: Make "splash" the default resource ID instead of null
|
||||
* docs: added Windows to supported platforms
|
||||
* [CB-7964](https://issues.apache.org/jira/browse/CB-7964) Add cordova-plugin-splashscreen support for browser platform
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
|
||||
* [wp8] oops, Added back config parse result checks
|
||||
* [WP8] code cleanup, minor refactors, comments to clarify some stuff.
|
||||
* Extend WP8 Splash Screen to respect SplashScreen and SplashScreenDelay preferences from config file
|
||||
* [CB-8574](https://issues.apache.org/jira/browse/CB-8574) Integrate TravisCI
|
||||
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-splashscreen documentation translation: cordova-plugin-splashscreen
|
||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
||||
* [CB-8397](https://issues.apache.org/jira/browse/CB-8397) Add support to 'windows' for showing the Windows Phone splashscreen
|
||||
|
||||
### 1.0.0 (Feb 04, 2015)
|
||||
* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Stop using deprecated IsIpad macro
|
||||
* [CB-3679](https://issues.apache.org/jira/browse/CB-3679) Add engine tag for Android >= 3.6.0 due to use of `preferences`
|
||||
* [CB-3679](https://issues.apache.org/jira/browse/CB-3679) Make SplashScreen plugin compatible with cordova-android@4.0.x
|
||||
|
||||
### 0.3.5 (Dec 02, 2014)
|
||||
* [CB-7204](https://issues.apache.org/jira/browse/CB-7204) - Race condition when hiding and showing spinner (closes #21)
|
||||
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-splashscreen documentation translation: cordova-plugin-splashscreen
|
||||
|
||||
### 0.3.4 (Oct 03, 2014)
|
||||
* Finalized iOS splash screen (image name) tests. 176 tests in all, 44 for each type of device (iPad, iPhone, iPhone5, iPhone6, iPhone 6 Plus).
|
||||
* [CB-7633](https://issues.apache.org/jira/browse/CB-7633) - (Re-fix based on updated unit tests) iPhone 6 Plus support
|
||||
* Updated iOS tests for locked orientations
|
||||
* Added more iOS splash screen tests.
|
||||
* [CB-7633](https://issues.apache.org/jira/browse/CB-7633) - Add support for iPhone 6/6+
|
||||
* Added failing iPhone 6/6 Plus tests.
|
||||
* Added 'npm test'
|
||||
* [CB-7663](https://issues.apache.org/jira/browse/CB-7663) - iOS unit tests for splash screen
|
||||
* Properly formatted splashscreen preference docs.
|
||||
|
||||
### 0.3.3 (Sep 17, 2014)
|
||||
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-splashscreen documentation translation
|
||||
* Renamed test dir, added nested `plugin.xml`
|
||||
* added documentation for manual tests
|
||||
* [CB-7196](https://issues.apache.org/jira/browse/CB-7196) port splashscreen tests to framework
|
||||
|
||||
### 0.3.2 (Aug 06, 2014)
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
|
||||
* [CB-7041](https://issues.apache.org/jira/browse/CB-7041) ios: Fix image filename logic when setting the iPad splash screen
|
||||
* fixes Splashscreen crash on WP8
|
||||
* Remove outdated doc
|
||||
|
||||
### 0.3.1 (Jun 05, 2014)
|
||||
* documentation translation: cordova-plugin-splashscreen
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-splashscreen
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-splashscreen
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-splashscreen
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-splashscreen
|
||||
* [CB-6810](https://issues.apache.org/jira/browse/CB-6810) Add license to CONTRIBUTING.md
|
||||
* [wp8] updated quirk for and combined iOS,WP8,BB10 quirks as they are all the same
|
||||
* [wp] implemented OnInit so splash screen can be shown before cordova page is loaded
|
||||
* [wp] plugin must be autoloaded for AutoHideSplashScreen preference to work
|
||||
* [CB-6483](https://issues.apache.org/jira/browse/CB-6483) Use splash screen image from manifest on Windows8
|
||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
||||
* Revert "Merge branch 'tizen' of http://github.com/siovene/cordova-plugin-splashscreen"
|
||||
|
||||
### 0.3.0 (Apr 17, 2014)
|
||||
* Add Tizen support to plugin
|
||||
* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy
|
||||
* [CB-4051](https://issues.apache.org/jira/browse/CB-4051): [ios] - Re-fix - Splashscreen rotation problem (closes #13)
|
||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
|
||||
* [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code
|
||||
* Add NOTICE file
|
||||
|
||||
### 0.2.7 (Feb 05, 2014)
|
||||
* [CB-3562](https://issues.apache.org/jira/browse/CB-3562) Fix aspect ratio on landscape-only iPhone applications
|
||||
* [CB-4051](https://issues.apache.org/jira/browse/CB-4051) fix for splashscreen rotation problem
|
||||
|
||||
### 0.2.6 (Jan 02, 2014)
|
||||
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Splashscreen plugin
|
||||
* Handle error when splash image is missing.
|
||||
|
||||
### 0.2.5 (Dec 4, 2013)
|
||||
* add ubuntu platform
|
||||
* Added amazon-fireos platform. Change to use amazon-fireos as a platform if the user agent string contains 'cordova-amazon-fireos'
|
||||
* [CB-5124](https://issues.apache.org/jira/browse/CB-5124) - Remove splashscreen config.xml values from iOS Configuration Docs, move to plugin docs
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to `plugin.xml` for splashscreen plugin
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.3 (Oct 9, 2013)
|
||||
* [CB-4806](https://issues.apache.org/jira/browse/CB-4806) Re-fix Update splashscreen image bounds for iOS 7
|
||||
* [CB-4934](https://issues.apache.org/jira/browse/CB-4934) plugin-splashscreen should not show by default on Windows8
|
||||
* [CB-4929](https://issues.apache.org/jira/browse/CB-4929) plugin-splashscreen not loading proxy windows8
|
||||
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
|
||||
|
||||
### 0.2.2 (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.splashscreen to org.apache.cordova.splashscreen
|
||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
||||
* [CB-4806](https://issues.apache.org/jira/browse/CB-4806) Update splashscreen image bounds for iOS 7
|
||||
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
|
||||
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
# 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-splashscreen
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|
||||
Dieses Plugin zeigt und verbirgt einen Splash-Screen beim Start der Anwendung.
|
||||
|
||||
## Installation
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
|
||||
## Unterstützte Plattformen
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
* Windows
|
||||
* Browser
|
||||
|
||||
## Methoden
|
||||
|
||||
* SplashScreen.Show
|
||||
* SplashScreen.Hide
|
||||
|
||||
### Android Eigenarten
|
||||
|
||||
Sie müssen in Ihrem `"config.xml"`fügen Sie die folgenden Einstellungen:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
|
||||
|
||||
Wo Foo ist der Name der Datei Splashscreen, vorzugsweise eine 9-Patch-Datei. Stellen Sie sicher, Splashcreen Dateien zu Ihrem res/xml-Verzeichnis unter den entsprechenden Ordnern hinzuzufügen. Der zweite Parameter stellt dar, wie lange das Splashscreen in Millisekunden angezeigt werden. Es wird standardmäßig auf 3000 ms. Weitere Informationen finden Sie unter [Symbole und Splash-Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html).
|
||||
|
||||
"SplashMaintainAspectRatio" Präferenz ist optional. Wenn wahr, Splash-Screen zeichenbaren nicht gestreckt wird, um den Bildschirm passen, sondern stattdessen einfach "" den Bildschirm, wie CSS abdeckt "Hintergrund-Größe: Schutz vor". Dies ist sehr nützlich, wenn Splash-Bildschirm Bilder können nicht, in keiner Weise, zum Beispiel verzerrt werden wenn sie Landschaft oder Text enthalten. Diese Einstellung funktioniert am besten mit Bildern, die große Margen (sichere Bereiche) haben, die sicher auf Bildschirme mit unterschiedlichen Seitenverhältnissen zugeschnitten werden können.
|
||||
|
||||
Das Plugin lädt platsch zeichenbaren wenn Ausrichtung ändert, sodass Sie verschiedene Drawables für hoch- und Querformat Ausrichtungen angeben können.
|
||||
|
||||
### Browser-Eigenheiten
|
||||
|
||||
In Ihrem `"config.xml"`können Sie die folgenden Einstellungen:
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
|
||||
### iOS Macken
|
||||
|
||||
* `FadeSplashScreen` (Boolean, standardmäßig auf `true festgelegt`): um zu verhindern, dass den Begrüßungsbildschirm ein-und ausblenden bei ihrer Anzeige Statusänderungen auf `false` festgelegt.
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
|
||||
|
||||
* `FadeSplashScreenDuration` (float, Standardwert ist `2`): gibt die Anzahl der Sekunden für den Begrüßungsbildschirm fade Effekt ausgeführt.
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="4"/>
|
||||
|
||||
|
||||
* `ShowSplashScreenSpinner` (Boolean, standardmäßig auf `true festgelegt`): auf `false` festgelegt wird, um den Begrüßungsbildschirm Spinner auszublenden.
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
|
||||
|
||||
## SplashScreen.Hide
|
||||
|
||||
Schließen Sie den Splash-Screen.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Eigenarten
|
||||
|
||||
Die Datei `config.xml` `AutoHideSplashScreen` Einstellung muss `false` sein. Verstecken des Begrüßungsbildschirms für zwei Sekunden Verzögerung, fügen Sie einen Timer wie die folgende in der `deviceready`-Ereignishandler:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## SplashScreen.Show
|
||||
|
||||
Zeigt den Begrüßungsbildschirm.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
Ihre Anwendung kann nicht `navigator.splashscreen.show()` aufrufen, bis die app begonnen hat und das `deviceready`-Ereignis ausgelöst hat. Aber da in der Regel der Splash-Screen soll sichtbar sein, bevor die Anwendung gestartet wurde, scheint die Niederlage der Zweck des Begrüßungsbildschirms. Somit einige Konfiguration in der Datei `config.xml` werden automatisch die Splash `show` sofort nach Ihrer app-Start und Bildschirm bevor es voll begonnen hat, und das `deviceready`-Ereignis empfangen. Weitere Informationen zu dieser Konfiguration finden Sie unter [Symbole und Splash-Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html). Aus diesem Grund ist es unwahrscheinlich, dass Sie `navigator.splashscreen.show()` damit den Splash-Screen sichtbar ist für app-Start aufrufen müssen.
|
||||
@@ -0,0 +1,78 @@
|
||||
<!---
|
||||
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-splashscreen
|
||||
|
||||
Dieses Plugin zeigt und verbirgt einen Splash-Screen beim Start der Anwendung.
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
|
||||
## Unterstützte Plattformen
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 und 8
|
||||
* Windows 8
|
||||
|
||||
## Methoden
|
||||
|
||||
* SplashScreen.Show
|
||||
* SplashScreen.Hide
|
||||
|
||||
### Android Eigenarten
|
||||
|
||||
Sie müssen in der config.xml folgende Einstellungen vornehmen:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
|
||||
|
||||
Wo Foo ist der Name der Datei Splashscreen, vorzugsweise eine 9-Patch-Datei. Stellen Sie sicher, Splashcreen Dateien zu Ihrem res/xml-Verzeichnis unter den entsprechenden Ordnern hinzuzufügen. Der zweite Parameter stellt dar, wie lange das Splashscreen in Millisekunden angezeigt werden. Es wird standardmäßig auf 3000 ms. Weitere Informationen finden Sie unter [Symbole und Splash-Screens][1].
|
||||
|
||||
[1]: http://cordova.apache.org/docs/en/edge/config_ref_images.md.html
|
||||
|
||||
## SplashScreen.Hide
|
||||
|
||||
Schließen Sie den Splash-Screen.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Eigenarten
|
||||
|
||||
Die Datei `config.xml` `AutoHideSplashScreen` Einstellung muss `false` sein. Verstecken des Begrüßungsbildschirms für zwei Sekunden Verzögerung, fügen Sie einen Timer wie die folgende in der `deviceready`-Ereignishandler:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## SplashScreen.Show
|
||||
|
||||
Zeigt den Begrüßungsbildschirm.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
Ihre Anwendung kann nicht `navigator.splashscreen.show()` aufrufen, bis die app begonnen hat und das `deviceready`-Ereignis ausgelöst hat. Aber da in der Regel der Splash-Screen soll sichtbar sein, bevor die Anwendung gestartet wurde, scheint die Niederlage der Zweck des Begrüßungsbildschirms. Somit einige Konfiguration in der Datei `config.xml` werden automatisch die Splash `show` sofort nach Ihrer app-Start und Bildschirm bevor es voll begonnen hat, und das `deviceready`-Ereignis empfangen. Weitere Informationen zu dieser Konfiguration finden Sie unter [Symbole und Splash-Screens][1]. Aus diesem Grund ist es unwahrscheinlich, dass Sie `navigator.splashscreen.show()` damit den Splash-Screen sichtbar ist für app-Start aufrufen müssen.
|
||||
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
# 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-splashscreen
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|
||||
Este plugin muestra y esconde una pantalla de bienvenida durante el inicio de la aplicación.
|
||||
|
||||
## Instalación
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
|
||||
## Plataformas soportadas
|
||||
|
||||
* Amazon fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
* Windows
|
||||
* Explorador
|
||||
|
||||
## Métodos
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.hide
|
||||
|
||||
### Rarezas Android
|
||||
|
||||
En el `archivo config.xml`, es necesario agregar las siguientes preferencias:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
|
||||
|
||||
Donde foo es el nombre del archivo splashscreen, preferiblemente un archivo de 9 parche. Asegúrese de agregar tus archivos splashcreen en tu directorio res/xml bajo las carpetas apropiadas. El segundo parámetro representa cuánto aparecerán el splashscreen en milisegundos. Valor predeterminado es ms 3000. Ver [los iconos y salpicadura pantallas](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) para obtener más información.
|
||||
|
||||
Preferencia "SplashMaintainAspectRatio" es opcional. Si establece en true, pantalla dibujable no es estirado para caber la pantalla, pero en su lugar simplemente "cover" la pantalla, como CSS "background-size: cover". Esto es muy útil cuando las imágenes de pantallas splash no distorsionadas de cualquier manera, por ejemplo cuando contienen texto o paisaje. Esta opción funciona mejor con imágenes que tienen bordes grandes (zonas seguras) que pueden ser recortadas con seguridad en pantallas con diferentes relaciones de aspecto.
|
||||
|
||||
El plugin recarga splash dibujable cuando cambia de orientación, por lo que puede especificar diferente dibujo para orientaciones vertical y horizontal.
|
||||
|
||||
### Navegador rarezas
|
||||
|
||||
Puede utilizar las siguientes preferencias en el `archivo config.xml`:
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
|
||||
### iOS rarezas
|
||||
|
||||
* `FadeSplashScreen` (booleano, por defecto `true`): establecida en `false` para evitar que la pantalla de bienvenida de descolorarse adentro y hacia fuera cuando cambia su estado de presentación.
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
|
||||
|
||||
* `FadeSplashScreenDuration` (float, por defecto es `2`): especifica el número de segundos para que la pantalla se descolora efecto para ejecutar.
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="4"/>
|
||||
|
||||
|
||||
* `ShowSplashScreenSpinner` (booleano, por defecto `true`): establecida en `false` para ocultar la ruleta de la pantalla de bienvenida.
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
Despedir a la pantalla de bienvenida.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Quirk
|
||||
|
||||
El `config.xml` del archivo `AutoHideSplashScreen` la configuración debe ser `false` . Para retrasar oculta la pantalla splash durante dos segundos, agregue un temporizador como la siguiente en el `deviceready` controlador de eventos:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
Muestra la pantalla de bienvenida.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
La aplicación no se puede llamar `navigator.splashscreen.show()` hasta que haya iniciado la aplicación y el `deviceready` evento ha despedido. Pero puesto que normalmente la pantalla está destinada a ser visible antes de que comience su aplicación, que parecería que el propósito de la pantalla de bienvenida. Proporcionar cierta configuración en `config.xml` automáticamente `show` la pantalla de presentación inmediatamente después de su lanzamiento de la aplicación y antes de ser completamente ha iniciado y recibió el `deviceready` evento. Ver [los iconos y salpicadura pantallas](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) para obtener más información sobre haciendo esta configuración. Por esta razón, es poco probable que necesitas llamar a `navigator.splashscreen.show()` para hacer la pantalla visible para el inicio de la aplicación.
|
||||
@@ -0,0 +1,76 @@
|
||||
<!---
|
||||
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-splashscreen
|
||||
|
||||
Este plugin muestra y esconde una pantalla de bienvenida durante el inicio de la aplicación.
|
||||
|
||||
## Instalación
|
||||
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
|
||||
## Plataformas soportadas
|
||||
|
||||
* Amazon fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 y 8
|
||||
* Windows 8
|
||||
|
||||
## Métodos
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.hide
|
||||
|
||||
### Rarezas Android
|
||||
|
||||
En el archivo config.xml, tienes que añadir las siguientes preferencias:
|
||||
|
||||
< nombre de preferencia = "SplashScreen" value = "foo" / >< nombre de preferencia = "SplashScreenDelay" value = "10000" / >
|
||||
|
||||
|
||||
Donde foo es el nombre del archivo splashscreen, preferiblemente un archivo de 9 parche. Asegúrese de agregar tus archivos splashcreen en tu directorio res/xml bajo las carpetas apropiadas. El segundo parámetro representa cuánto aparecerán el splashscreen en milisegundos. Valor predeterminado es ms 3000. Ver [los iconos y salpicadura pantallas][1] para obtener más información.
|
||||
|
||||
[1]: http://cordova.apache.org/docs/en/edge/config_ref_images.md.html
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
Despedir a la pantalla de bienvenida.
|
||||
|
||||
Navigator.SplashScreen.Hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Quirk
|
||||
|
||||
El `config.xml` del archivo `AutoHideSplashScreen` la configuración debe ser `false` . Para retrasar oculta la pantalla splash durante dos segundos, agregue un temporizador como la siguiente en el `deviceready` controlador de eventos:
|
||||
|
||||
setTimeout(function() {navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
Muestra la pantalla de bienvenida.
|
||||
|
||||
Navigator.SplashScreen.Show();
|
||||
|
||||
|
||||
La aplicación no se puede llamar `navigator.splashscreen.show()` hasta que haya iniciado la aplicación y el `deviceready` evento ha despedido. Pero puesto que normalmente la pantalla está destinada a ser visible antes de que comience su aplicación, que parecería que el propósito de la pantalla de bienvenida. Proporcionar cierta configuración en `config.xml` automáticamente `show` la pantalla de presentación inmediatamente después de su lanzamiento de la aplicación y antes de ser completamente ha iniciado y recibió el `deviceready` evento. Ver [los iconos y salpicadura pantallas][1] para obtener más información sobre haciendo esta configuración. Por esta razón, es poco probable que necesitas llamar a `navigator.splashscreen.show()` para hacer la pantalla visible para el inicio de la aplicación.
|
||||
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
# 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-splashscreen
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|
||||
Ce plugin affiche et masque un écran de démarrage lors du lancement de l'application.
|
||||
|
||||
## Installation
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
|
||||
## Plates-formes supportées
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
* Windows
|
||||
* Navigateur
|
||||
|
||||
## Méthodes
|
||||
|
||||
* splashscreen.Show
|
||||
* splashscreen.Hide
|
||||
|
||||
### Quirks Android
|
||||
|
||||
Dans votre `fichier config.xml`, vous devez ajouter les préférences suivantes :
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
|
||||
|
||||
Où foo est le nom du fichier splashscreen, préférablement un fichier de 9 correctif. Assurez-vous d'ajouter vos fichiers splashcreen dans votre répertoire res/xml dans les dossiers appropriés. Le deuxième paramètre représente combien de temps le splashscreen apparaîtra en millisecondes. Il est par défaut à 3000 ms. Pour plus d'informations, consultez [icônes et écrans de démarrage](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html).
|
||||
|
||||
Préférence de « SplashMaintainAspectRatio » est facultative. Si défini à true, écran de démarrage drawable n'est pas étirée pour s'adapter écran, mais plutôt simplement « couvre » l'écran, comme CSS "fond-taille : couverture". Ceci est très utile lorsque images écran de démarrage ne peut pas être déformées en quelque sorte, par exemple lorsqu'ils contiennent des décors ou texte. Ce paramètre fonctionne mieux avec des images qui ont des marges importantes (zones de sécurité) qui peuvent être recadrées en toute sécurité sur les écrans avec des proportions différentes.
|
||||
|
||||
Le plugin recharge splash drawable chaque fois que l'orientation change, donc vous pouvez spécifier différents drawables pour les orientations portrait et paysage.
|
||||
|
||||
### Bizarreries navigateur
|
||||
|
||||
Vous pouvez utiliser les préférences suivantes dans votre `fichier config.xml`:
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
|
||||
### Notes au sujet d'iOS
|
||||
|
||||
* `FadeSplashScreen` (boolean, par défaut est `true`): la valeur `false` pour empêcher l'écran de démarrage de fading in et out lorsque son état d'affichage est modifié.
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
|
||||
|
||||
* `FadeSplashScreenDuration` (float, la valeur par défaut `2`): spécifie le nombre de secondes que l'écran de démarrage s'estomper l'effet d'exécuter.
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="4"/>
|
||||
|
||||
|
||||
* `ShowSplashScreenSpinner` (boolean, par défaut est `true`): la valeur `false` pour masquer le cône de l'écran de démarrage.
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
|
||||
|
||||
## splashscreen.Hide
|
||||
|
||||
Faire disparaître de l'écran de démarrage.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Quirk
|
||||
|
||||
Paramètre `AutoHideSplashScreen` du fichier `config.xml` doit avoir la valeur `false`. Pour retarder la cacher l'écran de démarrage pendant deux secondes, ajouter un minuteur semblable à la suivante dans le gestionnaire d'événements `deviceready` :
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.Show
|
||||
|
||||
Affiche l'écran de démarrage.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
Votre application ne peut pas appeler `navigator.splashscreen.show()` jusqu'à ce que l'application a commencé et l'événement `deviceready` est déclenché. Mais puisqu'en général, l'écran de démarrage est destiné à être visible avant que votre application a commencé, qui semblerait à l'encontre des objectifs de l'écran de démarrage. Fournir une configuration dans le fichier `config.xml` automatiquement `show` le splash projettera immédiatement après votre lancement de l'app et avant qu'il a complètement démarré et a reçu l'événement `deviceready`. Voir les [icônes et les écrans de démarrage](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) pour plus d'informations sur la conduite de cette configuration. Pour cette raison, il est peu probable que vous devez appeler `navigator.splashscreen.show()` pour rendre l'écran de démarrage visible pour le démarrage de l'application.
|
||||
@@ -0,0 +1,78 @@
|
||||
<!---
|
||||
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-splashscreen
|
||||
|
||||
Ce plugin affiche et masque un écran de démarrage lors du lancement de l'application.
|
||||
|
||||
## Installation
|
||||
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
|
||||
## Plates-formes prises en charge
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 et 8
|
||||
* Windows 8
|
||||
|
||||
## Méthodes
|
||||
|
||||
* splashscreen.Show
|
||||
* splashscreen.Hide
|
||||
|
||||
### Quirks Android
|
||||
|
||||
Dans votre fichier config.xml, vous devez ajouter les préférences suivantes :
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
|
||||
|
||||
Où foo est le nom du fichier splashscreen, préférablement un fichier de 9 correctif. Assurez-vous d'ajouter vos fichiers splashcreen dans votre répertoire res/xml dans les dossiers appropriés. Le deuxième paramètre représente combien de temps le splashscreen apparaîtra en millisecondes. Il est par défaut à 3000 ms. Pour plus d'informations, consultez [icônes et écrans de démarrage][1].
|
||||
|
||||
[1]: http://cordova.apache.org/docs/en/edge/config_ref_images.md.html
|
||||
|
||||
## splashscreen.Hide
|
||||
|
||||
Faire disparaître de l'écran de démarrage.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Quirk
|
||||
|
||||
Paramètre `AutoHideSplashScreen` du fichier `config.xml` doit avoir la valeur `false`. Pour retarder la cacher l'écran de démarrage pendant deux secondes, ajouter un minuteur semblable à la suivante dans le gestionnaire d'événements `deviceready` :
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.Show
|
||||
|
||||
Affiche l'écran de démarrage.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
Votre application ne peut pas appeler `navigator.splashscreen.show()` jusqu'à ce que l'application a commencé et l'événement `deviceready` est déclenché. Mais puisqu'en général, l'écran de démarrage est destiné à être visible avant que votre application a commencé, qui semblerait à l'encontre des objectifs de l'écran de démarrage. Fournir une configuration dans le fichier `config.xml` automatiquement `show` le splash projettera immédiatement après votre lancement de l'app et avant qu'il a complètement démarré et a reçu l'événement `deviceready`. Voir les [icônes et les écrans de démarrage][1] pour plus d'informations sur la conduite de cette configuration. Pour cette raison, il est peu probable que vous devez appeler `navigator.splashscreen.show()` pour rendre l'écran de démarrage visible pour le démarrage de l'application.
|
||||
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
# 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-splashscreen
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|
||||
Questo plugin Visualizza e nasconde una schermata iniziale durante l'avvio dell'applicazione.
|
||||
|
||||
## Installazione
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
|
||||
## Piattaforme supportate
|
||||
|
||||
* Amazon fuoco OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
* Windows
|
||||
* Browser
|
||||
|
||||
## Metodi
|
||||
|
||||
* splashscreen
|
||||
* splashscreen.Hide
|
||||
|
||||
### Stranezze Android
|
||||
|
||||
Nel vostro `config. XML`, è necessario aggiungere le seguenti preferenze:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
|
||||
|
||||
Dove foo è il nome del file splashscreen, preferibilmente un file 9 patch. Assicurati di aggiungere i tuoi file splashcreen res/xml nella directory sotto cartelle appropriate. Il secondo parametro rappresenta quanto tempo lo splashscreen apparirà in millisecondi. Il valore predefinito è 3000 ms. Per ulteriori informazioni, vedere [icone e schermate iniziali](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html).
|
||||
|
||||
"SplashMaintainAspectRatio" preferenza è facoltativo. Se impostato su true, schermata iniziale drawable non viene adattata per misura lo schermo, ma invece semplicemente "copre" lo schermo, come CSS "sfondo-dimensione: copertina". Questo è molto utile quando immagini schermata iniziale non possono essere distorta in qualche modo, per esempio quando contengono testo o scenario. Questa impostazione funziona meglio con immagini che hanno grandi margini (zone sicure) che possono essere ritagliati in modo sicuro su schermi con proporzioni diverse.
|
||||
|
||||
Il plugin viene ricaricata splash drawable ogni volta che cambia orientamento, è possibile specificare diversi parte per orientamento verticale e orizzontale.
|
||||
|
||||
### Stranezze browser
|
||||
|
||||
Nel vostro `config. XML`, è possibile utilizzare le seguenti preferenze:
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
|
||||
### iOS stranezze
|
||||
|
||||
* `FadeSplashScreen` (boolean, impostazioni predefinite a `true`): impostare su `false` per impedire che la schermata iniziale e scompaiono quando cambia il relativo stato di visualizzazione.
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
|
||||
|
||||
* `FadeSplashScreenDuration` (float, il valore predefinito è `2`): specifica il numero di secondi per la schermata iniziale dissolvenza effetto da eseguire.
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="4"/>
|
||||
|
||||
|
||||
* `ShowSplashScreenSpinner` (boolean, impostazioni predefinite a `true`): impostare su `false` per nascondere la filatrice schermata iniziale.
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
|
||||
|
||||
## splashscreen.Hide
|
||||
|
||||
Respingere la schermata iniziale.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Quirk
|
||||
|
||||
Impostazione `AutoHideSplashScreen` del file `config.xml` deve essere `false`. Per ritardare nascondendo la schermata iniziale per due secondi, aggiungere un timer ad esempio nel gestore eventi `deviceready`:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen
|
||||
|
||||
Visualizza la schermata iniziale.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
L'applicazione non può chiamare `navigator.splashscreen.show()` fino a quando l'app ha iniziato e ha generato l'evento `deviceready`. Ma poiché in genere la schermata iniziale è destinata ad essere visibile prima app ha iniziato, che sembrerebbe per sconfiggere lo scopo della schermata iniziale. Fornendo qualche configurazione nel `file config.xml` sarà automaticamente `show` il tonfo schermo subito dopo il lancio dell'app e prima che completamente ha iniziato e ha ricevuto l'evento `deviceready`. Per ulteriori informazioni su facendo questa configurazione, vedere [icone e schermate iniziali](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html). Per questo motivo, è improbabile che dovete chiamare `navigator.splashscreen.show()` per rendere la schermata visibile per avvio di app.
|
||||
@@ -0,0 +1,78 @@
|
||||
<!---
|
||||
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-splashscreen
|
||||
|
||||
Questo plugin Visualizza e nasconde una schermata iniziale durante l'avvio dell'applicazione.
|
||||
|
||||
## Installazione
|
||||
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
|
||||
## Piattaforme supportate
|
||||
|
||||
* Amazon fuoco OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 e 8
|
||||
* Windows 8
|
||||
|
||||
## Metodi
|
||||
|
||||
* splashscreen
|
||||
* splashscreen.Hide
|
||||
|
||||
### Stranezze Android
|
||||
|
||||
Nel vostro config. xml, è necessario aggiungere le seguenti preferenze:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
|
||||
|
||||
Dove foo è il nome del file splashscreen, preferibilmente un file 9 patch. Assicurati di aggiungere i tuoi file splashcreen res/xml nella directory sotto cartelle appropriate. Il secondo parametro rappresenta quanto tempo lo splashscreen apparirà in millisecondi. Il valore predefinito è 3000 ms. Per ulteriori informazioni, vedere [icone e schermate iniziali][1].
|
||||
|
||||
[1]: http://cordova.apache.org/docs/en/edge/config_ref_images.md.html
|
||||
|
||||
## splashscreen.Hide
|
||||
|
||||
Respingere la schermata iniziale.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### BlackBerry 10, WP8, iOS Quirk
|
||||
|
||||
Impostazione `AutoHideSplashScreen` del file `config.xml` deve essere `false`. Per ritardare nascondendo la schermata iniziale per due secondi, aggiungere un timer ad esempio nel gestore eventi `deviceready`:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen
|
||||
|
||||
Visualizza la schermata iniziale.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
L'applicazione non può chiamare `navigator.splashscreen.show()` fino a quando l'app ha iniziato e ha generato l'evento `deviceready`. Ma poiché in genere la schermata iniziale è destinata ad essere visibile prima app ha iniziato, che sembrerebbe per sconfiggere lo scopo della schermata iniziale. Fornendo qualche configurazione nel `file config.xml` sarà automaticamente `show` il tonfo schermo subito dopo il lancio dell'app e prima che completamente ha iniziato e ha ricevuto l'evento `deviceready`. Per ulteriori informazioni su facendo questa configurazione, vedere [icone e schermate iniziali][1]. Per questo motivo, è improbabile che dovete chiamare `navigator.splashscreen.show()` per rendere la schermata visibile per avvio di app.
|
||||
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
# 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-splashscreen
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|
||||
このプラグインが表示され、アプリケーションの起動中にスプラッシュ スクリーンを非表示にします。
|
||||
|
||||
## インストール
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
|
||||
## サポートされているプラットフォーム
|
||||
|
||||
* アマゾン火 OS
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* iOS
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
* Windows
|
||||
* ブラウザー
|
||||
|
||||
## メソッド
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.hide
|
||||
|
||||
### Android の癖
|
||||
|
||||
あなたの`config.xml`内の次の設定を追加する必要があります。
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
|
||||
|
||||
Foo ができれば 9 パッチファイル splashscreen ファイルの名前です。 解像度/xml ディレクトリの適切なフォルダーの下に splashcreen ファイルを追加することを確認します。 2 番目のパラメーターは、スプラッシュ ・ スクリーンがの表示時間 (ミリ秒単位) を表します。 デフォルトでは 3000 ミリ秒です。 詳細については、[アイコンとスプラッシュ画面](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) を参照してください。
|
||||
|
||||
"SplashMaintainAspectRatio"の設定はオプションです。 True の場合、スプラッシュ画面描画に設定画面を埋めるために拡大されませんが、代わりに単に「カバー」画面では、CSS のような場合「背景-サイズ: カバー」. これは、たとえば風景またはテキストが含まれている場合、任意の方法でスプラッシュ画面画像が歪むことができない非常に便利です。 この設定は、画面と異なる縦横比で安全にトリミングすることができます大規模なマージン (安全な地域) の画像に適しています。
|
||||
|
||||
縦長と横長の異なるドロウアブルを指定できるように、プラグインは向きを変更するたびにスプラッシュ ドロウアブルをリロードします。
|
||||
|
||||
### ブラウザーの癖
|
||||
|
||||
あなたの`config.xml`で次の設定を使用できます。
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
|
||||
### iOS の癖
|
||||
|
||||
* `FadeSplashScreen`(ブール値、既定で [ `true`): スプラッシュ画面がフェードインとフェードアウトの表示状態が変更されたときすることを防ぐために`false`に設定します。
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
|
||||
|
||||
* `FadeSplashScreenDuration`(float, デフォルトは`2`): スプラッシュ画面の秒数のフェードを実行する効果を指定します。
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="4"/>
|
||||
|
||||
|
||||
* `ShowSplashScreenSpinner`(ブール値、既定で [ `true`): スプラッシュ スクリーン スピナーを非表示にするを`false`に設定します。
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
スプラッシュ スクリーンを閉じます。
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### ブラックベリー 10、WP8、iOS の気まぐれ
|
||||
|
||||
`config.xml` ファイルの `AutoHideSplashScreen` の設定は `false` である必要があります。 遅延を 2 秒間スプラッシュ スクリーンを非表示に `deviceready` イベント ハンドラーで、次のようタイマーを追加します。
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
スプラッシュ画面が表示されます。
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
アプリが開始され、`deviceready` イベントが発生するまで、アプリケーションは `navigator.splashscreen.show()` を呼び出すことはできません。 しかし、以来、通常スプラッシュ画面アプリ開始前に表示するものですと思われる、スプラッシュ スクリーンの目的の敗北します。 `config.xml` にいくつかの構成を提供するは自動的に `表示` スプラッシュ画面、アプリを起動後すぐに、それが完全に起動し、`deviceready` イベントを受信する前に。 詳細についてはこの構成を行うには、[アイコンとスプラッシュ画面](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) を参照してください。 この理由のためにアプリ起動時のスプラッシュ スクリーンを確認 `navigator.splashscreen.show()` をコールする必要がある可能性が高いです。
|
||||
@@ -0,0 +1,78 @@
|
||||
<!---
|
||||
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-splashscreen
|
||||
|
||||
このプラグインが表示され、アプリケーションの起動中にスプラッシュ スクリーンを非表示にします。
|
||||
|
||||
## インストール
|
||||
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
|
||||
## サポートされているプラットフォーム
|
||||
|
||||
* アマゾン火 OS
|
||||
* アンドロイド
|
||||
* ブラックベリー 10
|
||||
* iOS
|
||||
* Windows Phone 7 と 8
|
||||
* Windows 8
|
||||
|
||||
## メソッド
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.hide
|
||||
|
||||
### Android の癖
|
||||
|
||||
あなたの config.xml を以下の設定を追加する必要があります。
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
|
||||
|
||||
Foo ができれば 9 パッチファイル splashscreen ファイルの名前です。 解像度/xml ディレクトリの適切なフォルダーの下に splashcreen ファイルを追加することを確認します。 2 番目のパラメーターは、スプラッシュ ・ スクリーンがの表示時間 (ミリ秒単位) を表します。 デフォルトでは 3000 ミリ秒です。 詳細については、[アイコンとスプラッシュ画面][1] を参照してください。
|
||||
|
||||
[1]: http://cordova.apache.org/docs/en/edge/config_ref_images.md.html
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
スプラッシュ スクリーンを閉じます。
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### ブラックベリー 10、WP8、iOS の気まぐれ
|
||||
|
||||
`config.xml` ファイルの `AutoHideSplashScreen` の設定は `false` である必要があります。 遅延を 2 秒間スプラッシュ スクリーンを非表示に `deviceready` イベント ハンドラーで、次のようタイマーを追加します。
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
スプラッシュ画面が表示されます。
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
アプリが開始され、`deviceready` イベントが発生するまで、アプリケーションは `navigator.splashscreen.show()` を呼び出すことはできません。 しかし、以来、通常スプラッシュ画面アプリ開始前に表示するものですと思われる、スプラッシュ スクリーンの目的の敗北します。 `config.xml` にいくつかの構成を提供するは自動的に `表示` スプラッシュ画面、アプリを起動後すぐに、それが完全に起動し、`deviceready` イベントを受信する前に。 詳細についてはこの構成を行うには、[アイコンとスプラッシュ画面][1] を参照してください。 この理由のためにアプリ起動時のスプラッシュ スクリーンを確認 `navigator.splashscreen.show()` をコールする必要がある可能性が高いです。
|
||||
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
# 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-splashscreen
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|
||||
이 플러그인은 표시 하 고 응용 프로그램 실행 하는 동안 시작 화면을 숨깁니다.
|
||||
|
||||
## 설치
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
|
||||
## 지원 되는 플랫폼
|
||||
|
||||
* 아마존 화재 운영 체제
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* iOS
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
* 윈도우
|
||||
* 브라우저
|
||||
|
||||
## 메서드
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.hide
|
||||
|
||||
### 안 드 로이드 단점
|
||||
|
||||
`Config.xml`에 다음 환경 설정에 추가 해야 합니다.
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
|
||||
|
||||
여기서 foo splashscreen 파일, 선호 9 패치 파일의 이름입니다. 적절 한 폴더 아래 res/xml 디렉토리에 splashcreen 파일을 추가 해야 합니다. 두 번째 매개 변수는 splashscreen 얼마나 밀리초 단위로 표시 됩니다 나타냅니다. 3000 ms 기본값으로 사용 됩니다. 자세한 내용은 [아이콘 및 시작 화면을](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) 참조 하십시오.
|
||||
|
||||
"SplashMaintainAspectRatio" 취향은 선택 사항입니다. Drawable, 시작 화면 설정 화면에 맞게 확장 되지 하지만 대신 단순히 "커버" CSS 같은 화면 "배경-크기: 덮개". 시작 화면 이미지 예: 풍경 또는 텍스트를 포함 하는 경우 어떤 식으로든에서 왜곡 될 수 없는 경우에 매우 유용 합니다. 이 설정은 큰 여백 (안전 지역) 안전 하 게 다른 종횡비와 화면에 자를 수 있는 이미지에 가장 적합 합니다.
|
||||
|
||||
플러그인 다시 로드 스플래시 drawable 방향이 변경 될 때마다 세로 및 가로 방향에 대 한 다른 drawables를 지정할 수 있도록 합니다.
|
||||
|
||||
### 브라우저 만지면
|
||||
|
||||
`Config.xml`에 다음 기본 설정을 사용할 수 있습니다.
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
|
||||
### iOS 단점
|
||||
|
||||
* `FadeSplashScreen` (부울 `true`로 기본값): 시작 화면 표시 상태로 변경 될 때 밖으로 퇴색 하지 않도록 하려면 `false` 로 설정.
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
|
||||
|
||||
* `FadeSplashScreenDuration` (부동, `2`기본값): 시작 화면에 대 한 초 페이드 효과를 실행 하는 지정 합니다.
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="4"/>
|
||||
|
||||
|
||||
* `ShowSplashScreenSpinner` (부울 `true`로 기본값): 스플래시 화면 회전자를 숨기려면 `false` 로 설정.
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
시작 화면을 닫습니다.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### 블랙베리 10, WP8, iOS 특질
|
||||
|
||||
`config.xml` 파일의 `AutoHideSplashScreen` 설정을 `false` 여야 합니다. 2 초 동안 시작 화면을 숨기고 지연, `deviceready` 이벤트 처리기에서 다음과 같은 타이머를 추가:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
시작 화면을 표시합니다.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
응용 프로그램 시작 및 `deviceready` 이벤트는 발생 될 때까지 응용 프로그램이 `navigator.splashscreen.show()`을 호출할 수 없습니다. 하지만 그 스플래시 스크린의 목적 것 같다 일반적으로 시작 화면이 당신의 애플 리 케이 션 시작 하기 전에 표시 될 운명이 다, 이후. `config.xml에서` 몇 가지 구성을 제공 하 자동으로 스플래시 `표시` 화면 애플 리 케이 션 출시 직후와 그것은 완벽 하 게 시작 하 고 `deviceready` 이벤트를 받은 전에. 이 구성 하 고 자세한 내용은 [아이콘 및 시작 화면을](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html) 참조 하십시오. 이러한 이유로, 그것은 가능성이 시작 화면은 응용 프로그램 시작에 대 한 표시 되도록 `navigator.splashscreen.show()`를 호출 해야입니다.
|
||||
@@ -0,0 +1,78 @@
|
||||
<!---
|
||||
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-splashscreen
|
||||
|
||||
이 플러그인은 표시 하 고 응용 프로그램 실행 하는 동안 시작 화면을 숨깁니다.
|
||||
|
||||
## 설치
|
||||
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
|
||||
## 지원 되는 플랫폼
|
||||
|
||||
* 아마존 화재 운영 체제
|
||||
* 안 드 로이드
|
||||
* 블랙베리 10
|
||||
* iOS
|
||||
* Windows Phone 7과 8
|
||||
* 윈도우 8
|
||||
|
||||
## 메서드
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.hide
|
||||
|
||||
### 안 드 로이드 단점
|
||||
|
||||
당신의 config.xml에 다음 환경 설정에 추가 해야 합니다.
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
|
||||
|
||||
여기서 foo splashscreen 파일, 선호 9 패치 파일의 이름입니다. 적절 한 폴더 아래 res/xml 디렉토리에 splashcreen 파일을 추가 해야 합니다. 두 번째 매개 변수는 splashscreen 얼마나 밀리초 단위로 표시 됩니다 나타냅니다. 3000 ms 기본값으로 사용 됩니다. 자세한 내용은 [아이콘 및 시작 화면을][1] 참조 하십시오.
|
||||
|
||||
[1]: http://cordova.apache.org/docs/en/edge/config_ref_images.md.html
|
||||
|
||||
## splashscreen.hide
|
||||
|
||||
시작 화면을 닫습니다.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### 블랙베리 10, WP8, iOS 특질
|
||||
|
||||
`config.xml` 파일의 `AutoHideSplashScreen` 설정을 `false` 여야 합니다. 2 초 동안 시작 화면을 숨기고 지연, `deviceready` 이벤트 처리기에서 다음과 같은 타이머를 추가:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
시작 화면을 표시합니다.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
응용 프로그램 시작 및 `deviceready` 이벤트는 발생 될 때까지 응용 프로그램이 `navigator.splashscreen.show()`을 호출할 수 없습니다. 하지만 그 스플래시 스크린의 목적 것 같다 일반적으로 시작 화면이 당신의 애플 리 케이 션 시작 하기 전에 표시 될 운명이 다, 이후. `config.xml에서` 몇 가지 구성을 제공 하 자동으로 스플래시 `표시` 화면 애플 리 케이 션 출시 직후와 그것은 완벽 하 게 시작 하 고 `deviceready` 이벤트를 받은 전에. 이 구성 하 고 자세한 내용은 [아이콘 및 시작 화면을][1] 참조 하십시오. 이러한 이유로, 그것은 가능성이 시작 화면은 응용 프로그램 시작에 대 한 표시 되도록 `navigator.splashscreen.show()`를 호출 해야입니다.
|
||||
@@ -0,0 +1,119 @@
|
||||
<!--
|
||||
# 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-splashscreen
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-splashscreen)
|
||||
|
||||
Ten plugin wyświetla i ukrywa ekran powitalny podczas uruchamiania aplikacji.
|
||||
|
||||
## Instalacja
|
||||
|
||||
// npm hosted (new) id
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
// you may also install directly from this repo
|
||||
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
|
||||
|
||||
|
||||
## Obsługiwane platformy
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
* Windows
|
||||
* Przeglądarka
|
||||
|
||||
## Metody
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.Hide
|
||||
|
||||
### Dziwactwa Androida
|
||||
|
||||
W pliku `config.xml`musisz dodać następujące preferencje:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true|false" />
|
||||
|
||||
|
||||
Gdzie foo jest nazwą pliku ekranu powitalnego, najlepiej 9 łatce. Upewnij się dodać pliki splashcreen do katalogu res/xml w odpowiednich folderach. Drugi parametr reprezentuje, jak długo ekranu powitalnego pojawi się w milisekundach. Domyślnie 3000 ms. Aby uzyskać więcej informacji, zobacz [ikony i ekrany powitalne w aplikacjach](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html).
|
||||
|
||||
"SplashMaintainAspectRatio" preferencji jest opcjonalne. Jeśli zestaw na wartość true, ekran powitalny dolarowe nie jest rozciągnięty do ekranów, ale zamiast po prostu "obejmuje" ekranu, jak CSS "tło-rozmiar: okładka". Jest to bardzo przydatne, kiedy opryskać tęcza obrazy nie zniekształcony w jakikolwiek sposób, na przykład, gdy zawierają one dekoracje lub tekst. To ustawienie działa najlepiej z obrazów, które mają duże marginesy (bezpiecznych obszarów), które mogą być bezpiecznie przycięte na ekrany z różnych proporcji.
|
||||
|
||||
Plugin ładuje rozchlapać dolarowe, gdy zmienia orientację, tak można określić różnych drawables do orientacji pionowej i poziomej.
|
||||
|
||||
### Quirks przeglądarki
|
||||
|
||||
W pliku `config.xml`można użyć następujące preferencje:
|
||||
|
||||
<platform name="browser">
|
||||
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
|
||||
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
|
||||
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
|
||||
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
|
||||
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
|
||||
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
|
||||
</platform>
|
||||
|
||||
|
||||
### Dziwactwa iOS
|
||||
|
||||
* `FadeSplashScreen` (wartość logiczna, domyślnie `true`): zestaw na `false` , aby zapobiec Znikająca i odkładane po zmianie stanu wyświetlania ekranu powitalnego.
|
||||
|
||||
<preference name="FadeSplashScreen" value="false"/>
|
||||
|
||||
|
||||
* `FadeSplashScreenDuration` (float, domyślnie `2`): określa liczbę sekund dla ekranu powitalnego zanikanie efekt do wykonać.
|
||||
|
||||
<preference name="FadeSplashScreenDuration" value="4"/>
|
||||
|
||||
|
||||
* `ShowSplashScreenSpinner` (wartość logiczna, domyślnie `true`): zestaw na `false` , aby ukryć pokrętła ekran powitalny.
|
||||
|
||||
<preference name="ShowSplashScreenSpinner" value="false"/>
|
||||
|
||||
|
||||
## splashscreen.Hide
|
||||
|
||||
Odrzucić ten opryskaæ têcza.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### Jeżyna 10, WP8, iOS dziwactwo
|
||||
|
||||
Plik `config.xml` `AutoHideSplashScreen` ustawienie musi być `false`. Opóźnienia, ukrywanie ekranu powitalnego przez dwie sekundy, dodać timer następujących w `deviceready` obsługa zdarzeń:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
Wyświetla ekran powitalny.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
Aplikacja nie można wywołać `navigator.splashscreen.show()`, aż aplikacja została uruchomiona i zdarzenie `deviceready` został zwolniony. Ale ponieważ zazwyczaj opryskać tęcza ma być widoczne przed rozpoczęciem aplikacji, wydaje się sprzeczne z celem ekranu powitalnego. Dostarczanie niektórych konfiguracji w `pliku config.xml` będzie automatycznie `show` splash na ekranie natychmiast po uruchomienie aplikacji i przed pełni rozpoczął i odebrał zdarzenie `deviceready`. Aby uzyskać więcej informacji na robienie tej konfiguracji, zobacz [ikony i ekrany powitalne w aplikacjach](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html). Z tego powodu jest mało prawdopodobne, należy zadzwonić `navigator.splashscreen.show()`, aby wyświetlić ekran powitalny dla uruchamiania aplikacji.
|
||||
@@ -0,0 +1,78 @@
|
||||
<!---
|
||||
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-splashscreen
|
||||
|
||||
Ten plugin wyświetla i ukrywa ekran powitalny podczas uruchamiania aplikacji.
|
||||
|
||||
## Instalacja
|
||||
|
||||
cordova plugin add cordova-plugin-splashscreen
|
||||
|
||||
|
||||
## Obsługiwane platformy
|
||||
|
||||
* Amazon Fire OS
|
||||
* Android
|
||||
* BlackBerry 10
|
||||
* iOS
|
||||
* Windows Phone 7 i 8
|
||||
* Windows 8
|
||||
|
||||
## Metody
|
||||
|
||||
* splashscreen.show
|
||||
* splashscreen.Hide
|
||||
|
||||
### Dziwactwa Androida
|
||||
|
||||
W pliku config.xml musisz dodać następujące preferencje:
|
||||
|
||||
<preference name="SplashScreen" value="foo" />
|
||||
<preference name="SplashScreenDelay" value="10000" />
|
||||
|
||||
|
||||
Gdzie foo jest nazwą pliku ekranu powitalnego, najlepiej 9 łatce. Upewnij się dodać pliki splashcreen do katalogu res/xml w odpowiednich folderach. Drugi parametr reprezentuje, jak długo ekranu powitalnego pojawi się w milisekundach. Domyślnie 3000 ms. Aby uzyskać więcej informacji, zobacz [ikony i ekrany powitalne w aplikacjach][1].
|
||||
|
||||
[1]: http://cordova.apache.org/docs/en/edge/config_ref_images.md.html
|
||||
|
||||
## splashscreen.Hide
|
||||
|
||||
Odrzucić ten opryskaæ têcza.
|
||||
|
||||
navigator.splashscreen.hide();
|
||||
|
||||
|
||||
### Jeżyna 10, WP8, iOS dziwactwo
|
||||
|
||||
Plik `config.xml` `AutoHideSplashScreen` ustawienie musi być `false`. Opóźnienia, ukrywanie ekranu powitalnego przez dwie sekundy, dodać timer następujących w `deviceready` obsługa zdarzeń:
|
||||
|
||||
setTimeout(function() {
|
||||
navigator.splashscreen.hide();
|
||||
}, 2000);
|
||||
|
||||
|
||||
## splashscreen.show
|
||||
|
||||
Wyświetla ekran powitalny.
|
||||
|
||||
navigator.splashscreen.show();
|
||||
|
||||
|
||||
Aplikacja nie można wywołać `navigator.splashscreen.show()`, aż aplikacja została uruchomiona i zdarzenie `deviceready` został zwolniony. Ale ponieważ zazwyczaj opryskać tęcza ma być widoczne przed rozpoczęciem aplikacji, wydaje się sprzeczne z celem ekranu powitalnego. Dostarczanie niektórych konfiguracji w `pliku config.xml` będzie automatycznie `show` splash na ekranie natychmiast po uruchomienie aplikacji i przed pełni rozpoczął i odebrał zdarzenie `deviceready`. Aby uzyskać więcej informacji na robienie tej konfiguracji, zobacz [ikony i ekrany powitalne w aplikacjach][1]. Z tego powodu jest mało prawdopodobne, należy zadzwonić `navigator.splashscreen.show()`, aby wyświetlić ekran powitalny dla uruchamiania aplikacji.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user