Getting Started with NativeScript
eBook - ePub

Getting Started with NativeScript

  1. 168 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Getting Started with NativeScript

About this book

Explore the possibility of building truly native, cross-platform mobile applications using your JavaScript skill—NativeScript!

About This Book

  • Save your marketing time by building for iOS, Android, and Windows Mobile platforms simultaneously
  • Be an ace at utilizing the features of NativeScript and its ability to communicate with each of the host device libraries natively
  • Proficiently, build your fully cross-platform communication application exhibiting the fundamentals of NativeScript

Who This Book Is For

If you are a JavaScript developer and want to build cross-platform applications, then this book is just the right one for you!

What You Will Learn

  • Install and compile your application in NativeScript
  • Get important know-how on the NativeScript project structure
  • Develop and style your screens for multiple platforms
  • Create a full-featured cross-platform communication application
  • Import and use several third-party components
  • Simplify and deal with device resolution and cross-platform issues
  • Test and deploy your application

In Detail

NativeScript allows you to build a fast cross-platform application that has a native UI. NativeScript is a true cross-platform framework that generates native speed applications using the native components of the host platform, all using JavaScript. Although NativeScript allows you to build your application in JavaScript, you have full access to the host OS from your code, allowing you to easily tweak or use new platform features instantly at native code speeds.

Whether you have already developed multiple applications or zero applications, this book will help you to develop your next application in a cross-platform framework quickly, saving you a massive amount of time and money.

This book concisely shows you NativeScript's built-in framework that allows you to rapidly develop a fully-working compiled cross-platform application in just a few chapters. It starts by laying the foundation of NativeScript and working through the fundamentals to create a basic shell of the application. Moving on, you'll see how to build a full-fledged application step by step. We'll show you how to use plugins, and how to communicate with the native OS libraries easily so that you can customize your application as if your app was created in Java or Objective C. We then deal with the issues that arise from being cross platform and compensate for the different screen sizes, screen resolutions, and device abilities. Finally, we progress to testing and deploying your app.

Style and approach

A stepwise guide for building cross-platform mobile applications with the help of easy-to-understand examples.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Getting Started with NativeScript


Table of Contents

Getting Started with NativeScript
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Introduction to NativeScript
NativeScript
Telerik's NativeScript
Other competitors
NativeScript uniqueness
NativeScript is easy
NativeScript and TypeScript
What is TypeScript?
TypeScript's use in NativeScript
Choosing a development language
Common modules
Installing NativeScript
Prerequisites
node.js
iOS
Android
Installation
Installation help
The NativeScript command line
NativeScript commands
Creating your first application
Creating the application in easy steps
Running the app
Summary
2. The Project Structure
Project directory overview
The root folder
The app folder
The lib folder
The hooks folder
The node_modules folder
The tns-core-modules folder
The platforms folder
The platforms/android folder
Bad resource files on Android
Compiled Android application location
The platforms/iOS folder
The app folder
The .gradle folder
The App_Resources folder
The fonts folder
The app folder files
The package.json file
License
App.js
App.css
Application page
The main-page.js file
The main-page.css file
The main-page.xml file
The main-view-model.js file
Our rewrite of the main-view-model.js file
Foundational components
Application component
Frame component
Page component
Creating a second page
Creating additional files and pages
Creating settings.js
Navigating to another page
Running the application
Viewing our screen
Summary
3. Declarative UI, Styling, and Events
Declarative UI
XML parser
Page, StackLayout, label, and more
<Page ...> node
<StackLayout ...> node
<Label ...> node
FormattedString component
Complex properties
<Button ...> node
Second <Label...> node
Declarative UI and components
Visual components
Using the Declarative UI for our settings page
Our settings.xml file
Binding and event system
Event system
Binding
Styling the UI
What is CSS?
Why use CSS?
How to use CSS
Configuring your CSS Rules
Existing CSS properties
Exploring app.css
Trying CSS out and styling our application
Styling on your own
Summary
4. Building a Featured Application
Layouts
StackLayout
WrapLayout
AbsoluteLayout
DockLayout
GridLayout
Building our featured application
Nonvisual components
Dialogs
Alert dialog
Confirm dialog
Prompt dialog
Login dialog
Action dialog
Promises
The settings screen Declarative UI
GridLayouts
Building the main screen
JavaScript code
Declarative UI
Main page Declarative UI
Main page body
ScrollViews
More about bindings
Repeaters
Main-body footer
The main-page.css file
Application CSS
Fonts
Icons
Communication with the server
Trying out our application
The server
Setting up your own server
Trying crossCommunicator out.
Summary
5. Installing Third-Party Components
Places to find third-party components
The Telerik plugin site
npmjs.com
The NativeScript unofficial plugin list
How to install a third-party plugin component
Installing the vibration plugin
Installing the webSockets plugin
Installing the Telerik SideDrawer plugin
Using third-party components
Using the vibration plugin
Using Websockets
Using Telerik's side drawer
Easily using the components
Useful third-party components
Summary
6. Platform Differences
Android and iOS differences
The soft keyboard
The Page.loaded event
Code differences
Platform classes
Declarative UI
Declarative UI properties
Declarative UI platform qualifiers
Platform- and device-specific files
Screen size differences
Fonts
Our own custom resource folders
Compiled application resources on iOS
Compiled application resources on Android
Device differences
Summary
7. Testing and Deploying Your App
Testing your application
Test frameworks
Local testing of your code
Unit testing on the device
Installing the test framework
Writing tests
Running tests
Testing your app on a device or emulator
Understanding the call stack
Android call stack
iOS call stack
Debugging your application
Publishing your application
Publishing to iOS
Summary
Index

Getting Started with NativeScript

Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: January 2016
Production reference: 1220116
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-865-6
www.packtpub.com

Credits

Author
Nathanael J. Anderson
Reviewer
TJ VanToll
Commissioning Editor
Veena Pagare
Acquisition Editor
Prachi Bisht
Content Development Editor
Mehvash Fatima
Technical Editor
Abhishek R. Kotian
Copy Editor
Lauren Harkins
Project Coordinator
Shipra Chawhan
Proofreader
Safis Editing
Indexer
Monica Ajmera Mehta
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda

Foreword

Are you tired of writing the same mobile app from scratch for iOS, Android and Windows? Yes? Then, you should be glad you found NativeScript!
Owing to the mobile platforms diversification, it is clear that to build a successful mobile application, you should make it available on all of the major mobile marketplaces, namely, Apple AppStore, Google PlayStore, and Microsoft Windows Store. This created a need for companies and developers to publish native apps that ...

Table of contents

  1. Getting Started with NativeScript

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Getting Started with NativeScript by Nathanael J. Anderson in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Engineering. We have over one million books available in our catalogue for you to explore.