Coder Social home page Coder Social logo

backand-ionic-chat's Introduction

backand-ionic-chat

###A sample app in Ionic that demonstrates the Real Time feature in Backand

##Set up instructions:

1- To run starter, run ionic start on the repository:

ionic start backand-ionic-chat https://github.com/backand/backand-ionic-chat
cd backand-ionic-chat

2 - Run with ionic serve function

ionic serve

In order to run the app on another platform (Android/iOS):

cordova platform add <platform>
ionic run <platform>

##Setting up your own realtime Backand application

1 - Create a free personal application at backand.com

2 - Set the following Backand DB model:

[
  {
    "name": "users",
    "fields": {
      "email": {
        "type": "string"
      },
      "firstName": {
        "type": "string"
      },
      "lastName": {
        "type": "string"
      },
      "chats": {
        "object": "chats"
      }
    }
  },
  {
    "name": "chats",
    "fields": {
      "participants": {
        "collection": "users",
        "via": "chats"
      },
      "messages": {
        "collection": "messages",
        "via": "chat"
      },
      "name": {
        "type": "string"
      }
    }
  },
  {
    "name": "messages",
    "fields": {
      "message": {
        "type": "string"
      },
      "chat": {
        "object": "chats"
      }
    }
  }
]

3 - On the messages object, add a server side action that triggers after the create event. Call it SendMessage and use the following code:

'use strict';
function backandCallback(userInput, dbRow, parameters, userProfile) {
    socket.emitAll("send_message" + dbRow.chat, dbRow.message);
  return {};
}

4 - Modify the following code on www/js/app.js with your Backand app name, sign up token and anonymous token:

  BackandProvider.setAppName('Your-App-Name');
  
  BackandProvider.setSignUpToken('Your-SignUp-Token');
  
  BackandProvider.setAnonymousToken('Your-Anonymous-Token');

5 - Enjoy your custom Real Time app! You can add whatever functionality you want both to the client or the server!

For more info about Backand Real Time feature: http://docs.backand.com/en/latest/apidocs/realtime/index.html

backand-ionic-chat's People

Contributors

ktamir avatar itayher avatar

Watchers

 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.