Advanced Concepts
Adding custom native code to a project
NativeScript allows you to access any native APIs anytime in your app. If the native API you need is not exposed through @nativescript/core or third party plugins or @nativescript/* plugins), you can add it to your project and access it right away in TypeScript.
Add native code to App_Resources. For example, see Adding Java/Kotlin code to an application and Adding ObjectiveC/Swift Code to an application
Generate types for the added APIs For iOS types run:
ns typings ios
For Android run:
ns typings android --jar <.jar path>
Reference the generated types in references.d.ts
You can now code (strongly typed) against the platform native APIs. For various examples on how to interact with native API's in JavaScript/TypeScript, visit the Subclassing, iOS Marshalling and Android Marshalling pages
Additional Resources
- Android d.ts Generator, for advanced types generation for Android
- Previous
- webpack.config.js