Use the Parse & Parse Live Query iOS and Android SDK's in Axway Titanium! Read more about the Parse Live Query API in the official native repositories:
- iOS: https://github.com/parse-community/ParseLiveQuery-iOS-OSX
- Android: https://github.com/parse-community/ParseLiveQuery-Android
Warning: While iOS is ready for production, Android is highly dependent on community contributions. Submit a pull request to expose new features, e.g. query subscriptions.
- Titanium SDK 12.0.0+
If you use this module together with Ti.Facebook, you need to remove the Bolts.framework from
<project>/modules/iphone/ti.facebook/<version>/platform/Bolts.framework
since it is already bundled with Ti.LiveQuery. Remember: In case you remove Ti.LiveQuery, put the framework back in our replace it with a fresh module version that contains the framework.
No additional setup required.
Add the following to the <android> manifest section of the tiapp.xml:
<application ...>
...
<meta-data android:name="com.parse.SERVER_URL" android:value="YOUR_SERVER_URL" />
<meta-data android:name="com.parse.APPLICATION_ID" android:value="YOUR_APP_ID" />
</application>applicationId(String)clientKey(String)server(String)localDatastoreEnabled(Boolean)
applicationId(String)clientKey(String)server(String)
className(String)parameters(Dictionary)callback(Function)
sessionToken(String)callback(Function - optional)
query(Query)
query(Query)
query(Query)
query(Query)
eventType(EVENT_TYPE_*)object(Object)query(Query)
error(String)query(Query)
className(String)predicate(String, optional, e.g.name = "hans")predicateArguments(String, optional, e.g.myUsers)
Note: When using predicateArguments, you write a template based placeholder inside the predicate parameter
and fill it with the arguments passed in predicateArguments, e.g.
var query = LiveQuery.createQuery({
className: 'User',
predicate: 'userId in %@'
predicateArguments: users // an array of users
});
Note: If you use predicates, you may constraint your query for additional where clauses.
key(String)array(Array)
key(String)array(Array)
key(String)array(Array)
key(String)object(Any)
key(String)object(Any)
key(String)object(Any)
key(String)object(Any)
key(String)object(Any)
key(String)object(Any)
key(String)
key(String)
keys(Array)
keys(Array)
key(String)
key(String)
callback(Function)
username: The unique username of the user.password: The unique password of the user.email: The email address of the user.callback: The callback to be invoked if the user has been created (success: true) or if something went wrong (success: false, error: xxx)
username: The unique username of the user.password: The unique password of the user.callback: The callback to be invoked if the user has been logged in (success: true, sessionToken: xxx) or if something went wrong (success: false, error: xxx)
callback: The callback to be invoked if the user has been logged out (success: true) or if something went wrong (success: false, error: xxx)
If a callback function is used, it will be called asynchronous. Otherwise, it returns a synchronous boolean indicating if it was completed successfully or not.
If a callback function is used, it will be called asynchronous. Otherwise, it returns a synchronous boolean indicating if it was completed successfully or not.
The callback is optional.
The callback is optional.
The callback is optional.
The callback is optional.
The callback is optional.
This project uses the following Swift dependencies:
- Bolts
- BoltsSwift
- Parse
- ParseLiveQuery
- Starscream
Use Carthage to refresh the bundled frameworks:
cd ios
XCODE_XCCONFIG_FILE=$(pwd)/carthage.xcconfig carthage bootstrap --platform iOS --use-xcframeworksOnce the build completes, copy the updated .xcframework directories from ios/Carthage/Build/ into ios/platform/, replacing the existing frameworks.
Note: Parse.framework already embeds Bolts; we ship only headers under platform/BoltsHeaders.
After running carthage bootstrap, copy the latest Bolts-ObjC Bolts/*.h files
into platform/BoltsHeaders/include/Bolts to keep the module shim in sync.
var ParseLiveQuery = require("ti.livequery");
var win = Ti.UI.createWindow({
backgroundColor: "#fff",
});
var btn1 = Ti.UI.createButton({
title: "Initialize Parse",
top: 100,
});
var btn2 = Ti.UI.createButton({
title: "Subscribe",
top: 200,
});
btn1.addEventListener("click", function () {
ParseLiveQuery.initialize({
applicationId: "",
clientKey: "",
server: "",
});
});
// iOS only
btn2.addEventListener("click", function () {
var client = ParseLiveQuery.createClient({
applicationId: "",
clientKey: "",
server: "",
});
client.addEventListener("subscribe", function (e) {
Ti.API.info("Subscribed!");
// Subscribed
});
client.addEventListener("unsubscribe", function (e) {
Ti.API.info("Unsubscribed!");
// Unsubscribed
});
client.addEventListener("event", function (e) {
Ti.API.info("Event!");
printObject(e.object);
// Event received, check with e.type
});
client.addEventListener("error", function (e) {
Ti.API.info("Error!");
Ti.API.info(e.error);
// Error received, check with e.error
});
var query = ParseLiveQuery.createQuery({
className: "Posts",
predicate: 'name = "Hans"',
});
client.subscribeToQuery(query);
// Get existing objects
query.findObjectsInBackground(function (e) {
Ti.API.info(e);
var objects = e.objects;
for (var i = 0; i < objects.length; i++) {
printObject(objects[i]);
}
});
});
// Utility method to print objects by using "objectForKey"
function printObject(object) {
var allKeys = object.allKeys;
for (var i = 0; i < allKeys.length; i++) {
var key = allKeys[i];
var value = object.objectForKey(key);
Ti.API.info(key + " = " + value);
}
}
win.add(btn1);
win.add(btn2);
win.open();Hans Knöchel (@hansemannnn / Web)
Apache 2.0
Code contributions are greatly appreciated, please submit a new Pull-Request!