SlideShare a Scribd company logo
1 of 38
Download to read offline
Introduction to 
Titanium and how 
to connect with a 
PHP backend. 
Patrick JL Laso 
@jl_laso 
www.patricklaso.com 
! 
! 
#SMNYC 
New York, October, 5th 2014
Why Titanium ?
Basic principles of Titanium 
• Easy to learn 
• Multiplatform 
• Based on javascript 
• Free to use 
• Good documentation 
• Good community
What is the objective of this presentation? 
• Illustrate how to implement a very simple application 
• Integrate with a PHP backend through an API rest 
• Deal with the most normal questions that can be in a real 
app 
• Show how to solve the server side in PHP 
• Show how to solve push notifications
Our application 
• A simple score control for ping pong matches. 
• We need to control players and their scores. 
• With only two tables we can implement all the system. 
Principle: the application will run in the smartphone of each 
player. First: one player logs in and starts a match, then: the 
opponent signs in too and selects a match by player, that 
have to be online. There are one big button in the screen 
that each player taps to add a point to his score, that will be 
updated to the other player via push notification.
Prepare to publish 
in Apple Market
http://docs.appcelerator.com/titanium/3.0/#!/guide/Deploying_to_iOS_devices-section- 
27595262_DeployingtoiOSdevices-Obtainadevelopmentcertificate 
• Obtain a development 
certificate 
• Register your test 
devices 
• Create an App ID 
• Create and install a 
development 
provisioning profile 
• Build your app, 
embedding the profile 
within the app's bundle
Need to complain certain rules on resources 
• http://docs.appcelerator.com/titanium/3.0/#!/guide/ 
Icons_and_Splash_Screens-section- 
29004897_IconsandSplashScreens-iTunesConnectAssets
Prepare to publish 
in the Google Play
Google Play: 
every time you upload new APK needs to be another version, 
how to maintain a custom AndroidManifest 
http://developer.appcelerator.com/doc/mobile/android-custom-androidmanifest
Prepare push 
notifications for 
Android
Push notifications (Android) >= 4.2.2 
• http://docs.appcelerator.com/titanium/3.0/#!/guide/Configuring_push_services-section- 
37551713_Configuringpushservices- 
ConfiguringpushservicesforAndroiddevices 
• http://developer.android.com/google/gcm/gs.html#create-proj 
Old Android versions need to add permission to GET_ACCOUNTS: 
install module: https://github.com/appcelerator/titanium_modules 
ti.cloudpush 2.3.3 https://github.com/hieupham007/ 
Titanium_Mobile/tree/b33102312f137fb8ee6c1aa02374aba9c0968f68/ 
support/module/packaged 
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
Prepare push 
notifications for iOS
Push notifications (iOS) 
• http://docs.appcelerator.com/titanium/3.0/#!/guide/ 
Configuring_push_services-section- 
37551713_Configuringpushservices- 
ConfiguringpushservicesforiOSdevices 
• https://developer.apple.com/account/ios/certificate/ 
certificateCreate.action
The App 
Come in !
Match life cycle 
Login 
Player 
Start 
match 
Opponent 
Login 
Join 
match 
Match 
started 
push notification 
push notification 
Claim 
point 
Score 
updated 
push notification 
Claim 
point 
You 
loose 
9 times 
DB
Main screen 
To enter into the application user 
have to sign in with his nick and 
password. 
! 
It's possible to register online with 
the app.
Rival screenshot 
This screenshot is updated to show 
players connected sorted by distance. 
! 
At bottom we can see the hall of fame (*) 
! 
To start a match he have to choose the 
number of points to win (15/21). 
* Not implemented yet!
Playing screenshot 
Scores. 
! 
Button to claim a point. 
! 
Button to quit match (surrender).
Winner screenshot 
This screenshot shows the winner 
of the match.
Force App to 
portrait mode 
http://docs.appcelerator.com/ 
titanium/3.0/#!/guide/Orientation
How to integrate a 
third part module 
Why reinvent the wheel ? 
! 
Use modules of third-part that are 
tested and approved by 
Appcelerator. 
! 
Or use other modules.
Use third-part location module 
• cd project-path/Resources 
• git clone https://github.com/Who828/titanium-location-module. 
git location 
! 
Where you want to access location …! 
var location = require('/location/location'); 
location.start({ 
action: function(responseLocation) { 
// save gps position 
appc.gps = responseLocation; 
Titanium.API.info(responseLocation); 
location.stop(); 
}, 
error: function() { 
alert('Error: ' + e.error); 
} 
});
The code
Graphic elements 
var 
win1 
= 
Titanium.UI.createWindow({ 
title:'Settings', 
backgroundColor:'#fff' 
}); 
!! 
var 
labelNick 
= 
Titanium.UI.createLabel({ 
color: 
appc.colors.label, 
text: 
'User', 
top: 
'15dp', 
font: 
appc.fonts.labelFont, 
textAlign: 
'center', 
width: 
'auto' 
}); 
win1.add(labelNick); 
!! 
var 
inputNick 
= 
Titanium.UI.createTextField({ 
borderStyle 
: 
Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, 
backgroundColor:'#FFF', 
borderColor 
: 
'#333', 
borderWidth 
: 
1, 
font 
: 
appc.fonts.inputFont, 
color 
: 
'#336699', 
top 
: 
'50dp', 
left 
: 
'10%', 
width 
: 
'80%', 
height 
: 
'40dp', 
hintText 
: 
'Nick', 
value 
: 
'' 
}); 
win1.add(inputNick);
Multiplatform 
In some cases we need to distinguish 
in which platform is running our app. 
var 
simulator 
= 
(Titanium.Platform.model 
== 
"Simulator"); 
if (Titanium.Platform.osname == 'android') { … } 
if ((Titanium.Platform.osname == 'ipad') || 
(Titanium.Platform.osname == 'iphone')) { … }
GPS 
Don't forget to add permission in build/android/ 
AndroidManifest.xml: 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
if (Titanium.Geolocation.locationServicesEnabled) { 
! 
// message that presents to user when device ask for permission 
Titanium.Geolocation.purpose = 'Determine Current Location'; 
! 
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST; 
! 
Titanium.Geolocation.distanceFilter = 10; 
! 
Titanium.Geolocation.preferredProvider = Titanium.Geolocation.PROVIDER_GPS; 
! 
Titanium.Geolocation.addEventListener('location', function(e) { 
if (e.error) { 
alert('Error: ' + e.error); 
} else { 
Titanium.API.info(e.coords); 
// save the coordinates in order to use later 
appc.gps = e.coords; 
} 
}); 
} else { 
alert('Please enable location services'); 
}
Best Practices and Recommendations 
http://docs.appcelerator.com/titanium/3.0/#!/guide/ 
Best_Practices_and_Recommendations 
• Coding Best Practices 
• CommonJS Modules in Titanium 
• Application Frameworks 
• Image Best Practices 
• Database Best Practices 
• Style and Conventions
SERVER SIDE Let's see !
The server side 
• API very very simplified 
• Security is also simplified for educational purposes: api-key 
and user & password in the major part of actions 
• routes following REST standard: 
• GET: get information 
• PUT: modify records 
• POST: create records 
• DELETE: delete info
The data 
• Players 
! 
• Matches 
`id` 
int(11) 
NOT 
NULL 
AUTO_INCREMENT, 
`nick` 
varchar(100) 
DEFAULT 
NULL, 
`password` 
char(40) 
DEFAULT 
NULL, 
`email` 
varchar(100) 
DEFAULT 
NULL, 
`hash` 
char(40) 
DEFAULT 
NULL, 
`cloud_id` 
char(50) 
DEFAULT 
NULL, 
`match_id` 
int(11) 
DEFAULT 
NULL, 
`id` 
int(11) 
NOT 
NULL 
AUTO_INCREMENT, 
`player1` 
int(11) 
DEFAULT 
NULL, 
`player2` 
int(11) 
DEFAULT 
NULL, 
`created_at` 
datetime 
DEFAULT 
NULL, 
`finished_at` 
datetime 
DEFAULT 
NULL, 
`score1` 
int(11) 
DEFAULT 
NULL, 
`score2` 
int(11) 
DEFAULT 
NULL, 
`to_points` 
int(11) 
DEFAULT 
21, 
DB
Connecting the app to server 
• REST-API endpoints. 
• Some security issues. 
• Call's sequence.
Push notifications (server)
Push notifications 
• To send push notifications to a 
device through ACS first the 
device need to be subscribed. 
• In the login process in the app, 
ACS gives a cloud id to identify 
this user. 
• We save this cloud id in the user 
table to know how to 
communicate with this user. 
• And finally we can address some 
kind of messages to this user. 
• We need API and KEY to 
establish connection with ACS
Routes 
GET 
• /api/v1/version 
• /api/v1/players.json 
• /api/v1/search-match 
• /api/v1/match-info 
PUT 
• /api/v1/login 
• /api/v1/set-cloud-id 
• /api/v1/start-match[?toPoints=11|21] 
• /api/v1/join-match/:matchId 
• /api/v1/claim-point 
POST 
• /api/v1/register
Some responses to API requests (see /api-doc/v1) 
• GET /api/v1/version 
{"result":true,"version":"1"} 
• GET /api/v1/players.json 
{"result":true,"players": 
[{"id":"1","nick":"player1","email":"player1@pingpongserver.ahiroo.com"}, 
{"id":"2","nick":"player2","email":"player2@pingpongserver.ahiroo.com"}, 
{"id":"3","nick":"player3","email":"player3@pingpongserver.ahiroo.com"}]} 
• GET /api/v1/players.json?criteria=player1 
{"result":true,"players": 
[{"id":"1","nick":"player1","email":"player1@pingpongserver.ahiroo.com"}]} 
• PUT /api/v1/start-match?toPoints=11 
{"result":true,"match":"2"} 
• GET /api/v1/search-match?criteria=player2 
{"result":true,"matches": 
[{"id":"2","player1":"2","player2":null,"created_at":"2014-­‐08-­‐03 
07:47:45","finished_at":null,"score1":0,"score2": 
0,"to_points":"21"}],"players":["2"]}
Thanks 
! 
http://www.github.com/jlaso/pingpongserver 
http://www.github.com/jlaso/pingpongapp 
! 
@jl_laso

More Related Content

What's hot

Android studio
Android studioAndroid studio
Android studioAndri Yabu
 
Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021Svetlin Nakov
 
Automating the Gaps of Unit Testing Mobile Apps
Automating the Gaps of Unit Testing Mobile AppsAutomating the Gaps of Unit Testing Mobile Apps
Automating the Gaps of Unit Testing Mobile AppsGeoffrey Goetz
 
Toy robot simulator
Toy robot simulatorToy robot simulator
Toy robot simulatorpauldeng
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espressoÉdipo Souza
 
Developing Android Apps
Developing Android AppsDeveloping Android Apps
Developing Android AppsClaire Lee
 
How to be a Tizen Committer
How to be a Tizen CommitterHow to be a Tizen Committer
How to be a Tizen CommitterEun Young Lee
 
Android Fundamentals
Android FundamentalsAndroid Fundamentals
Android FundamentalsHenry Osborne
 
Getting your app on Android TV
Getting your app on Android TVGetting your app on Android TV
Getting your app on Android TVXavier Hallade
 
Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)LewisB2013
 
Let's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UILet's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UIAtlassian
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updatedGhanaGTUG
 
(Christian heilman) firefox
(Christian heilman) firefox(Christian heilman) firefox
(Christian heilman) firefoxNAVER D2
 
Mobile App Testing ScanAgile 2012
Mobile App Testing ScanAgile 2012Mobile App Testing ScanAgile 2012
Mobile App Testing ScanAgile 2012Daniel Knott
 
MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)Loiane Groner
 
Designing Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemDesigning Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemAtlassian
 
081107 Sammy Eclipse Summit2
081107   Sammy   Eclipse Summit2081107   Sammy   Eclipse Summit2
081107 Sammy Eclipse Summit2mkempka
 
New to native? Getting Started With iOS Development
New to native?   Getting Started With iOS DevelopmentNew to native?   Getting Started With iOS Development
New to native? Getting Started With iOS DevelopmentGeoffrey Goetz
 

What's hot (20)

Android studio
Android studioAndroid studio
Android studio
 
Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021Appium Mobile Testing: Nakov at BurgasConf - July 2021
Appium Mobile Testing: Nakov at BurgasConf - July 2021
 
Automating the Gaps of Unit Testing Mobile Apps
Automating the Gaps of Unit Testing Mobile AppsAutomating the Gaps of Unit Testing Mobile Apps
Automating the Gaps of Unit Testing Mobile Apps
 
Toy robot simulator
Toy robot simulatorToy robot simulator
Toy robot simulator
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espresso
 
Developing Android Apps
Developing Android AppsDeveloping Android Apps
Developing Android Apps
 
Android Lab
Android LabAndroid Lab
Android Lab
 
How to be a Tizen Committer
How to be a Tizen CommitterHow to be a Tizen Committer
How to be a Tizen Committer
 
Android Fundamentals
Android FundamentalsAndroid Fundamentals
Android Fundamentals
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
Getting your app on Android TV
Getting your app on Android TVGetting your app on Android TV
Getting your app on Android TV
 
Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)
 
Let's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UILet's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UI
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
(Christian heilman) firefox
(Christian heilman) firefox(Christian heilman) firefox
(Christian heilman) firefox
 
Mobile App Testing ScanAgile 2012
Mobile App Testing ScanAgile 2012Mobile App Testing ScanAgile 2012
Mobile App Testing ScanAgile 2012
 
MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)
 
Designing Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemDesigning Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI System
 
081107 Sammy Eclipse Summit2
081107   Sammy   Eclipse Summit2081107   Sammy   Eclipse Summit2
081107 Sammy Eclipse Summit2
 
New to native? Getting Started With iOS Development
New to native?   Getting Started With iOS DevelopmentNew to native?   Getting Started With iOS Development
New to native? Getting Started With iOS Development
 

Similar to Introduction to Titanium and how to connect with a PHP backend

Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Antonio Peric-Mazar
 
Telerik AppBuilder Presentation for TelerikNEXT Conference
Telerik AppBuilder Presentation for TelerikNEXT ConferenceTelerik AppBuilder Presentation for TelerikNEXT Conference
Telerik AppBuilder Presentation for TelerikNEXT ConferenceJen Looper
 
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...Wim Selles
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
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
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxNgLQun
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersAmbarish Hazarnis
 
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Innomatic Platform
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJSGregor Woiwode
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMohammad Shaker
 
Advanced REST API Scripting With AppDynamics
Advanced REST API Scripting With AppDynamicsAdvanced REST API Scripting With AppDynamics
Advanced REST API Scripting With AppDynamicsTodd Radel
 
Android, the life of your app
Android, the life of your appAndroid, the life of your app
Android, the life of your appEyal Lezmy
 
DEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking ForDEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking ForMichael Scovetta
 
Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)Sujee Maniyam
 
Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011sullis
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngineikailan
 

Similar to Introduction to Titanium and how to connect with a PHP backend (20)

Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...
 
Telerik AppBuilder Presentation for TelerikNEXT Conference
Telerik AppBuilder Presentation for TelerikNEXT ConferenceTelerik AppBuilder Presentation for TelerikNEXT Conference
Telerik AppBuilder Presentation for TelerikNEXT Conference
 
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
How React Native, Appium and me made each other shine @ContinuousDeliveryAmst...
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
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
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptxLecture 12 - Maps, AR_VR_aaaaHardware.pptx
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - Beginners
 
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
Building Multi-Tenant and SaaS products in PHP - CloudConf 2015
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
 
AIR & API
AIR & APIAIR & API
AIR & API
 
Advanced REST API Scripting With AppDynamics
Advanced REST API Scripting With AppDynamicsAdvanced REST API Scripting With AppDynamics
Advanced REST API Scripting With AppDynamics
 
Android, the life of your app
Android, the life of your appAndroid, the life of your app
Android, the life of your app
 
DEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking ForDEFCON 18- These Aren't the Permissions You're Looking For
DEFCON 18- These Aren't the Permissions You're Looking For
 
Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)Iphone client-server app with Rails backend (v3)
Iphone client-server app with Rails backend (v3)
 
Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 

Recently uploaded

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 

Recently uploaded (20)

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 

Introduction to Titanium and how to connect with a PHP backend

  • 1. Introduction to Titanium and how to connect with a PHP backend. Patrick JL Laso @jl_laso www.patricklaso.com ! ! #SMNYC New York, October, 5th 2014
  • 3. Basic principles of Titanium • Easy to learn • Multiplatform • Based on javascript • Free to use • Good documentation • Good community
  • 4. What is the objective of this presentation? • Illustrate how to implement a very simple application • Integrate with a PHP backend through an API rest • Deal with the most normal questions that can be in a real app • Show how to solve the server side in PHP • Show how to solve push notifications
  • 5. Our application • A simple score control for ping pong matches. • We need to control players and their scores. • With only two tables we can implement all the system. Principle: the application will run in the smartphone of each player. First: one player logs in and starts a match, then: the opponent signs in too and selects a match by player, that have to be online. There are one big button in the screen that each player taps to add a point to his score, that will be updated to the other player via push notification.
  • 6. Prepare to publish in Apple Market
  • 7. http://docs.appcelerator.com/titanium/3.0/#!/guide/Deploying_to_iOS_devices-section- 27595262_DeployingtoiOSdevices-Obtainadevelopmentcertificate • Obtain a development certificate • Register your test devices • Create an App ID • Create and install a development provisioning profile • Build your app, embedding the profile within the app's bundle
  • 8. Need to complain certain rules on resources • http://docs.appcelerator.com/titanium/3.0/#!/guide/ Icons_and_Splash_Screens-section- 29004897_IconsandSplashScreens-iTunesConnectAssets
  • 9. Prepare to publish in the Google Play
  • 10. Google Play: every time you upload new APK needs to be another version, how to maintain a custom AndroidManifest http://developer.appcelerator.com/doc/mobile/android-custom-androidmanifest
  • 12. Push notifications (Android) >= 4.2.2 • http://docs.appcelerator.com/titanium/3.0/#!/guide/Configuring_push_services-section- 37551713_Configuringpushservices- ConfiguringpushservicesforAndroiddevices • http://developer.android.com/google/gcm/gs.html#create-proj Old Android versions need to add permission to GET_ACCOUNTS: install module: https://github.com/appcelerator/titanium_modules ti.cloudpush 2.3.3 https://github.com/hieupham007/ Titanium_Mobile/tree/b33102312f137fb8ee6c1aa02374aba9c0968f68/ support/module/packaged <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  • 14. Push notifications (iOS) • http://docs.appcelerator.com/titanium/3.0/#!/guide/ Configuring_push_services-section- 37551713_Configuringpushservices- ConfiguringpushservicesforiOSdevices • https://developer.apple.com/account/ios/certificate/ certificateCreate.action
  • 15.
  • 16. The App Come in !
  • 17. Match life cycle Login Player Start match Opponent Login Join match Match started push notification push notification Claim point Score updated push notification Claim point You loose 9 times DB
  • 18. Main screen To enter into the application user have to sign in with his nick and password. ! It's possible to register online with the app.
  • 19. Rival screenshot This screenshot is updated to show players connected sorted by distance. ! At bottom we can see the hall of fame (*) ! To start a match he have to choose the number of points to win (15/21). * Not implemented yet!
  • 20. Playing screenshot Scores. ! Button to claim a point. ! Button to quit match (surrender).
  • 21. Winner screenshot This screenshot shows the winner of the match.
  • 22. Force App to portrait mode http://docs.appcelerator.com/ titanium/3.0/#!/guide/Orientation
  • 23. How to integrate a third part module Why reinvent the wheel ? ! Use modules of third-part that are tested and approved by Appcelerator. ! Or use other modules.
  • 24. Use third-part location module • cd project-path/Resources • git clone https://github.com/Who828/titanium-location-module. git location ! Where you want to access location …! var location = require('/location/location'); location.start({ action: function(responseLocation) { // save gps position appc.gps = responseLocation; Titanium.API.info(responseLocation); location.stop(); }, error: function() { alert('Error: ' + e.error); } });
  • 26. Graphic elements var win1 = Titanium.UI.createWindow({ title:'Settings', backgroundColor:'#fff' }); !! var labelNick = Titanium.UI.createLabel({ color: appc.colors.label, text: 'User', top: '15dp', font: appc.fonts.labelFont, textAlign: 'center', width: 'auto' }); win1.add(labelNick); !! var inputNick = Titanium.UI.createTextField({ borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, backgroundColor:'#FFF', borderColor : '#333', borderWidth : 1, font : appc.fonts.inputFont, color : '#336699', top : '50dp', left : '10%', width : '80%', height : '40dp', hintText : 'Nick', value : '' }); win1.add(inputNick);
  • 27. Multiplatform In some cases we need to distinguish in which platform is running our app. var simulator = (Titanium.Platform.model == "Simulator"); if (Titanium.Platform.osname == 'android') { … } if ((Titanium.Platform.osname == 'ipad') || (Titanium.Platform.osname == 'iphone')) { … }
  • 28. GPS Don't forget to add permission in build/android/ AndroidManifest.xml: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> if (Titanium.Geolocation.locationServicesEnabled) { ! // message that presents to user when device ask for permission Titanium.Geolocation.purpose = 'Determine Current Location'; ! Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST; ! Titanium.Geolocation.distanceFilter = 10; ! Titanium.Geolocation.preferredProvider = Titanium.Geolocation.PROVIDER_GPS; ! Titanium.Geolocation.addEventListener('location', function(e) { if (e.error) { alert('Error: ' + e.error); } else { Titanium.API.info(e.coords); // save the coordinates in order to use later appc.gps = e.coords; } }); } else { alert('Please enable location services'); }
  • 29. Best Practices and Recommendations http://docs.appcelerator.com/titanium/3.0/#!/guide/ Best_Practices_and_Recommendations • Coding Best Practices • CommonJS Modules in Titanium • Application Frameworks • Image Best Practices • Database Best Practices • Style and Conventions
  • 31. The server side • API very very simplified • Security is also simplified for educational purposes: api-key and user & password in the major part of actions • routes following REST standard: • GET: get information • PUT: modify records • POST: create records • DELETE: delete info
  • 32. The data • Players ! • Matches `id` int(11) NOT NULL AUTO_INCREMENT, `nick` varchar(100) DEFAULT NULL, `password` char(40) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, `hash` char(40) DEFAULT NULL, `cloud_id` char(50) DEFAULT NULL, `match_id` int(11) DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, `player1` int(11) DEFAULT NULL, `player2` int(11) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `finished_at` datetime DEFAULT NULL, `score1` int(11) DEFAULT NULL, `score2` int(11) DEFAULT NULL, `to_points` int(11) DEFAULT 21, DB
  • 33. Connecting the app to server • REST-API endpoints. • Some security issues. • Call's sequence.
  • 35. Push notifications • To send push notifications to a device through ACS first the device need to be subscribed. • In the login process in the app, ACS gives a cloud id to identify this user. • We save this cloud id in the user table to know how to communicate with this user. • And finally we can address some kind of messages to this user. • We need API and KEY to establish connection with ACS
  • 36. Routes GET • /api/v1/version • /api/v1/players.json • /api/v1/search-match • /api/v1/match-info PUT • /api/v1/login • /api/v1/set-cloud-id • /api/v1/start-match[?toPoints=11|21] • /api/v1/join-match/:matchId • /api/v1/claim-point POST • /api/v1/register
  • 37. Some responses to API requests (see /api-doc/v1) • GET /api/v1/version {"result":true,"version":"1"} • GET /api/v1/players.json {"result":true,"players": [{"id":"1","nick":"player1","email":"player1@pingpongserver.ahiroo.com"}, {"id":"2","nick":"player2","email":"player2@pingpongserver.ahiroo.com"}, {"id":"3","nick":"player3","email":"player3@pingpongserver.ahiroo.com"}]} • GET /api/v1/players.json?criteria=player1 {"result":true,"players": [{"id":"1","nick":"player1","email":"player1@pingpongserver.ahiroo.com"}]} • PUT /api/v1/start-match?toPoints=11 {"result":true,"match":"2"} • GET /api/v1/search-match?criteria=player2 {"result":true,"matches": [{"id":"2","player1":"2","player2":null,"created_at":"2014-­‐08-­‐03 07:47:45","finished_at":null,"score1":0,"score2": 0,"to_points":"21"}],"players":["2"]}
  • 38. Thanks ! http://www.github.com/jlaso/pingpongserver http://www.github.com/jlaso/pingpongapp ! @jl_laso