Titanium Dreamfactory tuto or example


#1

Hi there
I’m looking for documentation, spare code, example app on titanium intégration with DreamFactory
i’m starting with titanium, and i’m a little bit lost …
does someone can help me ?

best regards,

julien


#2

I recommend downloading and playing with our Titanium SDK.

It includes basic DSP API interaction as well as a sample app.


#3

hi jeffrestables
i’ve already play with the sdk
but i cannot find the sample app?
thanks


#4

If you have not already, you may import the Todo List sample app on the Apps tab of your DSP by clicking “Import” and selecting the appropriate sample application.


#5

sure, but i’m looking for a Titanium app sample


#6

Well, if no one else in the community responds with an example for you, please do post back with the one you end up writing so that others may benefit.


#7

Hi
please find below a login windows (tested & approved)

regards,


var win = Titanium.UI.currentWindow;
 
var username = Titanium.UI.createTextField({
    color:'#336699',
    top:10,
    left:10,
    width:300,
    height:40,
    hintText:'Username',
    keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
    returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
    borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(username);
 
var password2 = Titanium.UI.createTextField({
    color:'#336699',
    top:60,
    left:10,
    width:300,
    height:40,
    hintText:'Password',
    passwordMask:true,
    keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
    returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
    borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(password2);
 
var loginBtn = Titanium.UI.createButton({
    title:'Login',
    top:110,
    width:90,
    height:35,
    borderRadius:1,
    font:{fontFamily:'Arial',fontWeight:'bold',fontSize:14}
});
win.add(loginBtn);

/*
* Login Button Click Event
*/

 
loginBtn.addEventListener('click',function(e)
{
    var Promise = require('Promise');
   		var dreamfactory = require('dreamfactory');
    		var bodydb = {email: username.value , password: password2.value};
        	bodydb = JSON.stringify(bodydb);
        	dreamfactory.makeRequest("post","/user/session", bodydb).then(function(response) {
            	SESSION_ID = response.session_id;
            	Ti.API.info("login succes session id " + SESSION_ID);
            	Ti.App.fireEvent('grantEntrance', {
        		name:response.first_name,
        		email:response.email
       			});
            	
        	}, function (error) {
            	Ti.API.info("erreur" + bodydb);
            	alert("error" );
       		});

});

#8

That’s awesome, @jeebee! I hope you don’t mind, I’ve edited your post a bit to provide a little better formatting on the code.