The deck I presented on a technical sharing session at codeMeetUp() weekly meet-up, organized by ProCodeCG, Bandung. The attendees are all coders, senior ones among them. DyCode Education represented by me is very excited and such an honor to be able to deliver the sharing on this meet-up.
Soure code I used for live coding: https://github.com/andriyadi/iOS-Zumo-Sample
11. Typical Steps We’ll Take
Purchase a physical server or a VM
Install OS, Web Server, DB Server
Install & configure server-side scripting/runtime
(PHP, Node.js, Python, .NET, Java)
…and other fine tuning for performance, security
…1 - 2 days later, your server infra is up
Develop web API, authentication, push
notification
Backend
12. Typical Steps We’ll Take
1 - 2 weeks later, you have a mobile backend
and accessible API
Congratulation
Backend
13. Typical Steps We’ll Take
Prepare mobile project & integrate libraries:
async HTTP client, JSON parser
Develop web API
2 - 3 days later, you’re ready to access the API
Frontend
14. 3 - 4 weeks later, you’re ready to
develop your mobile app features :)
which is OK, if you’re doing it for fun!
29. Typical Steps We’ll Take
Prepare mobile project & integrate libraries:
async HTTP client, JSON parser
Develop web API
2 - 3 days later, you’re ready to access the API
Frontend
32. //client is instance of MSClient
//assumed to sign-in with Twitter
client?.loginWithProvider("twitter", controller:self, animated:true)
{
//trailing closure for completion handler
(user, error) -> Void in
if user != nil {
//do something about it!
}
}
as easy as adding this code on iOS side
34. azure mobile preview enable YOUR_MOBILE_SERVICE_NAME Users
Opt-in for Users feature
Getting expanded data of signed in user, via call to
user.getIdentities()
Install Azure-CLI
Type command:
37. The case
Let’s say, upon successful sign-in (on client side), I
want to register signed-in users to a table
38. Adding server-side logic
On “Insert” operation of User table, add this script:
function insert(item, user, request) {
var usersTable = tables.getTable('User');
usersTable.where({
userId: user.userId,
}).read({
success: function(results) {
if (results.length == 0) {
insertNewUser(usersTable, user);
}
else {
console.log('User exists');
request.respond(statusCodes.OK, results[0]);
}
}
});
}
39. Cont…
function insertNewUser(theUserTable, theUser) {
theUser.getIdentities({
success: function (identities) {
if (identities.twitter) {
var newUser = { userId: theUser.userId};
if (identities.twitter.screen_name) {
newUser.username = identities.twitter.screen_name;
}
theUserTable.insert(newUser, {
success: function(newItem) {
request.respond(statusCodes.OK, newItem);
}
});
}
else {
console.log('Identities is not retrieved');
request.respond();
}
}
});
}
40. On client-side
Add this Swift code upon successful sign-in:
let userTable = client?.tableWithName("User")
userTable?.insert(["userId": user.userId]){
(item, error) in
if let err = error {
println("Error: " + err.description)
}
}