From 0f3c0ae797c132b891e909a45575c74c780fa8ef Mon Sep 17 00:00:00 2001 From: Sosolidkk Date: Tue, 16 Apr 2019 00:16:25 -0300 Subject: [PATCH 1/2] Configurando os gradles para suportar o firestore. --- android/app/build.gradle | 2 + .../java/com/unichat/MainApplication.java | 2 + ios/Unichat.xcodeproj/project.pbxproj | 39 ++++--------------- ios/Unichat/Info.plist | 13 ------- 4 files changed, 12 insertions(+), 44 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 732800f..4bee7d3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -108,6 +108,7 @@ android { targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" + multiDexEnabled true } splits { abi { @@ -149,6 +150,7 @@ dependencies { // Firebase dependencys implementation 'com.google.firebase:firebase-core:16.0.8' implementation 'com.google.firebase:firebase-auth:16.2.1' + implementation "com.google.firebase:firebase-firestore:18.2.0" } diff --git a/android/app/src/main/java/com/unichat/MainApplication.java b/android/app/src/main/java/com/unichat/MainApplication.java index 6b83d9e..5af0d34 100644 --- a/android/app/src/main/java/com/unichat/MainApplication.java +++ b/android/app/src/main/java/com/unichat/MainApplication.java @@ -12,6 +12,7 @@ import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import io.invertase.firebase.auth.RNFirebaseAuthPackage; +import io.invertase.firebase.firestore.RNFirebaseFirestorePackage; import java.util.Arrays; import java.util.List; @@ -31,6 +32,7 @@ protected List getPackages() { new VectorIconsPackage(), new RNFirebasePackage(), new RNFirebaseAuthPackage(), + new RNFirebaseFirestorePackage(), new SvgPackage(), new RNGestureHandlerPackage() ); diff --git a/ios/Unichat.xcodeproj/project.pbxproj b/ios/Unichat.xcodeproj/project.pbxproj index 7266df3..64dc550 100644 --- a/ios/Unichat.xcodeproj/project.pbxproj +++ b/ios/Unichat.xcodeproj/project.pbxproj @@ -5,7 +5,6 @@ }; objectVersion = 46; objects = { - /* Begin PBXBuildFile section */ 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; @@ -49,10 +48,6 @@ C013733819F7492F86B74383 /* libRNGestureHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45942EDDB6694B7DB6AA2C1D /* libRNGestureHandler.a */; }; ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; }; ED2971652150620600B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2971642150620600B7C4FE /* JavaScriptCore.framework */; }; - C013733819F7492F86B74383 /* libRNGestureHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45942EDDB6694B7DB6AA2C1D /* libRNGestureHandler.a */; }; - 10753C3822CF4FE4BEB06127 /* libRNGestureHandler-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A9F8B20505004B98AB5B69AD /* libRNGestureHandler-tvOS.a */; }; - 45E4BC3E1782480491763649 /* libRNSVG.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AF667A9D70174E29A65F940D /* libRNSVG.a */; }; - 225AEA423375468C87A08975 /* libRNSVG-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 05F0EE6956C94A88B15D6F4F /* libRNSVG-tvOS.a */; }; 98426CE8528843B3B8777FDD /* libRNVectorIcons.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61D42B04BA224B598D26DB27 /* libRNVectorIcons.a */; }; 2F3E060758724E6EB5A4C421 /* libRNVectorIcons-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA522D07EF54A05812A4141 /* libRNVectorIcons-tvOS.a */; }; 08A4607A7CC94D0E87DC6BCB /* AntDesign.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0C7965D511774E7797FC14C5 /* AntDesign.ttf */; }; @@ -394,10 +389,10 @@ 00E356EE1AD99517003FC87E /* UnichatTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnichatTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 00E356F21AD99517003FC87E /* UnichatTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UnichatTests.m; sourceTree = ""; }; - 05F0EE6956C94A88B15D6F4F /* libRNSVG-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNSVG-tvOS.a"; sourceTree = ""; }; + 05F0EE6956C94A88B15D6F4F /* libRNSVG-tvOS.a */ = {isa = PBXFileReference; name = "libRNSVG-tvOS.a"; path = "libRNSVG-tvOS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; 0C9A24945A99882FB907FF48 /* Pods-Unichat-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Unichat-tvOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Unichat-tvOS/Pods-Unichat-tvOS.release.xcconfig"; sourceTree = ""; }; 1145456E31D8568778C55A3E /* Pods-Unichat-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Unichat-tvOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Unichat-tvOSTests/Pods-Unichat-tvOSTests.release.xcconfig"; sourceTree = ""; }; - 125C0030F7A245F79AAA4BD5 /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNGestureHandler.xcodeproj; path = "../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj"; sourceTree = ""; }; + 125C0030F7A245F79AAA4BD5 /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; name = "RNGestureHandler.xcodeproj"; path = "../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* Unichat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Unichat.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -413,7 +408,7 @@ 2D16E6891FA4F8E400B85C8A /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; }; 390956931BD045F69AC6ED08 /* libRNFirebase.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFirebase.a; sourceTree = ""; }; 3CE7A60A6AEF966A662DAF13 /* libPods-Unichat.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Unichat.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 45942EDDB6694B7DB6AA2C1D /* libRNGestureHandler.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNGestureHandler.a; sourceTree = ""; }; + 45942EDDB6694B7DB6AA2C1D /* libRNGestureHandler.a */ = {isa = PBXFileReference; name = "libRNGestureHandler.a"; path = "libRNGestureHandler.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; 4AF20528DA8344300BB7D52F /* Pods-Unichat.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Unichat.release.xcconfig"; path = "Pods/Target Support Files/Pods-Unichat/Pods-Unichat.release.xcconfig"; sourceTree = ""; }; 528A391FBE3DD9745B8ECF33 /* Pods-UnichatTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnichatTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-UnichatTests/Pods-UnichatTests.release.xcconfig"; sourceTree = ""; }; 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; @@ -423,22 +418,16 @@ 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 889ED91ED8CF4BB8B092167B /* RNFirebase.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFirebase.xcodeproj; path = "../node_modules/react-native-firebase/ios/RNFirebase.xcodeproj"; sourceTree = ""; }; 908EAEDC4B7505F0F558C566 /* Pods-Unichat-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Unichat-tvOSTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Unichat-tvOSTests/Pods-Unichat-tvOSTests.debug.xcconfig"; sourceTree = ""; }; - A3AD7F7807AB44AD87BFC4A5 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSVG.xcodeproj; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = ""; }; + A3AD7F7807AB44AD87BFC4A5 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; name = "RNSVG.xcodeproj"; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; A612E35522613E5B0023868C /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; - A9F8B20505004B98AB5B69AD /* libRNGestureHandler-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNGestureHandler-tvOS.a"; sourceTree = ""; }; + A9F8B20505004B98AB5B69AD /* libRNGestureHandler-tvOS.a */ = {isa = PBXFileReference; name = "libRNGestureHandler-tvOS.a"; path = "libRNGestureHandler-tvOS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = ""; }; - AF667A9D70174E29A65F940D /* libRNSVG.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNSVG.a; sourceTree = ""; }; + AF667A9D70174E29A65F940D /* libRNSVG.a */ = {isa = PBXFileReference; name = "libRNSVG.a"; path = "libRNSVG.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; B5805629F54E83D532E08063 /* libPods-Unichat-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Unichat-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; C0FB19EA484E5E46D1E3D8C8 /* Pods-Unichat-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Unichat-tvOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Unichat-tvOS/Pods-Unichat-tvOS.debug.xcconfig"; sourceTree = ""; }; EB982DD01FD60BAA3C457899 /* libPods-Unichat-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Unichat-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; - 125C0030F7A245F79AAA4BD5 /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; name = "RNGestureHandler.xcodeproj"; path = "../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; - 45942EDDB6694B7DB6AA2C1D /* libRNGestureHandler.a */ = {isa = PBXFileReference; name = "libRNGestureHandler.a"; path = "libRNGestureHandler.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; - A9F8B20505004B98AB5B69AD /* libRNGestureHandler-tvOS.a */ = {isa = PBXFileReference; name = "libRNGestureHandler-tvOS.a"; path = "libRNGestureHandler-tvOS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; - A3AD7F7807AB44AD87BFC4A5 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; name = "RNSVG.xcodeproj"; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; - AF667A9D70174E29A65F940D /* libRNSVG.a */ = {isa = PBXFileReference; name = "libRNSVG.a"; path = "libRNSVG.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; - 05F0EE6956C94A88B15D6F4F /* libRNSVG-tvOS.a */ = {isa = PBXFileReference; name = "libRNSVG-tvOS.a"; path = "libRNSVG-tvOS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; C50B483D1A264B288825440A /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; name = "RNVectorIcons.xcodeproj"; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 61D42B04BA224B598D26DB27 /* libRNVectorIcons.a */ = {isa = PBXFileReference; name = "libRNVectorIcons.a"; path = "libRNVectorIcons.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; EAA522D07EF54A05812A4141 /* libRNVectorIcons-tvOS.a */ = {isa = PBXFileReference; name = "libRNVectorIcons-tvOS.a"; path = "libRNVectorIcons-tvOS.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; @@ -1739,7 +1728,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", - "$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**", + "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", ); INFOPLIST_FILE = Unichat/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1751,12 +1740,6 @@ PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.Unichat; PRODUCT_NAME = Unichat; VERSIONING_SYSTEM = "apple-generic"; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", - "$(SRCROOT)/../node_modules/react-native-svg/ios/**", - "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", - ); }; name = Debug; }; @@ -1770,7 +1753,7 @@ "$(inherited)", "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", - "$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/**", + "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", ); INFOPLIST_FILE = Unichat/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1782,12 +1765,6 @@ PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.Unichat; PRODUCT_NAME = Unichat; VERSIONING_SYSTEM = "apple-generic"; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", - "$(SRCROOT)/../node_modules/react-native-svg/ios/**", - "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager", - ); }; name = Release; }; diff --git a/ios/Unichat/Info.plist b/ios/Unichat/Info.plist index e55dba1..84ff41f 100644 --- a/ios/Unichat/Info.plist +++ b/ios/Unichat/Info.plist @@ -53,19 +53,6 @@ UIViewControllerBasedStatusBarAppearance - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSExceptionDomains - - localhost - - NSExceptionAllowsInsecureHTTPLoads - - - - UIAppFonts AntDesign.ttf From d3163d76db46c69760165f3724d721387312810b Mon Sep 17 00:00:00 2001 From: Sosolidkk Date: Tue, 16 Apr 2019 02:52:40 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Adicionado=20trecho=20do=20c=C3=B3digo=20te?= =?UTF-8?q?mpor=C3=A1rio=20que=20ir=C3=A1=20salvar=20uma=20mensagem=20no?= =?UTF-8?q?=20firestore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Components/MessageInput.js | 2 +- src/Screens/Conversas/conversas.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Components/MessageInput.js b/src/Components/MessageInput.js index 9fa2c6f..ba4ec37 100644 --- a/src/Components/MessageInput.js +++ b/src/Components/MessageInput.js @@ -47,7 +47,7 @@ const styles = StyleSheet.create({ alignContent: "center", justifyContent: "center", top: 5, - right: 10, + right: 1, width: 30, height: 30, borderRadius: 30 / 2, diff --git a/src/Screens/Conversas/conversas.js b/src/Screens/Conversas/conversas.js index 90fa723..d54c08d 100644 --- a/src/Screens/Conversas/conversas.js +++ b/src/Screens/Conversas/conversas.js @@ -5,6 +5,7 @@ import { View, StyleSheet, Dimensions, StatusBar, Text } from "react-native" import { Avatar, Icon } from "react-native-elements" import { ScrollView } from "react-native-gesture-handler" import shortid from "shortid" +import firebase from "react-native-firebase" import MessageInput from "../../Components/MessageInput" import Message from "../../Components/mensagem" @@ -19,6 +20,8 @@ export default class Conversas extends Component { messageText: "", messages: [] } + // This line right here needs to be changed later + this.ref = firebase.firestore().collection("Messages") } onChangeHandler = text => { @@ -59,6 +62,13 @@ export default class Conversas extends Component { date: hour, source: "1" } + + this.ref.add({ + content: newMessage.content, + date: newMessage.date, + source: newMessage.source + }).then(() => true).catch(error => error) + this.setState({ messages: [...messages, newMessage] }) this.setState({ messageText: "" }) }