This is a Titanium JavaScript module that lets a Titanium app communicate with a deployd backend.
- You'll need deployd installed first.
- You'll need Appcelerator Titanium installed, as well as either the iOS or Android SDK.
Make sure your deployd app is running, and has a resource to communicate with. Also make sure your app has dpd.js available (from Resources/dpd.js)
// Init deployd module and create an object in a collection.
dpd = require('dpd');
dpd.init({root:'http://localhost:2403'});
dpd('collectionName').post({"title":"I <3 deployd"}, function (res, err){
if (err) Ti.API.error(err);
Ti.API.debug('Object created'+JSON.stringify(res));
});
// Get an object from a collection
dpd('collectionName').get({"comments":{"$gte":5}}, fn);
// Update an object in a collection
dpd('collectionName').put("1a2b3c", {"title": "New Title"}, fn);
// Delete an object in a collection
dpd('collectionName').del("1a2b3c", fn)
// Execute an arbitrary function, such as login.
dpd('users').exec('login', {"username":"jeffbcross", "password":"cats"}, fn);
The dpd object mostly implements the same API as described in the deployd docs, the main difference being that all resources have to be accessed by calling the dpd('resourceName')
function with the Resource name, instead of the standard dpd['resourceName']
convention.
dpd('collection').post({"title": "Test post"}, fn);
- Create a new Titanium project, and swap the Resources directory with the included Resources directory.
- Start the deployd app from Terminal/Command Prompt, and open your dashboard.
cd /deploydapp
dpd -d
- From Titanium Studio, run the project in iOS simulator.
- Watch the test output in the app's main window.
- Implement socket.io
- Implement login methods
- Make a login window?