Ionic Backand Chat

Ionic Backand Chat

Cool chat with Backand Real Time

$0.00

Tamir Kfir

Tamir Kfir

Member since 2016

Details

Version:
1.1
Ionic:
1.x  
Platforms:
iOS, Android  
Released:
5 years ago
Updated:
4 years ago
Category:
Starters
Tags:
Backand, Chat, backend, database, BAAS,

Leveraging Backand, this super-easy Ionic chat provides a boatload of functionality including real-time communication and a database API.

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 - Install Backand

bower install socket.io-client#1.4.5 bower install backand-angular1-sdk

3 - 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 app

1 - Create a free personal app 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