-
-
Save ghae/3927649 to your computer and use it in GitHub Desktop.
Example of using sign up / log in methods of the Titanium SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geoloqi.init({ | |
clientId: "xxxxxxx", | |
clientSecret: "xxxxxxx", | |
trackingProfile: "OFF", // Don't automatically start tracking | |
allowAnonymousUsers:false, // Don't automatically create a user when starting up the first time | |
pushAccount: "example@gmail.com", // Sets the push account to use for Android notifications | |
pushIcon: "push_icon" // Also required for Android push notifications | |
}, { | |
onSuccess:function(e) { | |
if (geoloqi.session==null) { | |
// No saved session was found. The user most likely launched the app for the first time. | |
} | |
else { | |
// A saved session was found. The user most likely re-launched the app. | |
} | |
}, | |
onFailure:function(e) { | |
alert(e.error_description); | |
} | |
}); | |
var btnAutheticateUser=Ti.UI.createButton({ | |
title:'Log in', | |
top:5, | |
height:30, | |
width:200 | |
}); | |
btnAutheticateUser.addEventListener('click',function(){ | |
geoloqi.authenticateUser('username', 'p4ssword', { | |
onSuccess: function(e) { | |
if (geoloqi.session==null) { | |
alert("Error logging in"); | |
} | |
else { | |
alert("Logged in successfully"); | |
configurePushNotifications(); | |
} | |
}, | |
onFailure: function(e) { | |
alert(e); | |
} | |
}); | |
}); | |
var btnCreateUser=Ti.UI.createButton({ | |
title:'Register', | |
top:75, | |
height:30, | |
width:200 | |
}); | |
btnCreateUser.addEventListener('click',function(){ | |
geoloqi.createUser({ | |
username: "username", | |
password: "p4ssword" | |
}, { | |
onSuccess:function(e) { | |
if (geoloqi.session==null) { | |
alert("Error registering user"); | |
} | |
else { | |
alert("Registed successfuly"); | |
configurePushNotifications(); | |
} | |
}, | |
onFailure:function(e) { | |
alert(e); | |
} | |
}); | |
}); | |
function configurePushNotifications() { | |
Ti.Network.registerForPushNotifications({ | |
types:[ | |
Titanium.Network.NOTIFICATION_TYPE_ALERT | |
], | |
callback: function(data){ | |
geoloqi.iOS.handlePush(data); | |
}, | |
success:function(data){ | |
geoloqi.iOS.registerDeviceToken(data.deviceToken); | |
}, | |
error: function(data){ | |
Ti.API.error("Could Not Register For Push" + data.error + data.type); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment