Windows Phone 8 - Implementing Cordova plug-ins
Note:In Cordova-based applications, developers must check for the
devicereadyevent before they use the Cordova API set. In a MobileFirst application, however, this check is done internally. Instead of implementing this check, implementation code can be placed in the
The below code blocks are based on the sample application, provided at the bottom of this tutorial.
Plug-in creation overview:
- Declare the plug-in in the config.xml file
- Use the
- Create the plug-in class that will run natively in Windows Phone 8
Declaring a plug-inThe plug-in needs to be declared in the project, so that Cordova can detect it. To declare the plug-in, add a reference to the config.xml file, located in the native folder of the Windows Phone 8 environment.
cordova.exec()to call the Cordova plug-in:
sayHelloSuccess- Success callback
sayHelloFailure- Failure callback
SayHelloPlugin- Plug-in name as declared in config.xml
sayHello- Action name
[name]- Parameters array The plug-in calls the
- Create a new C# class
- Add the new class to your project namespace and add the required import statements.
Step 2Implement the
SayHelloPluginclass and the
Sample applicationClick to download the Studio project. ▲
Last modified on November 09, 2016