SlideShare uma empresa Scribd logo
1 de 54
Nativescript
for Angular2
Chris Noring
Google Developer Expert
Front end Developer
at OVO Energy
About me
chris_noring
What’s out there for building
apps?
App store and market place = plan for monetizing
+ It also has
Built in features like
camera,
gps,
push notifications
+ Has access to
Native
swift, objective-c
java
- Usually needs
one dev team per platform $$$
Web apps
One team, only needs to know javascript + css
+ Cost less
- Limited access to hardware
- Browser support, increase maintenance and dev time
- Monetizing?
Will cost time and money to make it work well on all browsers also conti
- Doesn’t feel like native, its a compromise
+ Great for simple scenarios like a responsive version of t
geoposition
Hybrid frameworks
- You need to learn its api
rendering in web views, not truly native UI
+ It is possible to use an App Store
- Limited access to hardware
but the support is getting better and better
WebRTC*
WebGL
WebAudio
IndexedDB
Web Components*
Utilize Hardware Acceleratio
Remote Debugging*
- More and more cool features
are being supported
just a regular mobile optimized website, written in CSS, HTML and JavaScript, that is display
Ionic
Cordova
Phonegap
Titanium React Native
Progressive web apps
+ Caches
Is this the future?
- Monetizing?
+ Feels like an app
- Not great support on Safari yet
+ Progressive enhancement
better features with better browser and better broadband
+ Push notifications
So how does nativescript fit
in?
It’s NOT web although javascript, so no DOM
It targets actual apis
Its supports hardware due to being actual native
BUT you can use your javascript and css skills
AND you can use your native developers because
THEY KNOW THE API
It’s NOT either javascript or native folks, ITS BOTH
Nativescript
killer features
You can style native ui with css
You can use javascript OR angular 2 with typescript
free and open source framework for building native iOS and Android apps using JavaScript and C
You can access native apis with javascript
it’s free
It has hardware accelerated animations
You can monetise cause you can use App Store and markets
It’s pluggable, you can use and write your own plugins
How does it work?
Nativescript runtime uses
Javascript virtual machines
executed by V8.
is JIT compiled and
v8 JavaScriptCore
Android iOS
how does v8 know what android.text.format.Time() is?
var time = new android.text.format.Time();
this is javascript
NativeScript uses it to
inject APIs that let you access native code.
nativescript
inject android/ios object to
v8 or Javascript Core
There are APIs on v8 that lets you affect the global scope
How to know what to inject?
JavaScriptCore has a similar mechanism that makes the same te
How to interpret the js code?
1) NativeScript uses reflection to build the list of the APIs that are av
invokes a callback that native script can intercept, in that interceptio
2) android.text.format.Time()
javascript code
corresponding c++ callback
invokes JNI-bridge to
talk to native API
Android
invokes native API
directly
iOS
In conclusion
Nativescript investigates what to inject and injects metadat
A callback is connected to each executed javascript that na
C++ code on Android targets JNI ( c++ becomes java ) that
C++ on iOS talks to native API directly
And presto
Nativescript consists of
modules
Modules
camera.android.js
camera.ios.js
camera-common.js
selects the correct one at runtime
require(‘camera’)
camera
node_modules/ tns-core-modules
module
module
camera …
usage
everything is made up of modules
How easy is it to get started?
Preparing your environment
npm install nativescript -g
Windows
ecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https
Mac
ruby -e "$(curl -fsSL https://www.nativescript.org/setup/mac)"
tns doctor
verify your installation
Continued..
For android install genymotion
https://www.genymotion.com/
set path to android SDK
First app
scaffold
or
tns create my-app-name --ng
creates angular2 app
git clone https://github.com/NativeScript/sample-Groceries.git
angular 2 app for nativescript
Scaffolding saves a lot of time
What is the dev experience
like?
We got a plugin for vs code so we can set break points
We can use hot reload, so code is recompiled and rede
We can write and run unit tests
Hot reload
tns livesync platform —watch
1) compiles app
2) deploys to emulator/ device
repeats 1) + 2) on changes
Debug
tns debug platform
starts platform specific debugger
with option —debug-brk
—debug-brk
—start
—stop —emulator
set breakpoint
perform action
Build and start the application
Start Node Inspector
Launch Chrome browser
tns debug platform
Remote chromium debugger for Eclipse
https://www.nativescript.org/nativescript-for-visual-studio-code
Plugin for vs code
ext install nativescript
How hard is it to accomplish
something?
So we can be productive with all these components
we code in angular 2
we can easily extend with plugins
we can write our own plugins
we got,
ui components, we got layouts,http, css animations, gestures, hardware and more..
Controls with ng2
<Label class="lbl" [text]="title"></Label>
<Button (tap)="click()" text="Save new hero"></Button>
<TextField [(ngModel)]="status"></TextField>
<ListView [items]="todos" (itemTap)="tapped($event)" >
<template let-item="item" let-odd="odd" let-even="even">
</template>
</ListView>
one-way binding
event binding
two-way binding
So angular 2 with some new components
File system
Whats possible?
Create, Read, Update, Delete on files and folders
import * as fs from "file-system";
var documents = fs.knownFolders.documents();
var myFile = documents.getFile("Test_Write.txt");
myFile.writeText("Something")
.then(function () { }, err {});
myFile.readText()
.then(function (content) {
}, err {});
do something with
retrieved content
File demo
Layout
AbsoluteLayout
DockLayout
GridLayout
StackLayout
WrapLayout
Components ends up
exactly where you want them
x,y
Arranges children to outer edges,
last child takes up remaining space
columns and rows
Horizontally or vertically
follows orientation til space is filled
then wraps them into new column/row
Navigation
Navigation
Navigation is angular 2 router
if you know how that works
then you know how to build the app
CSS
CSS
Application-wide css, app.css
Component-specific css
@Component({
styleUrls : [‘pages/examples/list-
demo.component.css']
})
@Component({
style : ‘’
})
https://docs.nativescript.org/angular/ui/styling.html
Inline css
<Button text="inline style" style="background-color: green;"></Button>
<Button backgroundColor=“lightgray" >
Plugins
What is a native script plugin?
plugin
file.android.ts
file.ios.ts
package.json
lookup iOS and java implementation of the same thing
[NSDate date] new Date()).toString()
and add to respective file.platform.ts
write js-ified code corresponding to native api
NsDate.date() (new java.util.Date()).toString()
Is an npm package,
published or not, that exposes a native API
http://developer.telerik.com/featured/creating-nativescript-plugins-in-types
Great article to get started
http://plugins.telerik.com/nativescript
Telerik verified marketplace
https://docs.nativescript.org/plugins/plugins
More details
tns plugin add <Plugin>
tns plugin remove <Plugin>
Add/Remove
https://www.thepolyglotdeveloper.com/2016/07/create-native-ios-and-andr
Hardware
Camera
import * as cameraModule from 'camera';
cameraModule.takePicture({
width: 300,
height: 300,
keepAspectRatio: true
})
.then((picture) => {
console.log('picture taken');
this.source = picture;
})
<Image [src]="source"
stretch="none"
horizontalAlignment="center" >
</Image>
take picture
import a reference
Display image in control
Camera demo
A word about images
file system
<Image src="~/images/logo.png" stretch ="none" />
relative to the app folder
url
<Image src="https://www.google.com/images/errors/logo_sm_2.png" />
resource
<Image src="res://logo" stretch ="none" />
App_Resources
Android
iOS
Should be placed in resp platform
Geoposition
tns plugin add nativescript-geolocation
Install the plugin
Check if its enabled,
then ask for permission
import * as geolocation from "nativescript-geolocation";
if (!geolocation.isEnabled()) {
geolocation.enableLocationRequest();
}
So much for enabling, how to use?
geolocation.getCurrentLocation({
desiredAccuracy: 3,
updateDistance: 10,
maximumAge: 20000,
timeout: 20000})
.then(function(loc) {
if (loc) {
alert("Current location is: " + loc);
console.log("Current location is: " + loc);
}
}, function(e){
console.log("Error: " + e.message);
});
get location,
returns a promise
And just use a plugin to show the location
tns plugin add nativescript-google-sdk
Use an actual device to test this one
Once enabled, ask for location
Animation
ctrl.animate({
opacity: 0,
backgroundColor: new Color("Blue"),
translate: { x: 200, y: 0 },
scale: { x: 2, y: 2 },
rotate: 180,
duration: 800,
delay: 20,
iterations: 1,
curve: enums.AnimationCurve.easeIn
})
.then(() => {
console.log('animation done');
this.ypos += 20;
})
We can Rotate, scale, change opacity ..
What can we do?
translate
rotate
repeat animation
when done
Animation demo
Nativescript let’s you code an actual native
app using the API you know
using javascript
Just remember this..
Thank you for listening

Mais conteúdo relacionado

Mais procurados

From zero to hero with React Native!
From zero to hero with React Native!From zero to hero with React Native!
From zero to hero with React Native!Commit University
 
Putting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native BostonPutting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native Bostonstan229
 
Native Script by Sebastian Witalec
Native Script by Sebastian WitalecNative Script by Sebastian Witalec
Native Script by Sebastian WitalecSimone Basso
 
Intro To React Native
Intro To React NativeIntro To React Native
Intro To React NativeFITC
 
React Native in a nutshell
React Native in a nutshellReact Native in a nutshell
React Native in a nutshellBrainhub
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react nativeDani Akash
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Devin Abbott
 
A tour of React Native
A tour of React NativeA tour of React Native
A tour of React NativeTadeu Zagallo
 
Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016Adrian Philipp
 
Hands on react native
Hands on react nativeHands on react native
Hands on react nativeJay Nagar
 
React Native for ReactJS Devs
React Native for ReactJS DevsReact Native for ReactJS Devs
React Native for ReactJS DevsBarak Cohen
 
React Native for multi-platform mobile applications - Matteo Manchi - Codemo...
React Native for multi-platform mobile applications  - Matteo Manchi - Codemo...React Native for multi-platform mobile applications  - Matteo Manchi - Codemo...
React Native for multi-platform mobile applications - Matteo Manchi - Codemo...Codemotion
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react nativeModusJesus
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
React-Native for multi-platform mobile applications @ Codemotion Rome 2017
React-Native for multi-platform mobile applications @ Codemotion Rome 2017React-Native for multi-platform mobile applications @ Codemotion Rome 2017
React-Native for multi-platform mobile applications @ Codemotion Rome 2017Matteo Manchi
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeSambhu Lakshmanan
 
Lo mejor y peor de React Native @ValenciaJS
Lo mejor y peor de React Native @ValenciaJSLo mejor y peor de React Native @ValenciaJS
Lo mejor y peor de React Native @ValenciaJSMarcel Kalveram
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Nativedvcrn
 
Creating books app with react native
Creating books app with react nativeCreating books app with react native
Creating books app with react nativeAli Sa'o
 

Mais procurados (20)

From zero to hero with React Native!
From zero to hero with React Native!From zero to hero with React Native!
From zero to hero with React Native!
 
Putting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native BostonPutting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native Boston
 
Native Script by Sebastian Witalec
Native Script by Sebastian WitalecNative Script by Sebastian Witalec
Native Script by Sebastian Witalec
 
Intro To React Native
Intro To React NativeIntro To React Native
Intro To React Native
 
React Native in a nutshell
React Native in a nutshellReact Native in a nutshell
React Native in a nutshell
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react native
 
Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)Getting Started with React Native (and should I use it at all?)
Getting Started with React Native (and should I use it at all?)
 
A tour of React Native
A tour of React NativeA tour of React Native
A tour of React Native
 
Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016Experiences building apps with React Native @DomCode 2016
Experiences building apps with React Native @DomCode 2016
 
Hands on react native
Hands on react nativeHands on react native
Hands on react native
 
React Native for ReactJS Devs
React Native for ReactJS DevsReact Native for ReactJS Devs
React Native for ReactJS Devs
 
React Native for multi-platform mobile applications - Matteo Manchi - Codemo...
React Native for multi-platform mobile applications  - Matteo Manchi - Codemo...React Native for multi-platform mobile applications  - Matteo Manchi - Codemo...
React Native for multi-platform mobile applications - Matteo Manchi - Codemo...
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
React-Native for multi-platform mobile applications @ Codemotion Rome 2017
React-Native for multi-platform mobile applications @ Codemotion Rome 2017React-Native for multi-platform mobile applications @ Codemotion Rome 2017
React-Native for multi-platform mobile applications @ Codemotion Rome 2017
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Lo mejor y peor de React Native @ValenciaJS
Lo mejor y peor de React Native @ValenciaJSLo mejor y peor de React Native @ValenciaJS
Lo mejor y peor de React Native @ValenciaJS
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Creating books app with react native
Creating books app with react nativeCreating books app with react native
Creating books app with react native
 

Destaque

Introduction to NativeScript - BuildTruly Native Apps using JavaScript
Introduction to NativeScript - BuildTruly Native Apps using JavaScriptIntroduction to NativeScript - BuildTruly Native Apps using JavaScript
Introduction to NativeScript - BuildTruly Native Apps using JavaScriptLohith Goudagere Nagaraj
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2FITC
 
Why discovery of open books is a challenge
Why discovery of open books is a challengeWhy discovery of open books is a challenge
Why discovery of open books is a challengeEelco Ferwerda
 
The sorry state of Finnish e-payment APIs
The sorry state of Finnish e-payment APIsThe sorry state of Finnish e-payment APIs
The sorry state of Finnish e-payment APIsJuho Nurminen
 
Causal and semantic relatedness effects on L2 text processing and memory: Evi...
Causal and semantic relatedness effects on L2 text processing and memory: Evi...Causal and semantic relatedness effects on L2 text processing and memory: Evi...
Causal and semantic relatedness effects on L2 text processing and memory: Evi...Shingo Nahatame
 
Research Brief: Federal Reserve // March 2017
Research Brief: Federal Reserve // March 2017Research Brief: Federal Reserve // March 2017
Research Brief: Federal Reserve // March 2017Nicole Wesley-Smith
 
Comment automatiser l'exploitation de vos données webanalytics
Comment automatiser l'exploitation de vos données webanalyticsComment automatiser l'exploitation de vos données webanalytics
Comment automatiser l'exploitation de vos données webanalyticsuptilab
 
Why It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead Today
Why It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead TodayWhy It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead Today
Why It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead TodayVivastream
 
Identifying your Target Audience: How to Define and Maximize It
Identifying your Target Audience: How to Define and Maximize ItIdentifying your Target Audience: How to Define and Maximize It
Identifying your Target Audience: How to Define and Maximize ItMatt Haag
 
Ilb ira brochure-20140327145457
Ilb ira brochure-20140327145457Ilb ira brochure-20140327145457
Ilb ira brochure-20140327145457Michael Kleven
 

Destaque (15)

Introduction to NativeScript - BuildTruly Native Apps using JavaScript
Introduction to NativeScript - BuildTruly Native Apps using JavaScriptIntroduction to NativeScript - BuildTruly Native Apps using JavaScript
Introduction to NativeScript - BuildTruly Native Apps using JavaScript
 
Rxjs ppt
Rxjs pptRxjs ppt
Rxjs ppt
 
Native Script by Sebastian Witalec
Native Script by Sebastian WitalecNative Script by Sebastian Witalec
Native Script by Sebastian Witalec
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2
 
React lecture
React lectureReact lecture
React lecture
 
Why discovery of open books is a challenge
Why discovery of open books is a challengeWhy discovery of open books is a challenge
Why discovery of open books is a challenge
 
The sorry state of Finnish e-payment APIs
The sorry state of Finnish e-payment APIsThe sorry state of Finnish e-payment APIs
The sorry state of Finnish e-payment APIs
 
Causal and semantic relatedness effects on L2 text processing and memory: Evi...
Causal and semantic relatedness effects on L2 text processing and memory: Evi...Causal and semantic relatedness effects on L2 text processing and memory: Evi...
Causal and semantic relatedness effects on L2 text processing and memory: Evi...
 
Research Brief: Federal Reserve // March 2017
Research Brief: Federal Reserve // March 2017Research Brief: Federal Reserve // March 2017
Research Brief: Federal Reserve // March 2017
 
Comment automatiser l'exploitation de vos données webanalytics
Comment automatiser l'exploitation de vos données webanalyticsComment automatiser l'exploitation de vos données webanalytics
Comment automatiser l'exploitation de vos données webanalytics
 
บทที่8กฎหมายคอมพิวเตอร์[1]
บทที่8กฎหมายคอมพิวเตอร์[1]บทที่8กฎหมายคอมพิวเตอร์[1]
บทที่8กฎหมายคอมพิวเตอร์[1]
 
Why It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead Today
Why It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead TodayWhy It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead Today
Why It Takes 7-13+ Touches to Generate a Qualified B2B Sales Lead Today
 
Identifying your Target Audience: How to Define and Maximize It
Identifying your Target Audience: How to Define and Maximize ItIdentifying your Target Audience: How to Define and Maximize It
Identifying your Target Audience: How to Define and Maximize It
 
Origen y evolucion del teatro
Origen y evolucion del teatroOrigen y evolucion del teatro
Origen y evolucion del teatro
 
Ilb ira brochure-20140327145457
Ilb ira brochure-20140327145457Ilb ira brochure-20140327145457
Ilb ira brochure-20140327145457
 

Semelhante a Nativescript for Angular2: Build Native iOS and Android Apps with JavaScript

Ignite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and FirebaseIgnite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and FirebaseJen Looper
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsSarath C
 
Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020 Bogusz Jelinski
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
Nodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsNodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsBudh Ram Gurung
 
Phonegap android angualr material design
Phonegap android angualr material designPhonegap android angualr material design
Phonegap android angualr material designSrinadh Kanugala
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsNicholas Jansma
 
Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]Sentinel Solutions Ltd
 
Visual Studio 2017 Launch Event
Visual Studio 2017 Launch EventVisual Studio 2017 Launch Event
Visual Studio 2017 Launch EventJames Montemagno
 
High Productivity Web Development Workflow
High Productivity Web Development WorkflowHigh Productivity Web Development Workflow
High Productivity Web Development WorkflowVũ Nguyễn
 
High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014Oliver N
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.JooinK
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWTFrancesca Tosi
 
Progressive Web Application by Citytech
Progressive Web Application by CitytechProgressive Web Application by Citytech
Progressive Web Application by CitytechRitwik Das
 
NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行Osamu Monoe
 
Cross Platform Mobile App Development
Cross Platform Mobile App DevelopmentCross Platform Mobile App Development
Cross Platform Mobile App DevelopmentAnnmarie Lanesey
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkTroy Miles
 

Semelhante a Nativescript for Angular2: Build Native iOS and Android Apps with JavaScript (20)

Ignite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and FirebaseIgnite your app development with Angular, NativeScript and Firebase
Ignite your app development with Angular, NativeScript and Firebase
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS Apps
 
Mobile development in 2020
Mobile development in 2020 Mobile development in 2020
Mobile development in 2020
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Nodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsNodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web Applications
 
Phonegap android angualr material design
Phonegap android angualr material designPhonegap android angualr material design
Phonegap android angualr material design
 
React Native
React NativeReact Native
React Native
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.js
 
Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]Titanium Studio [Updated - 18/12/2011]
Titanium Studio [Updated - 18/12/2011]
 
Kunal bhatia resume mass
Kunal bhatia   resume massKunal bhatia   resume mass
Kunal bhatia resume mass
 
Visual Studio 2017 Launch Event
Visual Studio 2017 Launch EventVisual Studio 2017 Launch Event
Visual Studio 2017 Launch Event
 
Expo - Zero to App.pptx
Expo - Zero to App.pptxExpo - Zero to App.pptx
Expo - Zero to App.pptx
 
High Productivity Web Development Workflow
High Productivity Web Development WorkflowHigh Productivity Web Development Workflow
High Productivity Web Development Workflow
 
High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWT
 
Progressive Web Application by Citytech
Progressive Web Application by CitytechProgressive Web Application by Citytech
Progressive Web Application by Citytech
 
NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行NativeScript 環境のインストールとはじめてのプロジェクト実行
NativeScript 環境のインストールとはじめてのプロジェクト実行
 
Cross Platform Mobile App Development
Cross Platform Mobile App DevelopmentCross Platform Mobile App Development
Cross Platform Mobile App Development
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 

Mais de Christoffer Noring (20)

Azure signalR
Azure signalRAzure signalR
Azure signalR
 
Game dev 101 part 3
Game dev 101 part 3Game dev 101 part 3
Game dev 101 part 3
 
Game dev 101 part 2
Game dev 101   part 2Game dev 101   part 2
Game dev 101 part 2
 
Game dev workshop
Game dev workshopGame dev workshop
Game dev workshop
 
Deploying your static web app to the Cloud
Deploying your static web app to the CloudDeploying your static web app to the Cloud
Deploying your static web app to the Cloud
 
IaaS with ARM templates for Azure
IaaS with ARM templates for AzureIaaS with ARM templates for Azure
IaaS with ARM templates for Azure
 
Learning Svelte
Learning SvelteLearning Svelte
Learning Svelte
 
Ng spain
Ng spainNg spain
Ng spain
 
Angular Schematics
Angular SchematicsAngular Schematics
Angular Schematics
 
Design thinking
Design thinkingDesign thinking
Design thinking
 
Keynote ijs
Keynote ijsKeynote ijs
Keynote ijs
 
Vue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and VuexVue fundamentasl with Testing and Vuex
Vue fundamentasl with Testing and Vuex
 
Ngrx slides
Ngrx slidesNgrx slides
Ngrx slides
 
Kendoui
KendouiKendoui
Kendoui
 
Angular mix chrisnoring
Angular mix chrisnoringAngular mix chrisnoring
Angular mix chrisnoring
 
Nativescript angular
Nativescript angularNativescript angular
Nativescript angular
 
Graphql, REST and Apollo
Graphql, REST and ApolloGraphql, REST and Apollo
Graphql, REST and Apollo
 
Angular 2 introduction
Angular 2 introductionAngular 2 introduction
Angular 2 introduction
 
Rxjs vienna
Rxjs viennaRxjs vienna
Rxjs vienna
 
Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Nativescript for Angular2: Build Native iOS and Android Apps with JavaScript

  • 1. Nativescript for Angular2 Chris Noring Google Developer Expert Front end Developer at OVO Energy
  • 3. What’s out there for building apps?
  • 4. App store and market place = plan for monetizing + It also has Built in features like camera, gps, push notifications + Has access to Native swift, objective-c java - Usually needs one dev team per platform $$$
  • 5. Web apps One team, only needs to know javascript + css + Cost less - Limited access to hardware - Browser support, increase maintenance and dev time - Monetizing? Will cost time and money to make it work well on all browsers also conti - Doesn’t feel like native, its a compromise + Great for simple scenarios like a responsive version of t geoposition
  • 6. Hybrid frameworks - You need to learn its api rendering in web views, not truly native UI + It is possible to use an App Store - Limited access to hardware but the support is getting better and better WebRTC* WebGL WebAudio IndexedDB Web Components* Utilize Hardware Acceleratio Remote Debugging* - More and more cool features are being supported just a regular mobile optimized website, written in CSS, HTML and JavaScript, that is display Ionic Cordova Phonegap Titanium React Native
  • 7. Progressive web apps + Caches Is this the future? - Monetizing? + Feels like an app - Not great support on Safari yet + Progressive enhancement better features with better browser and better broadband + Push notifications
  • 8. So how does nativescript fit in?
  • 9. It’s NOT web although javascript, so no DOM It targets actual apis Its supports hardware due to being actual native BUT you can use your javascript and css skills AND you can use your native developers because THEY KNOW THE API It’s NOT either javascript or native folks, ITS BOTH
  • 10. Nativescript killer features You can style native ui with css You can use javascript OR angular 2 with typescript free and open source framework for building native iOS and Android apps using JavaScript and C You can access native apis with javascript it’s free It has hardware accelerated animations You can monetise cause you can use App Store and markets It’s pluggable, you can use and write your own plugins
  • 11. How does it work?
  • 12. Nativescript runtime uses Javascript virtual machines executed by V8. is JIT compiled and v8 JavaScriptCore Android iOS how does v8 know what android.text.format.Time() is? var time = new android.text.format.Time(); this is javascript
  • 13. NativeScript uses it to inject APIs that let you access native code. nativescript inject android/ios object to v8 or Javascript Core There are APIs on v8 that lets you affect the global scope How to know what to inject? JavaScriptCore has a similar mechanism that makes the same te How to interpret the js code?
  • 14. 1) NativeScript uses reflection to build the list of the APIs that are av invokes a callback that native script can intercept, in that interceptio 2) android.text.format.Time() javascript code corresponding c++ callback invokes JNI-bridge to talk to native API Android invokes native API directly iOS
  • 15. In conclusion Nativescript investigates what to inject and injects metadat A callback is connected to each executed javascript that na C++ code on Android targets JNI ( c++ becomes java ) that C++ on iOS talks to native API directly And presto
  • 17. Modules camera.android.js camera.ios.js camera-common.js selects the correct one at runtime require(‘camera’) camera node_modules/ tns-core-modules module module camera … usage everything is made up of modules
  • 18. How easy is it to get started?
  • 19. Preparing your environment npm install nativescript -g Windows ecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https Mac ruby -e "$(curl -fsSL https://www.nativescript.org/setup/mac)" tns doctor verify your installation
  • 20. Continued.. For android install genymotion https://www.genymotion.com/ set path to android SDK
  • 21. First app scaffold or tns create my-app-name --ng creates angular2 app git clone https://github.com/NativeScript/sample-Groceries.git angular 2 app for nativescript Scaffolding saves a lot of time
  • 22. What is the dev experience like?
  • 23. We got a plugin for vs code so we can set break points We can use hot reload, so code is recompiled and rede We can write and run unit tests
  • 24. Hot reload tns livesync platform —watch 1) compiles app 2) deploys to emulator/ device repeats 1) + 2) on changes
  • 25. Debug tns debug platform starts platform specific debugger with option —debug-brk —debug-brk —start —stop —emulator
  • 26. set breakpoint perform action Build and start the application Start Node Inspector Launch Chrome browser tns debug platform
  • 27. Remote chromium debugger for Eclipse https://www.nativescript.org/nativescript-for-visual-studio-code Plugin for vs code ext install nativescript
  • 28. How hard is it to accomplish something?
  • 29. So we can be productive with all these components we code in angular 2 we can easily extend with plugins we can write our own plugins we got, ui components, we got layouts,http, css animations, gestures, hardware and more..
  • 30. Controls with ng2 <Label class="lbl" [text]="title"></Label> <Button (tap)="click()" text="Save new hero"></Button> <TextField [(ngModel)]="status"></TextField> <ListView [items]="todos" (itemTap)="tapped($event)" > <template let-item="item" let-odd="odd" let-even="even"> </template> </ListView> one-way binding event binding two-way binding So angular 2 with some new components
  • 32. Whats possible? Create, Read, Update, Delete on files and folders import * as fs from "file-system"; var documents = fs.knownFolders.documents(); var myFile = documents.getFile("Test_Write.txt"); myFile.writeText("Something") .then(function () { }, err {}); myFile.readText() .then(function (content) { }, err {}); do something with retrieved content
  • 35. AbsoluteLayout DockLayout GridLayout StackLayout WrapLayout Components ends up exactly where you want them x,y Arranges children to outer edges, last child takes up remaining space columns and rows Horizontally or vertically follows orientation til space is filled then wraps them into new column/row
  • 37. Navigation Navigation is angular 2 router if you know how that works then you know how to build the app
  • 38. CSS
  • 39. CSS Application-wide css, app.css Component-specific css @Component({ styleUrls : [‘pages/examples/list- demo.component.css'] }) @Component({ style : ‘’ }) https://docs.nativescript.org/angular/ui/styling.html Inline css <Button text="inline style" style="background-color: green;"></Button> <Button backgroundColor=“lightgray" >
  • 41. What is a native script plugin? plugin file.android.ts file.ios.ts package.json lookup iOS and java implementation of the same thing [NSDate date] new Date()).toString() and add to respective file.platform.ts write js-ified code corresponding to native api NsDate.date() (new java.util.Date()).toString() Is an npm package, published or not, that exposes a native API
  • 42. http://developer.telerik.com/featured/creating-nativescript-plugins-in-types Great article to get started http://plugins.telerik.com/nativescript Telerik verified marketplace https://docs.nativescript.org/plugins/plugins More details tns plugin add <Plugin> tns plugin remove <Plugin> Add/Remove https://www.thepolyglotdeveloper.com/2016/07/create-native-ios-and-andr
  • 44. Camera import * as cameraModule from 'camera'; cameraModule.takePicture({ width: 300, height: 300, keepAspectRatio: true }) .then((picture) => { console.log('picture taken'); this.source = picture; }) <Image [src]="source" stretch="none" horizontalAlignment="center" > </Image> take picture import a reference Display image in control
  • 46. A word about images file system <Image src="~/images/logo.png" stretch ="none" /> relative to the app folder url <Image src="https://www.google.com/images/errors/logo_sm_2.png" /> resource <Image src="res://logo" stretch ="none" /> App_Resources Android iOS Should be placed in resp platform
  • 48. tns plugin add nativescript-geolocation Install the plugin Check if its enabled, then ask for permission import * as geolocation from "nativescript-geolocation"; if (!geolocation.isEnabled()) { geolocation.enableLocationRequest(); } So much for enabling, how to use?
  • 49. geolocation.getCurrentLocation({ desiredAccuracy: 3, updateDistance: 10, maximumAge: 20000, timeout: 20000}) .then(function(loc) { if (loc) { alert("Current location is: " + loc); console.log("Current location is: " + loc); } }, function(e){ console.log("Error: " + e.message); }); get location, returns a promise And just use a plugin to show the location tns plugin add nativescript-google-sdk Use an actual device to test this one Once enabled, ask for location
  • 51. ctrl.animate({ opacity: 0, backgroundColor: new Color("Blue"), translate: { x: 200, y: 0 }, scale: { x: 2, y: 2 }, rotate: 180, duration: 800, delay: 20, iterations: 1, curve: enums.AnimationCurve.easeIn }) .then(() => { console.log('animation done'); this.ypos += 20; }) We can Rotate, scale, change opacity .. What can we do? translate rotate repeat animation when done
  • 53. Nativescript let’s you code an actual native app using the API you know using javascript Just remember this..
  • 54. Thank you for listening