Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8F64118969 for ; Fri, 26 Feb 2016 01:00:04 +0000 (UTC) Received: (qmail 57142 invoked by uid 500); 26 Feb 2016 01:00:03 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 57042 invoked by uid 500); 26 Feb 2016 01:00:03 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 56591 invoked by uid 99); 26 Feb 2016 01:00:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Feb 2016 01:00:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1CED6E8F37; Fri, 26 Feb 2016 01:00:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: dblotsky@apache.org To: commits@cordova.apache.org Date: Fri, 26 Feb 2016 01:00:17 -0000 Message-Id: <6cb446ace18547458f73a7e625040162@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [16/51] [partial] docs commit: Renaming 6.0.0 to 6.x. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/win8/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/win8/index.md b/www/docs/en/6.x/guide/platforms/win8/index.md new file mode 100644 index 0000000..214869f --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/win8/index.md @@ -0,0 +1,292 @@ +--- +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. + +title: Windows Platform Guide +--- + +# Windows Platform Guide + +This guide shows how to set up your SDK development environment to build +and deploy Cordova apps for Windows 8, Windows 8.1, Windows Phone 8.1, and +Windows 10 Universal App Platform. It shows how to use either shell tools +to generate and build apps, or the cross-platform Cordova CLI discussed in +[The Command-Line Interface](../../cli/index.html). (See the [Overview](../../overview/index.html) for a comparison of these +development options.) This section also shows how to modify Cordova apps +within Visual Studio. Regardless of which approach you take, you need to +install the Visual Studio SDK, as described below. + +See [Upgrading Windows 8](upgrade.html) for information on how to upgrade existing +Windows 8 Cordova projects. + +Window Phone 8 (wp8) stays as a separate platform, +see [Windows Phone 8 Platform Guide](../wp8/index.html) for details. + +Cordova WebViews running on Windows rely on Internet Explorer 10 (Windows 8.0) +and Internet Explorer 11 (Windows 8.1 and Windows Phone 8.1) as +their rendering engine, so as a practical matter you can use IE's +powerful debugger to test any web content that doesn't invoke Cordova +APIs. The Windows Phone Developer Blog provides +[helpful guidance](http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/11/15/adapting-your-webkit-optimized-site-for-internet-explorer-10.aspx) +on how to support IE along with comparable WebKit browsers. + +## Requirements and Support + +To develop apps for Windows platform you need: + +- A Windows 8.1, 32 or 64-bit machine (_Home_, _Pro_, or _Enterprise_ editions) with minimum 4 GB of RAM. + +- Windows 8.0, 8.1 or 10, 32 or 64-bit _Home_, _Pro_, or _Enterprise_ + editions, along with + [Visual Studio 2012 Express](http://www.visualstudio.com/downloads) + or Visual Studio 2013. Visual Studio 2015 is not able to build Windows 8.0 apps. + +To develop apps for Windows 8.0 and 8.1 (including Windows Phone 8.1): + +- Windows 8.1 or Windows 10, 32 or 64-bit _Home_, _Pro_, or _Enterprise_ editions, + along with + [Visual Studio 2013 Express](http://www.visualstudio.com/downloads) + or higher. An evaluation version of Windows 8.1 Enterprise is + available from the + [Microsoft Developer Network](http://msdn.microsoft.com/en-US/evalcenter/jj554510). + +- For the Windows Phone emulators, Windows 8.1 (x64) Professional edition or higher, +and a processor that supports Client Hyper-V and Second Level Address Translation (SLAT). +An evaluation version of Windows 8.1 Enterprise is available from the +[Microsoft Developer Network](http://msdn.microsoft.com/en-US/evalcenter/jj554510). + +- [Visual Studio 2013 for Windows](http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-8) (Express or higher). + +To develop apps for Windows 10: + +- Windows 8.1 or Windows 10 Technical Preview 2, 32- or 64-bit, along with + [Visual Studio 2015 RC](http://www.visualstudio.com/preview) or higher. + +App compatibility is determined by the OS that the app targeted. Apps are forwardly-compatible +but not backwardly-compatible, so an app targeting Windows 8.1 cannot run on 8.0, but +an app built for 8.0 can run on 8.1. + +Follow the instructions at +[windowsstore.com](http://www.windowsstore.com/) +to submit the app to Windows Store. + +To develop Cordova apps for Windows, you may use a PC running +Windows, but you may also develop on a Mac, either by running a +virtual machine environment or by using Boot Camp to dual-boot a +Windows 8.1 partition. Consult these resources to set up the required +Windows development environment on a Mac: + +- [VMWare Fusion](http://msdn.microsoft.com/en-US/library/windows/apps/jj945426) + +- [Parallels Desktop](http://msdn.microsoft.com/en-US/library/windows/apps/jj945424) + +- [Boot Camp](http://msdn.microsoft.com/en-US/library/windows/apps/jj945423) + +## Using Cordova Shell Tools + +If you want to use Cordova's Windows-centered shell tools in +conjunction with the SDK, you have two basic options: + +- Access them locally from project code generated by the CLI. They are + available in the `platforms/windows/` directory after you add + the `windows` platform as described below. + +- Download them from a separate distribution at + [cordova.apache.org](https://www.apache.org/dist/cordova/platforms/). + The Cordova distribution contains separate archives for each platform. + Be sure to expand the appropriate archive, `cordova-windows` in + this case, within an empty directory. The relevant batch utilities + are available in `package/bin` directory. (Consult the + __README__ file if necessary for more detailed directions.) + +These shell tools allow you to create, build, and run Windows apps. +For information on the additional command-line interface that enables +plugin features across all platforms, see Using Plugman to Manage +Plugins. + +## Install the SDK + +Install any edition of +[Visual Studio](http://www.visualstudio.com/downloads) matching the version +requirements listed above. + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_installSDK.png) + +For Windows 10, the Visual Studio installer has an option to install tools to +build Universal Windows Apps. You must ensure that this option is selected +when installing to install the required SDK. + +## Create a New Project + +At this point, to create a new project you can choose between the +cross-platform CLI tool described in [The Command-Line Interface](../../cli/index.html), or +the set of Windows-specific shell tools. +The CLI approach below generates an app named _HelloWorld_ +within a new `hello` project directory: + + > cordova create hello com.example.hello HelloWorld + > cd hello + > cordova platform add windows + +Here's the corresponding lower-level shell-tool approach: + + C:\path\to\cordova-windows\package\bin\create.bat C:\path\to\new\hello com.example.hello HelloWorld + +This project targets Windows 8.1 as the default target OS. You can choose to target 8.0 or 10.0 (see "Configure target Windows version" below) for all builds, or you target specific a particular version during each build. + +## Build the Project + +If you are using the CLI in development, the project directory's +top-level `www` directory contains the source files. Run either of +these within the project directory to rebuild the app: + + > cordova build + > cordova build windows # do not rebuild other platforms + > cordova build windows --debug # generates debugging information + > cordova build windows --release # signs the apps for release + +Here's the corresponding lower-level shell-tool approach: + + C:\path\to\project\cordova\build.bat --debug + C:\path\to\project\cordova\build.bat --release + +The `clean` command helps flush out directories in preparation for the +next `build`: + + C:\path\to\project\cordova\clean.bat + +## Configure target Windows version + +By default `build` command produces two packages: Windows 8.0 and Windows Phone 8.1. +To upgrade Windows package to version 8.1 the following configuration setting must be +added to configuration file (`config.xml`). + + + +Once you add this setting `build` command will start producing Windows 8.1 +and Windows Phone 8.1 packages. + +### The --appx parameter + +You may decide that you want to build a particular version of your application targeting a particular OS (for example, you might have set that you want to target Windows 10, but you want to build for Windows Phone 8.1). To do this, you can use the `--appx` parameter: + + > cordova build windows -- --appx=8.1-phone + +The build system will ignore the preference set in config.xml for the target Windows version and strictly build a package for Windows Phone 8.1. + +Valid values for the `--appx` flag are `8.1-win`, `8.1-phone`, and `uap` (for Windows 10 Universal Apps). These options also apply to the `cordova run` command. + +### Considerations for target Windows version + +Windows 10 supports a new "Remote" mode for Cordova apps (and HTML apps in general). This mode enables +apps much more freedom with respect to use of DOM manipulation and common web patterns such as the use +of inline script, but does so by reducing the set of capabilities your app may use when +submitted to the public Windows Store. For more information about Windows 10 and Remote Mode, look at +the [Cordova for Windows 10](win10-support.md.html) documentation. + +When using Remote Mode, developers are encouraged to apply a Content Security Policy (CSP) to their application +to prevent script injection attacks. + +## Deploy the app + +To deploy Windows package: + + > cordova run windows -- --win # explicitly specify Windows as deployment target + > cordova run windows # `run` uses Windows package by default + +To deploy Windows Phone package: + + > cordova run windows -- --phone # deploy app to Windows Phone 8.1 emulator + > cordova run windows --device -- --phone # deploy app to connected device + +You can use __cordova run windows --list__ to see all available targets and +__cordova run windows --target=target_name -- --phone__ to run application on a +specific device or emulator +(for example, `cordova run windows --target="Emulator 8.1 720P 4.7 inch" -- --phone`). + +You can also use __cordova run --help__ to see additional build and run +options. + +## Open the Project in the SDK and Deploy the App + +Once you build a Cordova app as described above, you can open it with +Visual Studio. The various `build` commands generate a Visual Studio +Solution (_.sln_) file. Open the file in the File Explorer to modify +the project within Visual Studio: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_openSLN.png) + +The `CordovaApp` component displays within the solution, and its `www` +directory contains the web-based source code, including the +`index.html` home page: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk.png) + +The controls below Visual Studio's main menu allow you to test or +deploy the app: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_deploy.png) + +With __Local Machine__ selected, press the green arrow to install the +app on the same machine running Visual Studio. Once you do so, the app +appears in Windows 8's app listings: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_runApp.png) + +Each time you rebuild the app, the version available in the interface +is refreshed. + +Once available in the app listings, holding down the __CTRL__ key +while selecting the app allows you to pin it to the main screen: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_runHome.png) + +Note that if you open the app within a virtual machine environment, +you may need to click in the corners or along the sides of the windows +to switch apps or access additional functionality: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_run.png) + +Alternately, choose the __Simulator__ deployment option to view the +app as if it were running on a tablet device: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/win8_sdk_sim.png) + +Unlike desktop deployment, this option allows you to simulate the +tablet's orientation, location, and vary its network settings. + +__NOTE__: Consult the [Overview](../../overview/index.html) for advice on how to use Cordova's +command-line tools or the SDK in your workflow. The Cordova CLI relies +on cross-platform source code that routinely overwrites the +platform-specific files used by the SDK. If you want to use the SDK to +modify the project, use the lower-level shell tools as an alternative +to the CLI. + +## Supporting Toasts + +Windows requires an app manifest capability declaration in order to support +toast notifications. When using the `cordova-plugin-local-notifications` +plugin, or any other plugin that is attempting to use toast notifications, +add the following preference to your config.xml to enable it to publish +toast notifications: + + + +This preference sets the corresponding flag in your app manifest. Plugins +should do the work necessary to configure the appearance of the +displayed notifications. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/win8/packaging.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/win8/packaging.md b/www/docs/en/6.x/guide/platforms/win8/packaging.md new file mode 100644 index 0000000..76683c5 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/win8/packaging.md @@ -0,0 +1,120 @@ +--- +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. + +title: Windows Packaging +--- + +# Windows Packaging + +You can learn more about signing and packaging of Windows Store Apps on [MSDN][1]. + +To be able to correctly package and sign Windows apps there are few things required: + +- A signing certificate +- Identity details matching the provided signing certificate + +In Windows project, identity details are kept in a file named package.appxmanifest. This file is automatically populated every time a Cordova app is built. Identity holds 3 important fields. + +- Name +- Publisher +- Version + +*Name* and *Version* can be set from **config.xml**. *Publisher* can be provided as a build parameter or can be set on **build.json** file. + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/packaging.png) + +A signing certificate can be provided from either CLI or through build.json file. The certificate related CLI flags are: + +- `--packageCertificateKeyFile` : Once a package signing certificate is created, this parameter can be used to associate the certificate with the app. This flag takes a file path as an argument. Eg. `> cordova build -- --packageCertificateKeyFile="platforms\windows\CordovaApp_TemporaryKey.pfx"` +- `--packageThumbprint` : Package thumbprint is used to validate the authenticity of package certificate key file. When creating a certificate key file, this value will be provided to the end user. Eg. `> cordova build -- --packageCertificateKeyFile="platforms\windows\CordovaApp_TemporaryKey.pfx" --packageThumbprint="ABCABCABCABC123123123123"` + +Alternatively, these values could be specified using a build configuration file (build.json) using CLI (--buildConfig). A sample build configuration file: + + { + "windows": { + "debug": { + "packageCertificateKeyFile": "platforms\\windows\\CordovaApp_TemporaryKey.pfx" + }, + "release": { + "packageCertificateKeyFile": "c:\\path-to-key\\keycert.pfx", + "packageThumbprint": "ABCABCABCABC123123123123", + "publisherId": "CN=FakeCorp.com, L=Redmond, S=Washington, C=US" + } + } + } + +There is also support to mix and match command line arguments and parameters in build.json file. Values from the command line arguments will get precedence. + +# How to create a certificate key and sign Cordova windows Apps +Signing is required for distributing and installing Windows Store apps. This process is normally handled by Visual Studio when you deploy a package for release. To do tmhis without Visual Studio we need to create our own certificates. + +For creating certificates we need to use [makecert.exe][2] util. This tool ships with Windows SDK and can be found under `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x64` or `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x86`. + +The first thing we need to do is to create a root key for signing our app. + +`makecert.exe -n "CN=FakeCorp.com" -r -eku "1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.10.3.13" -e "01/01/2020" –h 0 -sv FakeCorp.com.pvk FakeCorp.com.cer` + +To understand what makecert does, here's a brief explanation of what parameters do: + +- -n "CN=FakeCorp.com" : This is the certificate subject [X.509](http://en.wikipedia.org/wiki/X.509) name. In this example it's **C**ommon**N**ame=FakeCorp.com. +- -r : Creates a [self signed certificate](http://en.wikipedia.org/wiki/Self-signed_certificate). +- -eku #EKU_VAL# : Comma separated enhanced key usage OIDs. + - 1.3.6.1.5.5.7.3.3 indicates that the certificate is valid for code signing. Always specify this value to limit the intended use for the certificate. + - 1.3.6.1.4.1.311.10.3.13 indicates that the certificate respects lifetime signing. Typically, if a signature is time stamped, as long as the certificate was valid at the point when it was time stamped, the signature remains valid even if the certificate expires. This EKU forces the signature to expire regardless of whether the signature is time stamped. +- -e "01/01/2020" : Sets the expiration date of the certificate. +- -h 0 : Sets max height of the tree below this cert to 0 to prevent the certificate from being used as a Certification Authority (CA) that can issue other certificates. +- -sv FakeCorp.com.pvk : Output PVK file. Windows uses PVK files to store private keys for code signing. +- FakeCorp.com.cer : Output certificate file. CER file is used to store X.509 certificate. + +After running makecert for the first time, enter the private password on the screen that pops up: + +![]({{ site.baseurl }}/static/img/guide/platforms/win8/createprivatekeywindow.png) + +Once pvk and cer file is created, we need to create a pfx file from these certificates. A pfx (Personal Exchange Format) file contains a variety of cryptographic information, such as certificates, root authority certificates, certificate chains and private keys. To package the certs, we will use the a tool called [pvk2pfx][3]. This tool ships with Windows SDK and can be found under `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x64` or `%ProgramFiles(x86)%\Windows Kits\8.1\bin\x86`. + +`pvk2pfx -pvk FakeCorp.com.pvk -pi pvkPassword -spc FakeCorp.com.cer -pfx FakeCorp.com.pfx -po pfxPassword` + +Where: + +- pvk : Input pvk file name +- pi : pvk password +- spc : Input cert file name +- pfx : Output pfx file name +- po : pfx password; same as pvk password if not provided + +If we provide this pfx file to build.json file, we will have the following error: "The key file may be password protected. To correct this, try to import the certificate manually into the current user's personal certificate store.". In order to import it we have to use [certutil][4] from an admin prompt: + +`certutil -user -p PASSWORD -importPFX FakeCorp.com.pfx` + +Where: + +- user : Specifies "current user" personal store +- p : Password for pfx file +- importPfx : Name of pfx file + +Once installed, next step is to add packageThumbprint and packageCertificateKeyFile to build.json. In order to find the packageThumbprint, search for the CommonName we've associated with the certificate: + +`powershell -Command " & {dir -path cert:\LocalMachine\My | where { $_.Subject -like \"*FakeCorp.com*\" }}"` + +Once these final values are provided. Cordova should successfully package and sign the app. + +[1]: https://msdn.microsoft.com/en-us/library/hh446593(v=vs.85).aspx +[2]: https://msdn.microsoft.com/en-us/library/ff548309(v=vs.85).aspx +[3]: https://msdn.microsoft.com/en-us/library/ff550672(v=vs.85).aspx +[4]: https://technet.microsoft.com/en-us/library/ee624045(v=ws.10).aspx http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/win8/plugin.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/win8/plugin.md b/www/docs/en/6.x/guide/platforms/win8/plugin.md new file mode 100644 index 0000000..6a49de6 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/win8/plugin.md @@ -0,0 +1,221 @@ +--- +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. + +title: Windows Plugins +--- + +# Windows Plugins + +This section provides details for how to implement a plugin for use in +a Windows Store app. Before reading this, see Application Plugins for +an overview of the plugin's structure and its common JavaScript interface. +This section continues to demonstrate the sample _echo_ plugin that +communicates from the Cordova webview to the native platform and back. + +It is important to note that Windows supports developing directly in Javascript, which means developing the 'native' portions in only required in special cases. + +Creating a Windows Plugin in JavaScript +--- + +These instructions are to create a pure JavaScript plugin. Understanding this is crucial to understanding how to add the native/managed bits. + +Windows Cordova plugins are essentially a thin wrapper around existing WinJS provided functions, but assuming you will want to define your JS common interface for multiple devices, you will typically have 1 JS file that provides the API. + + // inside file echoplugin.js + var EchoPlugin = { + // the echo function calls successCallback with the provided text in strInput + // if strInput is empty, it will call the errorCallback + echo:function(successCallback, errorCallback, strInput) { + cordova.exec(successCallback,errorCallback,"EchoPlugin","echo",[strInput]); + } + } + +Inside Cordova exec on Windows +--- + +The cordova.exec function is defined differently on every platform, this is because each platform has it's own way of communicating between the application js code, and the native wrapper code. But in the case of Windows, there is no native wrapper, so the exec call is there for consistency. You could do your js only plugin work directly in EchoPlugin.echo, something like : + + // inside file echoplugin.js ( this is what NOT to do if you want to reuse the JS API cross platform ) + var EchoPlugin = { + echo:function(successCallback,errorCallback,strInput) { + if(!strInput || !strInput.length) { + errorCallback("Error, something was wrong with the input string. =>" + strInput); + } + else { + successCallback(strInput + "echo"); + } + } + } + +This would/could work fine, however it means that you will need different versions of echoPlugin.js for different platforms, and possibly you could have issues with inconsistencies in your implementations. As a best practice, we decided to mimic a native API inside cordova.exec on Windows, so we could run the same JS code, and not have to rewrite it for the platform, and also take advantage of any parameter checking, or other common code provided by developers who were working on other platforms. + +The Cordova exec proxy +--- + +On Windows, cordova provides a proxy that you can use to register an object that will handle all cordova.exec calls to an API. + +For example if you wanted to provide the implementation for the Accelerometer API, you would do this : + +cordova.commandProxy.add("Accelerometer",{ + start:function(){ + // your code here ... + } + // , + // ... and the rest of the API here +}); + +So in our case, we will assume that the code in echoplugin.js is handling cross platform relevant JavaScript, and we can simply write a proxy for Windows + + // in file echopluginProxy.js + cordova.commandProxy.add("EchoPlugin",{ + echo:function(successCallback,errorCallback,strInput) { + if(!strInput || !strInput.length) { + errorCallback("Error, something was wrong with the input string. =>" + strInput); + } + else { + successCallback(strInput + "echo"); + } + } + }); + +The plugin definition + +If we want users of our plugin to be able to easily install our plugin, we will need to define it according to how PlugMan defines plugins. More on this in the [Plugin Spec](plugin_ref_spec.md.html#Plugin%20Specification) + + + + + + + + + + + + + + + + + + + +This gives us a working Windows JavaScript plugin that uses a common file ( echoplugin.js ) and uses a proxy to provide the Windows only portion of implementation ( echopluginProxy.js ). So how do we add native/managed code to this? Well we are going to start the same, the only difference will be what we do inside in echopluginProxy methods. + +How WinJS accesses native/managed code +=== + + +In Windows, WinJS authored apps are able to interact with native code, this inter-op is available for Windows Runtime Components. The details are numerous, and this guide will only cover the basics. Microsoft provides much more info [here](http://msdn.microsoft.com/en-us/library/windows/apps/hh441569.aspx). + +When you create your Windows Runtime Component, any class that is defined as 'public ref class sealed' is considered an 'activatable class' and will be callable from JavaScript. + + // in your header file .h + namespace EchoRuntimeComponent + { + public ref class EchoPluginRT sealed + { + public: + static Platform::String^ Echo(Platform::String^ input); + } + } + + // in the implementation file .cpp + using namespace EchoRuntimeComponent; + using namespace Platform; + + Platform::String^ EchoPluginRT::Echo(Platform::String^ input) + { + if(input->IsEmpty()) + { + return "Error: input string is empty."; + } + else + { + return input->ToString() + "echo"; + } + } + +Now in order for us to call the native code, we use the namespace, classname, and lowerCamelCase the method we are calling. + +var res = EchoRuntimeComponent.EchoPluginRT.echo("boom"); +Moving this to our echopluginProxy.js file, we get this : + + // in file echopluginProxy.js + cordova.commandProxy.add("EchoPlugin",{ + echo:function(successCallback,errorCallback,strInput) { + var res = EchoRuntimeComponent.EchoPluginRT.echo(strInput); + if(res.indexOf("Error") == 0) { + errorCallback(res); + } + else { + successCallback(res); + } + } + }); + +And that's it, we have an end to end C++ backed js callable plugin for use in Apache Cordova Windows! + +Some technical notes: +=== + +- the callback is typically async, so calling the callback right away is probably not expected by the caller. In practice, if the call is not async, you should at least use a javascript timeout to force the callback to be called async. +- Activatable classes can do all kinds of awesome, like event dispatching, async callbacks, passing your own object types, arrays, collections, overloaded methods and much more. I recommend you do your homework. +- If you stick to common Windows Phone 8.0 and Windows SDK API calls, you will be able to use the same runtime component ( native or managed bits ) in a Windows Phone 8.0 Apache Cordova plugin. ~stay tuned for that post. + +Defining your plugin +=== + +Now that we have a working plugin, we need to revisit the plugin definition from earlier so we can publish it. We can now add the runtime component as a framework. +Note that the output type of a WindowsRuntimeComponent can be either .winmd or .dll + + + + + + + + + + + + + + + + + + + + +That's it, you now have a distributable plugin that you can share with the world! +One thing to note, support for adding frameworks to Windows Cordova project was only recently added so you will need to make sure your cordova tooling current. The cordova-cli and cordova-plugman both support adding removing native backed plugins. + +\> cordova plugin add com.risingj.echoplugin + +or + +\> plugman install --platform windows --plugin com.risingj.echoplugin --project . + +https://github.com/purplecabbage/cordova-runtimecomp-echoplug + http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/win8/upgrade.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/win8/upgrade.md b/www/docs/en/6.x/guide/platforms/win8/upgrade.md new file mode 100644 index 0000000..06dd39a --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/win8/upgrade.md @@ -0,0 +1,64 @@ +--- +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. + +title: Upgrading Windows 8 +--- + +# Upgrading Windows 8 + +This guide shows how to modify Windows 8 projects to upgrade from older versions of Cordova. +Most of these instructions apply to projects created with an older set +of command-line tools that precede the `cordova` CLI utility. See [The Command-Line Interface](../../cli/index.html) for information how to update the +version of the CLI. + +## Upgrade to 4.0.0 from 3.1.0 or later + +For projects that were created with the cordova CLI: + +1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). + +2. Run `cordova platform update windows8`. + +For projects not created with the cordova CLI, run: + + bin\update + +## Upgrade to 3.1.0 + +Cordova CLI support for Windows 8 was introduced in Cordova 3.1.0. To upgrade, we suggest creating a new Cordova CLI project and moving over all necessary assets. + +## Upgrade to 2.9.0 from 2.8.0 + +The following commands should be done from within Visual Studio to be sure that the any project references are updated/deleted. + +1. Remove `cordova-2.8.0.js` from the project's `www` directory. + +2. Add `cordova.js` file from the source to the project's `www` directory. (Note that the file no longer contains a version number in the filename.) + +3. Build and test! + +## Upgrade to 2.8.0 from 2.7.0 + +The following commands should be done from within Visual Studio to be sure that the any project references are updated/deleted. + +1. Remove `cordova-2.7.0.js` from the project's `www` directory. + +2. Add `cordova.js` file from the source to the project's `www` directory. (Note that the file no longer contains a version number in the filename.) + +3. Build and test! http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/win8/win10-support.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/win8/win10-support.md b/www/docs/en/6.x/guide/platforms/win8/win10-support.md new file mode 100644 index 0000000..ee04287 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/win8/win10-support.md @@ -0,0 +1,129 @@ +--- +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. + +title: Cordova for Windows 10 # +--- + +# Cordova for Windows 10 # +Maybe you could instead call it "Windows 10 for Cordova." Windows 10 has had its HTML and +JavaScript Apps platform re-engineered to bring Cordova support to the web, and to get +platform security restrictions out of your way. + +## Getting Started with Windows 10 ## +Adding Windows 10 support to your app is as easy as setting your Windows target platform +version to 10.0: + + + + +When you build with these preferences both set, only a single .appx (and .appxupload) will +be built. They will require Windows 10 at a minimum. + +### Understanding Remote Mode vs. Local Mode ### +Remote Mode is a new feature of the HTML Applications for Windows platform in Windows 10. In +Windows 8 and 8.1, HTML Applications worked in what is called "Local Mode" in Windows 10. In +Local Mode, HTML Applications have full access to the native Windows API surface and +capabilities. In order to prevent script injection attacks which could result in leaking +personally-identifiable information due to malicious code, Local Mode disallows inline script, +and requires developers who perform DOM manipulation to do so within an explicit context +(`MSApp.execUnsafeLocalFunction`). + +Remote Mode eliminates those requirements, which makes it possible to use unmodified libraries like jQuery or AngularJS directly in your code, without any changes. To do so, it removes your ability to declare certain capabilities when certifying your app in the Windows Store. The removal of these capabilities usually doesn't prevent getting to certain functionality, but it might require to use a different combination of APIs or tactics. + +### Effect of Remote Mode on capabilities ### +The following capabilities are unavailable when deploying your Remote Mode application to the Windows Store: + +- Enterprise Authentication (`enterpriseAuthentication`) +- Shared User Certificates (`sharedUserCertificates`) +- Documents Library (`documentsLibrary`) +- Music Library (`musicLibrary`) +- Pictures Library (`picturesLibrary`) +- Videos Library (`videosLibrary`) +- Removable [Storage](../../../cordova/storage/storage.html) (`removableStorage`) +- Internet client/server (`internetClientServer`) - note that `internetClient` is still permitted +- Private network client/server (`privateNetworkClientServer`) + +Each of the library restrictions may be worked around by requesting that the user interact with the file system via a [File Picker](https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileopenpicker.aspx). This prevents malicious injected code from arbitrarily accessing the file system. + +The network-related restrictions must be worked around by either using an API that doesn't use capability checks or by brokering communication via standard internet communication channels, such as `XMLHttpRequest` or Web Sockets. + +The Enterprise Authentication and Shared User Certificates capabilities are specifically targeted at Enterprise scenarios. These capabilities are supported for private/enterprise-enabled App Stores, so if you are building apps which are going to be deployed to an internal deployment mechanism, you can still support these. However, they are not supported for Remote Mode apps in the public Windows Store. When you build targeting Windows 10, if one of these capabilities is detected in your app manifest, a warning will be displayed. + +## Reference ## + +### config.xml Preferences ### + +#### windows-target-version, windows-phone-target-version #### + + + +*At least one is required.* + +These preferences identify the version of Windows or Windows Phone you would like your +app package to target. + +**Valid Values** + +- `10.0`, `UAP`: Builds for Windows 10 Universal App Platform +- `8.1`: Builds for Windows 8.1 or Windows Phone 8.1 +- `8.0`: Build for Windows 8.0. Not valid for Windows Phone (use the **wp8** Cordova +platform instead) + +**Scenarios** + +If you are targeting Windows 10 only, you only need to have a single `windows-target-version` +setting in your config.xml file. + +#### WindowsDefaultUriPrefix #### + + +This preference identifies whether you want your app to target the **local context** or **remote +context** as its startup URI. When building for Windows 10, the default is the remote +context (`ms-appx-web://`). + +In order to have a local-mode application that is not impacted by Remote Mode capability +restrictions, you must set this preference to `ms-appx://` and not declare any `` +elements with remote URIs. + +**Valid Values** + +- `ms-appx://` (Default for Windows 8.0, 8.1): The start page runs in the local context +- `ms-appx-web://` (Default for Windows 10): The start page runs in the remote context + +#### {SDK}-MinVersion, {SDK}-MaxVersionTested #### +*Optional* + + + + + + +These preferences identify which ecosystems (including but not limited to Windows Universal, Windows Mobile, or Xbox) and their min/max versions they are compatible with. They still require that the platforms have support for the Universal App Platform (so Windows 10 as the base OS). However, these may indicate that the application is aware of particular functionality that may only be available on certain devices (such as game streaming on Xbox). + +**Valid Values** + +There are three parts to each value: the **SDK**, the **version restriction**, and the **version value**. These preferences are detected by beginning with `Windows` or `Microsoft` and ending in `-MinVersion` or `-MaxVersionTested`: + +- The **SDK** defines what specialized platform you want to target. The default is `Windows.Universal`. Valid values for these are defined in the AppxManifest schema, in the `Package/Depednencies/TargetPlatform` elements. +- The **version restriction** defines application compatibility rules. For example, if the `-MinVersion` is set to 10.1.0.0, then OS versions which don't support at least 10.1.0.0 of the corresponding SDK won't be able to load it. + - `-MinVersion` specifies the minimum version of the SDK required + - `-MaxVersionTested` specifies the highest-tested version of the SDK. If a new version of the corresponding SDK is released, it will run in compatibility mode for the specified version. +- The **version value** is a 4-integer tuple in the form of *major.minor.build.qfe*. + +If no preferences of these types are specified in your config.xml file, then Windows.Universal version 10.0.0.0 will be chosen by default. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/wp8/index.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/wp8/index.md b/www/docs/en/6.x/guide/platforms/wp8/index.md new file mode 100644 index 0000000..04732c7 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/wp8/index.md @@ -0,0 +1,256 @@ +--- +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. + +title: Windows Phone 8 Platform Guide +--- + +# Windows Phone 8 Platform Guide + +This guide shows how to set up your SDK development environment to +deploy Cordova apps for Windows Phone devices. It focuses on Windows +Phone 8, but provides additional details on how to support Windows +Phone 7. + +It shows how to use either Windows Phone-specific shell tools to +generate and build apps, or the cross-platform Cordova CLI discussed +in [The Command-Line Interface](../../cli/index.html). (See the [Overview](../../overview/index.html) for a comparison of +these development workflows.) This section also shows how to open +Cordova apps so that you can modify them within Visual Studio. +Regardless of which approach you take, you need to install the Windows +Phone SDK, as described below. + +See the following for details specific to the Windows Phone platform: + +- [Windows Phone 8 Plugins](plugin.html) +- [Upgrading Windows Phone 8](upgrade.html) + +For the Windows Phone 8 platform, the Cordova WebView relies on +Internet Explorer 10 as its rendering engine, so as a practical matter +you can use IE10's powerful debugger to test any web content that +doesn't invoke Cordova APIs. The Windows Phone Developer Blog +provides +[helpful guidance](http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/11/15/adapting-your-webkit-optimized-site-for-internet-explorer-10.aspx) +on how to support IE10 along with comparable WebKit browsers. + +## Requirements and Support + +You need the following: + +- A 64-bit version of Windows 8 Pro, either an installation disk or an + _ISO_ disk image file. An evaluation version is available on the + [Microsoft Developer Network](http://msdn.microsoft.com/en-US/evalcenter/jj554510). + The Pro version is necessary to run the device emulator. + +- The [Windows Phone SDK](http://www.microsoft.com/en-us/download/details.aspx?id=35471). + +- In order to deploy via the command-line with the Windows Phone 8.0 SDK, +[Visual Studio 2012 Update 2](https://support.microsoft.com/en-us/kb/2797912) +must be installed. + +To develop Cordova apps for Windows Phone devices, you may use a PC +running Windows, but you may also develop on a Mac, either by running +a virtual machine environment or by using Boot Camp to dual-boot a +Windows partition. Consult these resources to set up the required +Windows development environment on a Mac: + +- __VMWare Fusion__: To set up the Windows 8 virtual machine, follow + the instructions provided by the + [Microsoft Developer Network](http://msdn.microsoft.com/en-US/library/windows/apps/jj945426), + then see [Configuring VMWare Fusion](vmware.html) for information on preparing the + virtual environment to run the emulator bundled with the SDK. + +- __Parallels Desktop__: To set up the Windows 8 virtual machine, + follow the instructions provided by the + [Microsoft Developer Network](http://msdn.microsoft.com/en-US/library/windows/apps/jj945424), + then see [Configuring Parallels Desktop](parallels.html) for information on preparing + the virtual environment to run the emulator bundled with the SDK. + + + +- __Boot Camp__: To set up the Windows 8 partition, follow the + installation instructions provided by the [Microsoft Developer + Network](http://msdn.microsoft.com/en-US/library/windows/apps/jj945423). + +If you are developing on a PC, its processor must support +virtualization (_VT-x_ on Intel) and [Second Level Address Translation +(SLAT)](http://en.wikipedia.org/wiki/Second_Level_Address_Translation). +Consult [Intel's list of supporting +processors](http://ark.intel.com/Products/VirtualizationTechnology). +Virtualization is typically disabled by default, so you need to enable +it in your BIOS settings. The PC should have at least 6.5GB of free +hard disk space, and 4GB of RAM. + +## Using Cordova Shell Tools + +If you want to use Cordova's Windows Phone-centered shell tools in +conjunction with the SDK, you have two basic options: + +- Access them locally from project code generated by the CLI. They are + available in the `platforms/wp8/cordova` directory after you add the + `wp8` platform as described below. + +- Download them from a separate distribution at + [cordova.apache.org](http://cordova.apache.org). The Cordova + distribution contains separate archives for each platform. Be sure + to expand the appropriate archive, `cordova-wp8\wp8` in this case, + within an empty directory. The relevant batch utilities are + available in the top-level `bin` directory. (Consult the __README__ + file if necessary for more detailed directions.) + +These shell tools allow you to create, build, and run Windows Phone +apps. For information on the additional command-line interface that +enables plugin features across all platforms, see Using Plugman to +Manage Plugins. See Application Plugins for guidance on how to develop +plugins, and [Windows Phone 8 Plugins](plugin.html) for details specific to the Windows +Phone platform. + +## Install the SDK + +Install the latest version of the Windows Phone SDK from the +__Downloads__ area of +[dev.windowsphone.com](https://dev.windowsphone.com/en-us/downloadsdk). +You may also install more recent emulator update packages. + +![]({{ site.baseurl }}/static/img/guide/platforms/wp8/wp8_downloadSDK.png) + +## Create a New Project + +At this point, to create a new project you can choose between the +cross-platform CLI tool described in [The Command-Line Interface](../../cli/index.html), or +the set of Windows Phone-specific shell tools. From within a +source-code directory, here's the CLI approach: + + > cordova create hello com.example.hello HelloWorld + > cd hello + > cordova platform add wp8 + +Here's the corresponding lower-level shell-tool approach: + + C:\path\to\cordova-wp8\bin\create.bat C:\path\to\new\hello com.example.hello HelloWorld + +## Build the Project + +If you are using the CLI in development, the project directory's +top-level `www` directory contains the source files. Run either of +these within the project directory to rebuild the app: + + > cordova build + > cordova build wp8 # do not rebuild other platforms + +If you are using the Windows Phone-specific shell tools in +development, there is a different approach. Once you generate the +project, the default app's source is available in the +`projects\wp8\www` subdirectory. Subsequent commands are available in +the `cordova` subdirectory at the same level. + +The `build` command cleans project files and rebuilds the app. The first +example generates debugging information, and the second signs the apps +for release: + + C:\path\to\project\cordova\build.bat --debug + C:\path\to\project\cordova\build.bat --release + +The `clean` command helps flush out directories in preparation for the +next `build`: + + C:\path\to\project\cordova\clean.bat + +## Deploy to Emulator + +At this point you can use the `cordova` CLI utility to deploy the +application to the emulator from the command line: + + > cordova emulate wp8 + +Otherwise use the alternate shell interface: + + C:\path\to\project\cordova\run + +By default, the `run` script invokes the emulator flag, and accepts +additional build flags, for which `--debug` provides the default: + + C:\path\to\project\cordova\run --emulator --debug + C:\path\to\project\cordova\run --emulator --release + C:\path\to\project\cordova\run --emulator --nobuild + +The emulator launches a device image with the app installed. From the +home screen, navigate to the apps panel to launch the __HelloWorld__ +app. This shows the app launching with its splash screen followed by +its main interface: + +![]({{ site.baseurl }}/static/img/guide/platforms/wp8/wp8_emulator.png) + +The emulator's basic controls on the top-right of the device screen +allow you to toggle between portrait and landscape orientation. The +__>>__ button opens more controls that allow you to test more complex +orientations and gestures: + +![]({{ site.baseurl }}/static/img/guide/platforms/wp8/wp8_emulator_orient.png) + +These advanced controls also allow you to modify the device's +location or to simulate sequences of movements: + +![]({{ site.baseurl }}/static/img/guide/platforms/wp8/wp8_emulator_loc.png) + +## Deploy to Device + +Before testing your application on a device, the device must be +registered. Consult [Microsoft's +documentation][1] +for details on how to deploy and test on Windows Phone 8. Also, make +sure the phone is connected to the computer, and the screen is +unlocked. + +Then run the following CLI command to run the app on the device: + + > cordova run wp8 + +It corresponds to this lower-level shell command: + + C:\path\to\project\cordova\run --device + +Alternately, if you are working in Visual Studio, select __Windows +Phone Device__ from the drop-down menu at the top, then press the +green __Play__ button nearby or else type __F5__. + +## Modify the Project in the SDK + +Once you build a Cordova app as described above, you can open it with +the SDK. The various `build` commands generates a Visual Studio +Solution (_.sln_) file. Open the file to modify the project within +Visual Studio. The web-based source code is available within the +project's `www` directory. Along with other tools the SDK provides, +the control below the menu allows you to launch the app in a Windows +Phone emulator: + +![]({{ site.baseurl }}/static/img/guide/platforms/wp8/wp8_vs.png) + +Consult the [Overview](../../overview/index.html) for advice on how to use Cordova's command-line +tools or the SDK in your workflow. The Cordova CLI relies on +cross-platform source code that routinely overwrites the +platform-specific files used by the SDK. If you want to work within +the SDK, use the lower-level shell tools as an alternative to the CLI. + +[1]: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402565.aspx http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/wp8/parallels.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/wp8/parallels.md b/www/docs/en/6.x/guide/platforms/wp8/parallels.md new file mode 100644 index 0000000..9a95018 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/wp8/parallels.md @@ -0,0 +1,49 @@ +--- +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. + +title: Configuring Parallels Desktop +--- + +# Configuring Parallels Desktop + +This section shows how to configure Parallels Desktop on a Mac so that +you can use Cordova to generate Windows Phone applications. + +The +[Microsoft Developer Network](http://msdn.microsoft.com/en-US/library/windows/apps/jj945424) +provides general instructions for how to run Windows under Parallels +Desktop. After installing Windows, follow these steps: + +1. Within Parallels Desktop, select the Windows 8 disk image you have + prepared, and choose __Settings__. + +1. Choose the __General → CPUs__ options. Specify _two_ CPUs. + Specify at least 2GB of memory, even if it falls outside the + recommended range: + + ![]({{ site.baseurl }}/static/img/guide/platforms/wp8/parallel_cpu_opts.png) + +1. To be able to run the device emulator image within the Windows 8 + virtual machine, choose the __Optimizations__ options and enable + __Nested Virtualization__. + + ![]({{ site.baseurl }}/static/img/guide/platforms/wp8/parallel_optimize_opts.png) + +Once you complete these steps, you are ready to install the Windows +Phone SDK. See the [Windows Phone 8 Platform Guide](index.html) for details. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/wp8/plugin.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/wp8/plugin.md b/www/docs/en/6.x/guide/platforms/wp8/plugin.md new file mode 100644 index 0000000..7153275 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/wp8/plugin.md @@ -0,0 +1,238 @@ +--- +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. + +title: Windows Phone 8 Plugins +--- + +# Windows Phone 8 Plugins + +This section provides details for how to implement native plugin code +on the Windows Phone platform. Before reading this, see [Plugin Development Guide](../../hybrid/plugins/index.html) +for an overview of the plugin's structure and its common +JavaScript interface. This section continues to demonstrate the sample +_echo_ plugin that communicates from the Cordova webview to the native +platform and back. + +Writing a plugin for Cordova on Windows Phone requires a basic +understanding of Cordova's architecture. Cordova-WP8 consists of a +`WebBrowser` that hosts the application's JavaScript code and manages +native API calls. You can extend a C# `BaseCommand` class +(`WPCordovaClassLib.Cordova.Commands.BaseCommand`), which comes with +most of the functionality you need: + +1. Select your project, and right-click to choose __Add → New + Item...__ If you wish, you can add it to the `Plugins` folder. + +2. Select __Class__ and name it `Echo.cs`. This class name must + _exactly_ match what you call specify as the service in the + `cordova.exec()` call on the JavaScript side. + +3. Include the base classes implementation: + + using WPCordovaClassLib.Cordova; + using WPCordovaClassLib.Cordova.Commands; + using WPCordovaClassLib.Cordova.JSON; + +4. Extend your class from `BaseCommand`: + + public class Echo : BaseCommand + { + // ... + } + +5. Add an `echo` method that is callable from JavaScript: + + public class Echo : BaseCommand + { + public void echo(string options) + { + // all JS callable plugin methods MUST have this signature! + // public, returning void, 1 argument that is a string + } + } + +See the +[BaseCommand.cs](https://github.com/apache/cordova-wp8/blob/master/wp8/template/cordovalib/Commands/BaseCommand.cs) +class for methods available for the plugin to override. For example, +the plugin can capture '[pause](../../../cordova/events/events.pause.html)' and '[resume](../../../cordova/events/events.resume.html)' events. + +## Namespaces + +The default namespace for unqualified commands is: + + namespace Cordova.Extension.Commands + { + // ... + } + +If you want to specify your own namespace, you need to make a fully +qualified call to `cordova.exec`. For example, if you want to define +your C# class like this: + + namespace com.mydomain.cordovaExtensions + { + public class Echo : BaseCommand + { + // ... + } + } + +The JavaScript would need to call `exec` like this: + + cordova.exec(win, fail, "com.mydomain.cordovaExtensions.Echo", ...); + +## Interpreting Arguments in C# + +In the example discussed in Application Plugins, the data your plugin +receives is a string, but what if you want to pass an array of +strings? Suppose the JavaScript `cordova.exec` call is specified like +this: + + cordova.exec(win, fail, "Echo", "echo", ["input string"]); + +The value of `options` string passed to the `Echo.echo` method is +JSON: + + "[\"input string\"]" + +All JavaScript `exec` arguments are JSON-encoded before being passed +into C#, and so need to be decoded: + + string optVal = JsonHelper.Deserialize(options)[0]; + // optVal now has the value of "input string" + +## Passing Results from C# to JavaScript + +The `BaseCommand` class provides methods to pass data to JavaScript +callback handlers. If you simply want to signal success with no +accompanying result, you can simply call: + + DispatchCommandResult(); + // calls back with an empty plugin result, considered a success callback + +To pass data back, you need to call `DispatchCommandResult` +differently: + + DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Everything went as planned, this is a result that is passed to the success handler.")); + +Use an encoded JSON string to pass structured object data back to +JavaScript: + + DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "{result:\"super awesome!\"}")); + +To signal an error, call `DispatchCommandResult` with a `PluginResult` +object whose status is `ERROR`: + + DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Echo signaled an error")); + +## Handling Serialization Errors + +When interpreting your arguments, `try`/`catch` blocks help screen out +bad input. This pattern appears throughout the Cordova C# code: + + string optVal = null; + + try + { + optVal = JsonHelper.Deserialize(options)[0]; + } + catch(Exception) + { + // simply catch the exception, we handle null values and exceptions together + } + + if (optVal == null) + { + DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); + } + else + { + // ... continue on to do our work + } + +## Plugin Lifetime + +Plugins with long-running requests, background activity such as media +playback, listeners, or that maintain internal state should implement +the `onReset` method to clean up those activities. The method runs +when the CordovaView WebBrowser navigates to a new page or refreshes, which +reloads the JavaScript. + + // defined in WPCordovaClassLib.Cordova.Commands.BaseCommand + public virtual void OnReset() { } + +## Plugin XML + +The following shows how to use the `plugin.xml` file to specify a +plugin's source files on the Windows Phone platform. See Application +Plugins for an overview, and [Plugin Specification](../../../plugin_ref/spec.html) for details on +available options. + +- The `` element defines all plugin resources, such + as _.cs_, _.xaml_, _.xaml.cs_, and _.dll_ files, and image assets. + +- The `` element defines elements to inject into a + configuration file. This example adds a plugin to the platform's + `config.xml` file: + + + + + + + + This example adds the contacts capability to the `WMAppManifest.xml` + file: + + + + + +## Debugging Plugins + +Use Visual Studio's debugger to debug a plugin's C# component. You can +set a break point at any of the methods exposed by your class. + +JavaScript is more difficult to debug on Windows Phone. You need to +use `console.log` to output the plugin's state, or to inform +yourself of errors. + +## Common Pitfalls + +- Be careful not to pass arguments from JavaScript to the native side + that are difficult to deserialize as JSON. Most device platforms + expect the argument passed to `cordova.exec()` to be an array, such + as the following: + + cordova.exec(win, fail, "ServiceName", "MethodName", ["this is a string", 54, {literal:'trouble'}]); + + This may result in an overly complex string value for C# to decode: + + "[\"this is a string\", 54, { literal:'trouble' }]" + + Instead, consider converting _all_ parameters to strings before + calling `exec()`, and decoding each separately: + + cordova.exec(win, fail, "ServiceName", "MethodName", ["this is a string", "54", "{literal:'trouble'}"]); + string[] optValues = JsonHelper.Deserialize(options); + +- It is usually better to check parameters in JavaScript before + calling `exec()`. Doing so allows you to re-use more code and pull + unnecessary functionality from the plugin's various native + implementations. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/wp8/upgrade.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/wp8/upgrade.md b/www/docs/en/6.x/guide/platforms/wp8/upgrade.md new file mode 100644 index 0000000..4f99126 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/wp8/upgrade.md @@ -0,0 +1,108 @@ +--- +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. + +title: Upgrading Windows Phone 8 +--- + +# Upgrading Windows Phone 8 + +This guide shows how to modify Windows Phone 8 projects, to upgrade from older versions of Cordova. Some of these +instructions apply to projects created with an older set of +command-line tools that precede the `cordova` CLI utility. See The +Command-Line Interface for information how to update the version of +the CLI. The following section shows how to upgrade from non-CLI and +CLI projects. + +## Upgrading 3.6.0 Projects to 4.0.0 + +For non-CLI projects, run: + + bin/update path/to/project + +For CLI projects: + +1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). + +2. Run `cordova platform update wp8` in your existing projects. + + +## Upgrade to 3.2.0 from 3.1.0 + +For projects that were created with the cordova CLI: + +1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). + +2. Run `cordova platform update wp8` + +For projects not created with the cordova CLI, run: + + bin\update + +## Upgrade to 3.1.0 from 3.0.0 + +For projects that were created with the cordova CLI: + +1. Update the `cordova` CLI version. See [The Command-Line Interface](../../cli/index.html). + +2. Run `cordova platform update wp8` + +For projects not created with the cordova CLI, run: + + bin\update + +## Upgrade to the CLI (3.0.0) from 2.9.0 + +1. Create a new Apache Cordova 3.0.0 project using the cordova CLI, as + described in [The Command-Line Interface](../../cli/index.html). + +2. Add your platforms to the cordova project, for example: `cordova + platform add wp8`. + +3. Copy the contents of the project's `www` directory to the `www` directory + at the root of the cordova project you just created. + +4. Copy or overwrite any native assets from your original project + (`SplashScreen`, `ApplicationIcon`, etc.), making sure to add any + new files to the `.csproj` file. The windows phone project builds + inside the `platforms\wp8` directory. + +5. Use the cordova CLI tool to install any plugins you need. Note that + the CLI handles all core APIs as plugins, so they may need to be + added. Only 3.0.0 plugins are compatible with the CLI. + +6. Build and test. + +## Upgrade to 3.0.0 (non-CLI) from 2.x + +In Visual Studio's Solution Explorer window: + +1. Create a new Apache Cordova WP8 3.0.0 Project. + +2. Copy the contents of the `www` directory to the new project, and be sure these items are added to the VS project. + +3. Copy and overwrite any splash screen, or icon images. + +4. Copy over any plugins from the `plugins` directory to the new project and ensure that they are also added to the VS project. + +5. Build and test. + +__NOTE__: all core APIs are removed from Cordova version 3.0, and must +be installed separately as plugins. For more information on how to +re-enable these features in a non-CLI workflow, see Using Plugman to +Manage Plugins. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/wp8/vmware.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/wp8/vmware.md b/www/docs/en/6.x/guide/platforms/wp8/vmware.md new file mode 100644 index 0000000..5c08fb8 --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/wp8/vmware.md @@ -0,0 +1,57 @@ +--- +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. + +title: Configuring VMWare Fusion +--- + +# Configuring VMWare Fusion + +This section shows how to configure VMWare Fusion on a Mac so that +you can use Cordova to generate Windows Phone applications. + +The [Microsoft Developer +Network](http://msdn.microsoft.com/en-US/library/windows/apps/jj945426) +provides general instructions for how to run Windows under VMWare +Fusion. After installing Windows, follow these steps: + +1. Within VMWare Fusion, select the Windows 8 disk image you have + prepared and choose __Settings__. + +1. Choose the __Processors & Memory__ configuration options. Make sure + to specify _two_ processor cores, and to __Enable hypervisor + applications in this Virtual machine__: + + ![]({{ site.baseurl }}/static/img/guide/platforms/wp8/vmware_memory_opts.png) + + The Windows Phone Emulator alone uses half a gigabyte of memory, so + overall you should reserve at least 2GB for VMWare. + +1. Choose the __Advanced__ settings. Enable the __Preferred + virtualization engine: Intel VT-x with EPT__ option: + + ![]({{ site.baseurl }}/static/img/guide/platforms/wp8/vmware_advanced_opts.png) + +1. Modify the _.vmx_ file to add or modify the following settings: + + hypervisor.cpuid.v0 = "FALSE" + mce.enable = "TRUE" + vhv.enable = "TRUE" + +Once you complete these steps, you are then ready to install the +Windows Phone SDK. See the [Windows Phone 8 Platform Guide](index.html) for details. http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/21c8e8f0/www/docs/en/6.x/guide/platforms/wp8/webview.md ---------------------------------------------------------------------- diff --git a/www/docs/en/6.x/guide/platforms/wp8/webview.md b/www/docs/en/6.x/guide/platforms/wp8/webview.md new file mode 100644 index 0000000..03855da --- /dev/null +++ b/www/docs/en/6.x/guide/platforms/wp8/webview.md @@ -0,0 +1,57 @@ +--- +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. + +title: Windows Phone 8.0 WebViews +--- + +# Windows Phone 8.0 WebViews + +This guide shows how to embed a Cordova-enabled WebView component +within a larger Windows Phone 8.0 application. + +To follow these instructions, make sure you have the latest Cordova +distribution. Download it from +[cordova.apache.org](http://cordova.apache.org) and unzip its +Windows Phone 8.0 package (cordova-wp8-*.zip). + +1. Navigate to the package's `wp8/framework` directory and build + `WPCordovaClassLib.sln`. + It creates the `Bin\Debug[Release]\WPCordovaClassLib.dll`. + +1. Copy the `WPCordovaClassLib.dll` file into the Windows Phone 8 project's + `/libs` directory and include `WPCordovaClassLib.dll` to your + project via `Project->References->Add Reference`. + Alternatively, you can directly reference the + `wp8/framework/WPCordovaClassLib.csproj` file. + +1. Add `CordovaView` component to your page (for example, `MainPage.xaml`). + + xmlns:my="clr-namespace:WPCordovaClassLib;assembly=WPCordovaClassLib"> + ... + + +1. Copy `common/www/cordova.js` along with the application's HTML + and JavaScript files to the Windows Phone 8 project's `html` directory + and include new files to the project. + +1. Copy the `wp8/template/config.xml`to the project's root directory and + +Instructions above will link core Cordova components only, +see [Using Plugman to Manage Plugins](../../../plugin_ref/plugman.html) in order to link Cordova plugins. \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org