Skip to content

Instantly share code, notes, and snippets.

View warodri-sendbird's full-sized avatar

Walter Rodriguez warodri-sendbird

View GitHub Profile
@warodri-sendbird
warodri-sendbird / request-body.json
Last active February 9, 2021 09:29
sendbird-webhooks
{
"category": "group_channel:message_send",
"custom_type": "",
"mention_type": "users",
"mentioned_users": [],
"app_id": "-",
"members": [
{
"unread_message_count": 234,
"total_unread_message_count": 234,
@warodri-sendbird
warodri-sendbird / send-message.js
Created February 16, 2021 12:21
sendbird-basics
‎‎​
@warodri-sendbird
warodri-sendbird / package.json
Created February 17, 2021 12:53
webhooks-nodejs-sendbird-signature
{
"name": "webhooks",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "nodemon server.js"
},
"keywords": [],
"author": "",
createMessageItem(message, isCurrentUser, isContinue, unreadCount) {
var messageSet = this.createDiv();
messageSet.id = message.messageId;
this._setClass(messageSet, isCurrentUser ? [className.MESSAGE_SET, className.USER] : [className.MESSAGE_SET]);
if (isContinue) {
messageSet.style.cssText += `margin-top: ${MARGIN_TOP_MESSAGE}`;
}
var senderImg = this.createDiv();
this._setClass(senderImg, [className.IMAGE]);
/**
* @format
*/
import {AppRegistry, Platform} from 'react-native';
import messaging from '@react-native-firebase/messaging';
import App from './App';
import {name as appName} from './app.json';
import { onRemoteMessage } from './src/utils';
@warodri-sendbird
warodri-sendbird / index.js
Created September 2, 2021 14:42
Main file
/**
* @format
*/
import {AppRegistry, Platform} from 'react-native';
import messaging from '@react-native-firebase/messaging';
import App from './App';
import {name as appName} from './app.json';
import { onRemoteMessage } from './src/utils';
useEffect(() => {
AsyncStorage.getItem(savedUserKey)
.then(async user => {
try {
if (user) {
const authorizationStatus = await messaging().requestPermission();
if (
authorizationStatus === messaging.AuthorizationStatus.AUTHORIZED ||
authorizationStatus === messaging.AuthorizationStatus.PROVISIONAL
) {
return (
<NavigationContainer>
<AppContext.Provider value={initialState}>
<Stack.Navigator>
<Stack.Screen name="Lobby" component={Lobby} options={{ ...defaultHeaderOptions }} />
<Stack.Screen name="Chat" component={Chat} options={{ ...defaultHeaderOptions }} />
<Stack.Screen name="Member" component={Member} options={{ ...defaultHeaderOptions }} />
<Stack.Screen name="Invite" component={Invite} options={{ ...defaultHeaderOptions }} />
<Stack.Screen name="Profile" component={Profile} options={{ ...defaultHeaderOptions }} />
</Stack.Navigator>
useEffect(() => {
AsyncStorage.getItem(savedUserKey)
.then(user => {
if (user) {
setCurrentUser(JSON.parse(user));
}
setInitialized(true);
return handleNotificationAction(navigation, sendbird, currentUser, 'lobby');
})
.catch(err => console.error(err));
return (
<>
{initialized ? (
currentUser ? (
<Channels {...props} currentUser={currentUser} />
) : (
<Login {...props} onLogin={login} />
)
) : (
<View />