Skip to content

cjpearson/cordova-plugin-nativescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-nativescript

A Cordova plugin to make calls to any native API using NativeScript. Currently only iOS is supported.

Installation

cordova plugin add https://github.com/cjpearson/cordova-plugin-nativescript

On iOS the metadata generation script has to run between compiling the app and deploying to the device. The after-compile hook does not work for this because it only runs if the CLI compile command was used. As a result, you have to make some changes to your iOS project.

  • Open the project in XCode.

  • Click the Project then select the main target

  • Select the Build Phases tab

  • Click the + icon and 'New Run Script Phase'

  • Select /bin/sh as the shell and copy the following code into the body

      pushd ../../plugins/cordova-plugin-nativescript/src/ios/Scripts/metadataGenerator/bin
      ./metadata-generation-build-step.sh
      popd
    

Methods

  • window.NativeScript.evaluate

window.NativeScript.evaluate

Evaluates a Javascript string asynchronously in the NativeScript runtime.

window.NativeScript.evaluate(code, onSuccess, onError)
  • code: The code to evaluate. (String)
  • onSuccess: Callback to invoke when the code evaluates successfully. (Function)
  • onError: Callback to invoke when there is an error evaluating the code. (Function)

Example

window.NativeScript.evaluate("var alert = new UIAlertView; \
				      alert.title = 'NativeScript Test'; \
				      alert.addButtonWithTitle('Ok'); \
				      alert.show();")

Supported Platforms

  • iOS

About

A Cordova plugin to interface with the nativescript runtime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages