Today I decided to do series of post for the next 100 days focusing on NativeScript.
These posts would be ranging from tips, experiences from plugins or sample applications developed using NativeScript.
Hope you find the series useful!! Feel free to comment if you would like me to cover any areas related to NativeScript. I will try to address the same in my series.
NativeScript Play Ground is my favorite tool to explore and play with NativeScript. We can use play ground with out any installation to do quick development and explore the features of NativeScript.
By clicking the QR code we can pair NativeScript PlayGround with our device. For this we need to install NativeScript Playground app and Preview app. They can be downloaded from Play Store for Android and App Store for Apple.
Once the device is paired the changes will be pushed to the device and Preview app displays the changes. Cool right. So far everything is good.
At this point we can download the app from PlayGround using the Download option. This will download the contents as a zip file with name as “NSPlayGround”.
We can extract the contents from archive and open the app using Visual Studio Code.
Visual Studio Code opens and loads the app. Notice the home-page.js file. It refers the home-view-model.
Now let us go back to play ground and add a nativescript plugin to our app. Let us add nativescript-camera npm package.
Once the package is added a folder nativescript-camera will be created. We can refer this plugin in home-page.js file. While on Play Ground we can refer the camera plugin as shown in below pictures. Both options will work and no errors will be displayed when the changes are pushed to device.
Now go ahead and download the playground app from website. This will create a new zip file with same as previous one. Extract the contents and open the app using Visual Studio following previous steps. In the below picture nativescript-camera plugin is referred with “../”
Now we shall build the project and deploy our app in local android emulator using tns build and tns run commands.
The app gets built successfully. Now let us execute tns run android command. This will deploy the app to emulator. I have a local android emulator which is using Android API 19 Version Image.
The app gets deployed and app loads irrespective of
var cameraModule = require("../nativescript-camera");
var cameraModule = require("nativescript-camera");
tns plugin add nativescript-geolocation
var locationModule = require("../nativescript-geolocation");
var locationModule = require("nativescript-geolocation");
All packages from node_modules folder can be referred by providing the name of the plugin.