Telerik DevRel
Developer Relations team @ Telerik!
3 strategies to make your NativeScript apps feel all the feels!
Jen Looper
Progress
Senior Developer Advocate
@jenlooper
@jenlooper
an open source framework for building truly native mobile apps with JavaScript. Use web skills, like TypeScript, Angular and CSS, and get native UI and performance on iOS and Android.
@jenlooper
NativeScript is the best tool for cross-platform native app development 🎉
@jenlooper
1
Rich, animated, “no compromise” native UI
(with shared UI code)
Search for
“Examples NativeScript”
in the iOS App Store or Google Play to try this app out for yourself.
@jenlooper
2
Maximum code and skill reusability
@jenlooper
3
@jenlooper
@jenlooper
@jenlooper
@jenlooper
@jenlooper
4
@jenlooper
@jenlooper
5
@jenlooper
@jenlooper
My apps are stupid and boring
@jenlooper
Turn your app into a personal assistant with one plugin
Try two machine learning APIs
Talk a little about what's possible next
@jenlooper
@jenlooper
Powered by Firebase & NativeScript
QuickNoms.com
@jenlooper
Algolia search
Firebase Remote Config marquee
Text-To-Speech
@jenlooper
@jenlooper
speak(text: string){
this.isSpeaking = true;
let speakOptions: SpeakOptions = {
text: text,
speakRate: 0.5,
finishedCallback: (() => {
this.isSpeaking = false;
})
}
this.TTS.speak(speakOptions);
}
pass a string to the plugin to leverage native text-to-speech capability
@jenlooper
@jenlooper
@jenlooper
not
@jenlooper
@jenlooper
@jenlooper
@jenlooper
@jenlooper
Gather a lot of data (images, sounds)
Divide that data into a training set and a test set
Use an algorithm to train a model with the training set by pairing input with expected output
*"supervised learning"
Use the test set to test the accuracy of the training
rinse & repeat
@jenlooper
StitchFix combines ML + human curation
Formulas to pick out clothes based on customer input
Formulas to pair a shopper with a stylist
Formulas to calculate distance of warehouse to customer
Algorithms to search and classify clothing trends to recommend
@jenlooper
@jenlooper
install a ton of surveillance cameras
get really good at ml-powered facial recognition
match faces to IDs
monitor emotions...and manipulate them
push ads at people based on age/gender
invisibly track location
@jenlooper
@jenlooper
MIT students used an algorithm to optimize school bus routes
50 superfluous routes eliminated
$3-5 million saved
50 union bus drivers out of work
@jenlooper
@jenlooper
@jenlooper
@jenlooper
Specialists in image analysis
Took top 5 awards in 2013 ImageNet challenge
Innovative techniques in training models to analyze images
Offer useful pre-trained models like "Food" "Wedding" "NSFW"
Or, train your own model!
@jenlooper
Use Clarif.ai's pretrained Food model to analyze images of plates of food for inspiration
probably not!
might be!
@jenlooper
takePhoto() {
const options: camera.CameraOptions = {
width: 300,
height: 300,
keepAspectRatio: true,
saveToGallery: false
};
camera.takePicture(options)
.then((imageAsset: ImageAsset) => {
this.processRecipePic(imageAsset);
}).catch(err => {
console.log(err.message);
});
}
@jenlooper
public queryClarifaiAPI(imageAsBase64):Promise<any>{
return http.request({
url: AuthService.clarifaiUrl,
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Key " + AuthService.clarifaiKey,
},
content: JSON.stringify({
"inputs": [{
"data": {
"image": {
"base64": imageAsBase64
}
}
}]
})
})
.then(function (response) {
return response
}
)}
@jenlooper
.then(res => {
this.loader.hide();
try {
let result = res.content.toJSON();
let tags = result.outputs[0].data.concepts.map( mc => mc.name + '|' + mc.value );
let ingredients = [];
tags.forEach(function(entry) {
let prob = entry.split('|');
prob = prob[1];
let ingred = entry.split('|');
if(prob > 0.899){
ingredients.push(ingred[0])
}
});
//there should be between four and eight discernable ingredients
if (ingredients.length >= 4 && ingredients.length <= 8) {
alert("Yes! This dish might qualify as a QuickNom! It contains "+ingredients)
}
else {
alert("Hmm. This recipe doesn't have the qualifications of a QuickNom.
Try again!")
}
}
if between 4 & 8 ingredients are listed with over .899 certainty,
it's a QuickNom!
QuickNom dishes have a few easy-to-see, simple ingredients
@jenlooper
Use Google's Vision API to match images with recipes
@jenlooper
Do it all with Google!
Leverage its consumption of millions of photos via Google Photos with Cloud Vision API
@jenlooper
takePhoto() {
const options: camera.CameraOptions = {
width: 300,
height: 300,
keepAspectRatio: true,
saveToGallery: false
};
camera.takePicture(options)
.then((imageAsset: ImageAsset) => {
this.processItemPic(imageAsset);
}).catch(err => {
console.log(err.message);
});
}
@jenlooper
public queryGoogleVisionAPI(imageAsBase64: string):Promise<any>{
return http.request({
url: "https://vision.googleapis.com/v1/images:annotate?key="+AuthService.googleKey,
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": imageAsBase64.length,
},
content: JSON.stringify({
"requests": [{
"image": {
"content": imageAsBase64
},
"features" : [
{
"type":"LABEL_DETECTION",
"maxResults":1
}
]
}]
})
})
.then(function (response) {
return response
}
)}
this.mlService.queryGoogleVisionAPI(imageAsBase64)
.then(res => {
let result = res.content.toJSON();
this.ingredient = result.responses[0].labelAnnotations.map( mc => mc.description );
this.ngZone.run(() => {
this.searchRecipes(this.ingredient)
})
});
@jenlooper
@jenlooper
@jenlooper
@jenlooper
What if you don't want to make a bunch of REST API calls?
What if you need offline capability?
What if you need to reduce costs? (API calls can add up)
What if you need to train something really custom?
@jenlooper
Just landed in iOS 11: Core ML
Train a model, let Core ML process it for your app on device
@jenlooper
TensorFlow Mobile
Designed for low-end Androids, works for iOS and Android
@jenlooper
@jenlooper
@jenlooper
@jenlooper
By Telerik DevRel
For ATO, DevFests, etc