Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/satishbabariya/chatter
Real time chat app written in Swift 4 using Firebase
https://github.com/satishbabariya/chatter
chat firebase firebase-auth firebase-authentication firebase-cloud-messaging firebase-database firebase-functions firebase-realtime-database firebase-storage ios swift4
Last synced: 27 days ago
JSON representation
Real time chat app written in Swift 4 using Firebase
- Host: GitHub
- URL: https://github.com/satishbabariya/chatter
- Owner: satishbabariya
- License: mit
- Created: 2017-10-21T12:46:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-23T04:43:34.000Z (over 4 years ago)
- Last Synced: 2024-11-06T13:00:25.741Z (about 2 months ago)
- Topics: chat, firebase, firebase-auth, firebase-authentication, firebase-cloud-messaging, firebase-database, firebase-functions, firebase-realtime-database, firebase-storage, ios, swift4
- Language: Swift
- Homepage:
- Size: 60.7 MB
- Stars: 30
- Watchers: 3
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chatter
Real time chat app written in Swift 4 using Firebase# Push Notifications using Cloud Functions
``` js
// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
admin.initializeApp();exports.notification = functions.database
.ref('conversations/{conversationsID}/{messageID}')
.onCreate((snapshot, context) => {
var sender = snapshot.val().sender;
var receiver = snapshot.val().receiver;
var content = '';if (snapshot.val().data.text) {
content = snapshot.val().data.text;
}const conversationsID = context.params.conversationsID;
const messageID = context.params.messageID;var topic = receiver.id;
// Notification details and Payload.
const payload = {
notification: {
title: sender.displayName,
body: content,
sound: 'default'
},
data: {
statusCode: '101',
senderID: sender.id,
senderName: sender.displayName,
receiverID: receiver.id,
receiverName: receiver.displayName,
conversationsID: conversationsID,
messageID: messageID,
content: content,
senderImage: sender.image,
receiverImage: receiver.image,
type: 'SINGLE'
}
};if (snapshot.val().data.photo) {
payload.data['image-url'] = snapshot.val().data.photo;
payload.data['mediaUrl'] = snapshot.val().data.photo;
}const options = {
priority: 'high',
timeToLive: 60 * 60 * 24
};if (snapshot.val().data.photo) {
options['content_available'] = true;
options['mutable_content'] = true;
}return admin.messaging().sendToTopic(topic, payload, options);
});```