Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
7 views

Getting Started with NativeScript Explore the possibility of building truly native cross platform mobile applications using your JavaScript skill NativeScript 1st Edition Anderson - The ebook in PDF format is ready for download

The document promotes various eBooks available for download at ebookname.com, focusing on topics such as NativeScript, React Native, and JavaScript. It highlights the benefits of using NativeScript for building cross-platform mobile applications with JavaScript skills. Additionally, it provides links to multiple eBooks and emphasizes the ease of accessing digital formats like PDF, ePub, and MOBI.

Uploaded by

becicinonev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
7 views

Getting Started with NativeScript Explore the possibility of building truly native cross platform mobile applications using your JavaScript skill NativeScript 1st Edition Anderson - The ebook in PDF format is ready for download

The document promotes various eBooks available for download at ebookname.com, focusing on topics such as NativeScript, React Native, and JavaScript. It highlights the benefits of using NativeScript for building cross-platform mobile applications with JavaScript skills. Additionally, it provides links to multiple eBooks and emphasizes the ease of accessing digital formats like PDF, ePub, and MOBI.

Uploaded by

becicinonev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Endless Ebook, One Click Away – Start Downloading at ebookname.

com

Getting Started with NativeScript Explore the


possibility of building truly native cross
platform mobile applications using your JavaScript
skill NativeScript 1st Edition Anderson
https://ebookname.com/product/getting-started-with-
nativescript-explore-the-possibility-of-building-truly-
native-cross-platform-mobile-applications-using-your-
javascript-skill-nativescript-1st-edition-anderson/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://ebookname.com


Click here to visit ebookname.com and download ebook now
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Learning React Native Building Native Mobile Apps with


JavaScript 1 (Early Release) Edition Bonnie Eisenman

https://ebookname.com/product/learning-react-native-building-
native-mobile-apps-with-javascript-1-early-release-edition-
bonnie-eisenman/

Enyo Up and Running Build Native Quality Cross Platform


JavaScript Apps 2nd Edition Roy Sutton

https://ebookname.com/product/enyo-up-and-running-build-native-
quality-cross-platform-javascript-apps-2nd-edition-roy-sutton/

JavaScript for Absolute Beginners Getting Started 1st


Edition Terry Mcnavage

https://ebookname.com/product/javascript-for-absolute-beginners-
getting-started-1st-edition-terry-mcnavage/

Brain Stimulation 1st Edition Andres M. Lozano And Mark


Hallett (Eds.)

https://ebookname.com/product/brain-stimulation-1st-edition-
andres-m-lozano-and-mark-hallett-eds/
Across This Land 2nd Edition John C. Hudson

https://ebookname.com/product/across-this-land-2nd-edition-john-
c-hudson/

Quantum Non Locality and Relativity Metaphysical


Intimations of Modern Physics 3rd Edition Tim Maudlin

https://ebookname.com/product/quantum-non-locality-and-
relativity-metaphysical-intimations-of-modern-physics-3rd-
edition-tim-maudlin/

Problems as Possibilities Problem Based Learning for K


16 Education 2nd Edition Linda Torp

https://ebookname.com/product/problems-as-possibilities-problem-
based-learning-for-k-16-education-2nd-edition-linda-torp/

The Pharmacology of Neurogenesis and Neuroenhancement


1st Edition Donard S. Dwyer (Eds.)

https://ebookname.com/product/the-pharmacology-of-neurogenesis-
and-neuroenhancement-1st-edition-donard-s-dwyer-eds/

A Guide to Sources of Texas Criminal Justice Statistics


R. Scott Harnsberger

https://ebookname.com/product/a-guide-to-sources-of-texas-
criminal-justice-statistics-r-scott-harnsberger/
Telling Lives in India Biography Autobiography and Life
History 1st Edition David Arnold

https://ebookname.com/product/telling-lives-in-india-biography-
autobiography-and-life-history-1st-edition-david-arnold/
[1]
Getting Started with
NativeScript

Explore the possibility of building truly native,


cross-platform mobile applications using your
JavaScript skill—NativeScript!

Nathanael J. Anderson

BIRMINGHAM - MUMBAI
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 Project Coordinator


Nathanael J. Anderson Shipra Chawhan

Reviewer Proofreader
TJ VanToll Safis Editing

Commissioning Editor Indexer


Veena Pagare Monica Ajmera Mehta

Acquisition Editor Production Coordinator


Prachi Bisht Conidon Miranda

Content Development Editor Cover Work


Mehvash Fatima Conidon Miranda

Technical Editor
Abhishek R. Kotian

Copy Editor
Lauren Harkins
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 are available on all three major mobile stores without compromising on the
native user experience. The problem, however, is that these three operating systems
are very different and companies need to implement three different applications
for these stores. Essentially, your company has to write and maintain multiple
implementations for the same problem. Teams write (and have to support) the
same apps multiple times. There is a good chance that bugs reported on one
platform also exist on the others but remain unnoticed. Apps that are meant to
behave identically on all platforms may exhibit subtle differences due to their
differing implementations. Also, shipping new features at the same time on all
platforms is difficult. This is neither optimal, nor very productive and requires a
significant investment to gain the knowledge of three different operating systems,
languages, IDEs, APIs, and marketplaces. There has got to be a better way. Enter
NativeScript—a framework using the native platform APIs, rendering and layout
capabilities to deliver ultimate user experience and will allow developers to reuse
their coding skills, eliminating the need to learn new languages and IDEs.

The NativeScript framework enables developers to use the pure JavaScript language
to build native mobile applications running on all major mobile platforms—Apple
iOS, Google Android, and Windows Universal. The application's UI stack is built
on the native platform rendering and layout engine using native UI components,
and because of that, no compromises with the User Experience of the applications
are made. It is also worth mentioning that a full native API access is provided
using JavaScript.
This book has everything you need to get started with NativeScript. It starts with
the fundamentals, such as the project structure, the command-line interface, how
to use basic UI element, how to use third-party native components, and finally,
how to target different platforms with NativeScript.

The author, Nathanael Anderson, is one of the faces of NativeScript. He has a deep
understanding of how the framework operates from inside out and is the best person
who can teach you how to use it.

"I'm confident that by reading this book, you will be able to quickly get into
NativeScript and start building your next cross-platform native mobile
application."

Valio Stoychev
Product Manager NativeScript at Telerik
About the Author

Nathanael J. Anderson has been developing software for over 20 years in a wide
range of industries, including areas of games, time management, imaging, service,
printing, accounting, land management, security, web, and even (believe it or not)
some successful government projects. He is currently a contract developer for master
technology and can create a solution for several types of applications (native, web,
mobile, and hybrid) running on any operating system.

As a senior developer engineer, he can work, tune, and secure everything from
your backend servers to the final destination of the data on your desktop or
mobile devices. By understanding the entire infrastructure, including the real and
virtualized hardware, he can completely eliminate different types of issues in all
parts of a framework.

Currently, he has multiple highly rated cross-platform plugins for NativeScript,


and he works heavily in the NativeScript community by providing things such as
bleeding edge build servers to build knightly code. He has also provided multiple
patches and features to the main NativeScript project.
About the Reviewer

TJ VanToll is a senior developer advocate for Telerik, a jQuery team member,


and the author of jQuery UI in Action. He has over a decade of web development
experience—specializing in performance and the mobile Web. He speaks about
his research and experiences at conferences around the world and has written for
publications such as Smashing Magazine, HTML5 Rocks, and MSDN Magazine. You
can follow him on Twitter at @tjvantoll and on GitHub at tjvantoll.
www.PacktPub.com

Support files, eBooks, discount offers,


and more
For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and
as a print book customer, you are entitled to a discount on the eBook copy. Get in touch
with us at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface vii
Chapter 1: Introduction to NativeScript 1
NativeScript 1
Telerik's NativeScript 2
Other competitors 2
NativeScript uniqueness 2
NativeScript is easy 3
NativeScript and TypeScript 4
What is TypeScript? 4
TypeScript's use in NativeScript 4
Choosing a development language 5
Common modules 5
Installing NativeScript 6
Prerequisites 6
node.js 6
iOS 6
Android 7
Installation 7
Installation help 8
The NativeScript command line 8
NativeScript commands 8
Creating your first application 10
Creating the application in easy steps 11
Running the app 12
Summary 13
Chapter 2: The Project Structure 15
Project directory overview 15
The root folder 17
The app folder 18
[i]
Table of Contents

The lib folder 18


The hooks folder 18
The node_modules folder 19
The tns-core-modules folder 19
The platforms folder 20
The platforms/android folder 20
The platforms/iOS folder 22
The app folder 24
The .gradle folder 24
The App_Resources folder 24
The fonts folder 25
The app folder files 25
The package.json file 25
License 25
App.js 26
App.css 27
Application page 27
The main-page.js file 27
The main-page.css file 28
The main-page.xml file 28
The main-view-model.js file 29
Foundational components 31
Application component 31
Frame component 32
Page component 32
Creating a second page 33
Creating additional files and pages 34
Creating settings.js 34
Navigating to another page 35
Running the application 36
Viewing our screen 36
Summary 37
Chapter 3: Declarative UI, Styling, and Events 39
Declarative UI 39
XML parser 40
Page, StackLayout, label, and more 41
<Page ...> node 41
<StackLayout ...> node 42
<Label ...> node 42
<Button ...> node 45
Second <Label...> node 46
Declarative UI and components 46
Visual components 47

[ ii ]
Table of Contents

Using the Declarative UI for our settings page 47


Our settings.xml file 47
Binding and event system 49
Event system 50
Binding 51
Styling the UI 52
What is CSS? 52
Why use CSS? 53
How to use CSS 53
Configuring your CSS Rules 54
Existing CSS properties 56
Exploring app.css 58
Trying CSS out and styling our application 60
Styling on your own 61
Summary 62
Chapter 4: Building a Featured Application 63
Layouts 63
StackLayout 64
WrapLayout 64
AbsoluteLayout 65
DockLayout 66
GridLayout 66
Building our featured application 68
Nonvisual components 69
Dialogs 72
Alert dialog 73
Confirm dialog 73
Prompt dialog 74
Login dialog 74
Action dialog 75
Promises 75
The settings screen Declarative UI 76
GridLayouts 76
Building the main screen 79
JavaScript code 79
Declarative UI 82
Main page Declarative UI 83
Main page body 83
ScrollViews 84
More about bindings 84
Repeaters 84
Main-body footer 85

[ iii ]
Table of Contents

The main-page.css file 87


Application CSS 89
Fonts 90
Icons 91
Communication with the server 91
Trying out our application 95
The server 95
Setting up your own server 96
Trying crossCommunicator out. 97
Summary 98
Chapter 5: Installing Third-Party Components 99
Places to find third-party components 99
The Telerik plugin site 100
npmjs.com 100
The NativeScript unofficial plugin list 100
How to install a third-party plugin component 100
Installing the vibration plugin 101
Installing the webSockets plugin 101
Installing the Telerik SideDrawer plugin 101
Using third-party components 102
Using the vibration plugin 102
Using Websockets 102
Using Telerik's side drawer 108
Easily using the components 110
Useful third-party components 110
Summary 110
Chapter 6: Platform Differences 111
Android and iOS differences 111
The soft keyboard 112
The Page.loaded event 112
Code differences 113
Platform classes 114
Declarative UI 115
Declarative UI properties 116
Declarative UI platform qualifiers 116
Platform- and device-specific files 117

[ iv ]
Table of Contents

Screen size differences 117


Fonts 118
Our own custom resource folders 118
Compiled application resources on iOS 119
Compiled application resources on Android 121
Device differences 123
Summary 124
Chapter 7: Testing and Deploying Your App 125
Testing your application 126
Test frameworks 126
Local testing of your code 128
Unit testing on the device 131
Installing the test framework 132
Writing tests 132
Running tests 133
Testing your app on a device or emulator 134
Understanding the call stack 136
Android call stack 136
iOS call stack 138
Debugging your application 139
Publishing your application 140
Publishing to iOS 141
Summary 141
Index 143

[v]
Other documents randomly have
different content
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like