GithubHelp home page GithubHelp logo

firebase-titanium's Introduction

Firebase iOS Module for Titanium

Native iOS Module for using Firebase with Titanium apps.

Compatibility

Module has been tested with the following versions of the Titanium SDK:

  • Titanium 3.2.1
  • Titanium 3.3.0

Installation

Documentation

This module is constructed to mimic the official Firebase JavaScript Library. All functions available with the official library are also available on this module. All methods take the same arguments and return the same values where applicable.

The only difference is the syntax for creating a new Firebase reference.

var Firebase = require('com.leftlanelab.firebase');

// WRONG: Official Firebase JavaScript library method
var firebaseReference = new Firebase('https://l3-appcelerator-demo.firebaseio.com/users');

// CORRECT: Method to use with this module
var firebaseReference = Firebase.new('https://l3-appcelerator-demo.firebaseio.com/users');

// CORRECT: ... when com.leftlanelab.firebase.forge is set in tiapp.xml
var firebaseReference = Firebase.new('/users');

Tutorials

Traverse a Firebase location, and write some data.

var Firebase = require('com.leftlanelab.firebase');

var sampleChatRef = Firebase.new('https://l3-appcelerator-demo.firebaseio.com');
var fredNameRef = sampleChatRef.child('users/fred/name');
fredNameRef.set({first: 'Fred', last: 'Flintstone'});

Now read the data back (and get notified whenever it changes).

fredNameRef.on('value', function (nameSnapshot) {
  var y = nameSnapshot.val();
  // y now contains the object { first: 'Fred', last: 'Flintstone' }.
});

Let's add a new chat message child to the message_list location.

var messageListRef = sampleChatRef.child('message_list');
messageListRef.push({'user_id': 'fred', 'text': 'Yabba Dabba Doo!'});

And let's listen for new children added to the message_list location. We'll be notified of our 'Yabba Dabba Doo!' message as well as any other messages that were added in the past, and any new messages that get added in the future.

messageListRef.on('child_added', function(newMessageSnapshot) {
  var userId = newMessageSnapshot.child('user_id').val();
  var text = newMessageSnapshot.child('text').val();
  // Do something with user_id and text.
});

Global Properties (tiapp.xml)

Global configuration options can be defined in the tiapp.xml file.

NOTE: These are optional

Properties

  • forge : base value for new Firebase references. This value can always be overridden by specifying an absolute URL when calling Firebase.new( ).
  • persistence : Enables the Firebase iOS Disk Persistence feature (default: false)

Usage

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
  ...
  <property name="com.leftlanelab.firebase.forge" type="string">https://l3-appcelerator-demo.firebaseio.com/</property>
  <property name="com.leftlanelab.firebase.persistence" type="bool">true</property>
  ...
</ti:app>

firebase-titanium's People

Contributors

thevinchi avatar

Watchers

Navid Nikpour avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.