Professional Documents
Culture Documents
Logro
¿Cómo?
Middleware
RESTful API
REST
JSON
JSON
{"customers":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
JSON Files
Extensión .JSON
MIME Type “application/json”
JSON & RoR
Gradle
compile 'com.google.code.gson:gson:2.2.4'
GSON
Primitivas
// Serialization
Gson gson = new Gson();
gson.toJson(1); // ==> 1
gson.toJson("abcd"); // ==> "abcd"
gson.toJson(new Long(10)); // ==> 10
int[] values = { 1 };
gson.toJson(values); // ==> [1]
// Deserialization
int one = gson.fromJson("1", int.class);
Integer one = gson.fromJson("1", Integer.class);
Long one = gson.fromJson("1", Long.class);
Boolean false = gson.fromJson("false", Boolean.class);
String str = gson.fromJson("\"abc\"", String.class);
String[] anotherStr = gson.fromJson("[\"abc\"]", String[].class);
TEMA # 3
Storage
Push notifications
Usage Analytics
Dashboard/UI
User Administration & Social Integration
Custom Code Integration
BaaS/MBaaS Providers
Algunos proveedores
AnyPresence back{4}app
ApiOmat Built.io
Appcelerator CloudKit
Arrow Google Cloud Platform
Appery.io & Firebase
Appmobi Kinvey
AWS Mobile Microsoft Azure Mobile
Hub Services
TEMA # 4
Firebase
Carácterísticas
Proyectos
Prerrequisitos
Agregar a proyecto
Alternativas:
• Firebase Assistant en Android Studio (Menú Tools > Firebase).
• Agregar manualmente en Firebase console
(https://console.firebase.google.com).
Proyectos
Bibliotecas
Gradle Dependency Line Service
com.google.firebase:firebase-core:10.0.1 Analytics
com.google.firebase:firebase-storage:10.0.1 Storage
com.google.firebase:firebase-auth:10.0.1 Authentication
com.google.firebase:firebase-ads:10.0.1 AdMob
Agregar
Gradle
com.google.firebase:firebase-database:10.0.1
Configurar reglas
Autenticación
Acceso público
Realtime Database
Guardar
getInstance()
getReference()
myRef.setValue("Hello, World!");
Realtime Database
Leer
addValueEventListener()
Override de método onDataChange()
// Read from the database
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
String value = dataSnapshot.getValue(String.class);
Log.d(TAG, "Value is: " + value);
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});
Realtime Database
Estructurar datos
Evite anidar datos
Aplane las estructuras de datos
Cree estructuras de datos que escalen
Realtime Database
Estructurar datos
// An index to track Ada's memberships
{
"users": {
"alovelace": {
"name": "Ada Lovelace",
// Index Ada's groups in her profile
"groups": {
// the value here doesn't matter, just that the key exists
"techpioneers": true,
"womentechmakers": true
}
},
...
},
"groups": {
"techpioneers": {
"name": "Historical Tech Pioneers",
"members": {
"alovelace": true,
"ghopper": true,
"eclarke": true
}
},
...
}
}
Conclusiones
1 BaaS
6 RESTful API
Bibliografía
• GSON
https://github.com/google/gson
• Firebase
https://firebase.google.com
Material producido por la Universidad Peruana de Ciencias Aplicadas
Autor: Ángel Augusto Velásquez Núñez
COPYRIGHT ©UPC 2016 - Todos los derechos reservados.