├── .gitignore
├── LICENSE
├── Podfile
├── README.md
├── firechat.gif
├── messagingapp.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── Nishita.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── Nishita.xcuserdatad
│ └── xcschemes
│ │ ├── messagingapp.xcscheme
│ │ └── xcschememanagement.plist
│ └── nilesh.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
├── messagingapp.xcworkspace
├── contents.xcworkspacedata
├── xcshareddata
│ └── IDEWorkspaceChecks.plist
└── xcuserdata
│ ├── Nishita.xcuserdatad
│ ├── UserInterfaceState.xcuserstate
│ └── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ └── nilesh.xcuserdatad
│ └── UserInterfaceState.xcuserstate
└── messagingapp
├── DefaultResources
├── .gitignore
├── Assets.xcassets
│ ├── .DS_Store
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── icon-20.png
│ │ ├── icon-40.png
│ │ ├── icon-40@2x-1.png
│ │ ├── icon-40@2x-2.png
│ │ ├── icon-40@2x.png
│ │ ├── icon-40@3x-1.png
│ │ ├── icon-40@3x.png
│ │ ├── icon-41.png
│ │ ├── icon-60@2x.png
│ │ ├── icon-60@3x.png
│ │ ├── icon-76.png
│ │ ├── icon-76@2x.png
│ │ ├── icon-83.5@2x.png
│ │ ├── icon-small.png
│ │ ├── icon-small@2x-1.png
│ │ ├── icon-small@2x.png
│ │ ├── icon-small@3x.png
│ │ └── icon.png
│ ├── Chat.imageset
│ │ ├── Contents.json
│ │ ├── chat copy 2.png
│ │ ├── chat copy.png
│ │ └── chat.png
│ ├── Check.imageset
│ │ ├── Contents.json
│ │ ├── selectUserWallet@2x.png
│ │ └── selectUserWallet@3x.png
│ ├── Contact.imageset
│ │ ├── Contents.json
│ │ └── add-contact.png
│ ├── Contents.json
│ ├── Edit.imageset
│ │ ├── Contents.json
│ │ └── pencil-edit-button.png
│ ├── Group.imageset
│ │ ├── Contents.json
│ │ ├── group.png
│ │ └── group1.png
│ ├── Home.imageset
│ │ ├── Contents.json
│ │ ├── home-icon-1.png
│ │ ├── home-icon-2.png
│ │ └── home-icon.png
│ ├── Logout.imageset
│ │ ├── Contents.json
│ │ ├── logout-1.png
│ │ ├── logout-2.png
│ │ └── logout.png
│ ├── Profile.imageset
│ │ ├── Contents.json
│ │ ├── profilePIc 2.png
│ │ ├── profilePIc 3.png
│ │ └── profilePIc.png
│ ├── SideMenu.imageset
│ │ ├── Contents.json
│ │ └── menu-button.png
│ ├── Splash.imageset
│ │ ├── Contents.json
│ │ ├── Default736h@2x.png
│ │ └── Default736h@3x.png
│ ├── Uncheck.imageset
│ │ ├── CircleWithShadow@2x.png
│ │ ├── CircleWithShadow@3x.png
│ │ └── Contents.json
│ └── User.imageset
│ │ ├── Contents.json
│ │ └── man-user.png
├── Info.plist
├── LaunchScreen.storyboard
├── Main.storyboard
└── messagingapp.xcdatamodeld
│ ├── .xccurrentversion
│ └── messagingapp.xcdatamodel
│ └── contents
├── Home
├── AppDelegate.swift
└── Constant.swift
├── ViewController
├── LoginAndRegistration
│ ├── LoginVC.swift
│ ├── SignUpSB.storyboard
│ ├── SignUpVC.swift
│ ├── SplashScreenSB.storyboard
│ └── SplashScreenVC.swift
└── SideMenu
│ ├── Home
│ ├── ChatSB.storyboard
│ ├── ChatVC.swift
│ ├── ContactSB.storyboard
│ ├── ContactVC.swift
│ ├── CustomCell
│ │ ├── Chat2TableViewCell.swift
│ │ ├── ChatTableViewCell.swift
│ │ ├── ContactCell.swift
│ │ ├── GroupListCell.swift
│ │ ├── HomeSideVcCell.swift
│ │ ├── HomeTableViewCell.swift
│ │ └── ProfileCell.swift
│ ├── CustomClass
│ │ └── CustomLabelVC.swift
│ ├── GroupMenuSB.storyboard
│ ├── GroupMenuVC.swift
│ ├── HomeSB.storyboard
│ ├── HomeSideSB.storyboard
│ ├── HomeSideVC.swift
│ ├── HomeVC.swift
│ ├── ProfileDetailSB.storyboard
│ ├── ProfileDetailVC.swift
│ ├── ProfileSB.storyboard
│ └── ProfileVC.swift
│ └── SSB-Bridging-Header.h
└── messagingapp.entitlements
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | ## Playgrounds
32 | timeline.xctimeline
33 | playground.xcworkspace
34 |
35 | # Swift Package Manager
36 | #
37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38 | # Packages/
39 | # Package.pins
40 | # Package.resolved
41 | .build/
42 |
43 | # CocoaPods
44 | #
45 | # We recommend against adding the Pods directory to your .gitignore. However
46 | # you should judge for yourself, the pros and cons are mentioned at:
47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
48 | #
49 | Pods/
50 | Blog
51 | # Carthage
52 | #
53 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
54 | # Carthage/Checkouts
55 |
56 | Carthage/Build
57 |
58 | # fastlane
59 | #
60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
61 | # screenshots whenever they are needed.
62 | # For more information about the recommended setup visit:
63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
64 |
65 | fastlane/report.xml
66 | fastlane/Preview.html
67 | fastlane/screenshots/**/*.png
68 | fastlane/test_output
69 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Logistic Infotech Pvt. Ltd.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment the next line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | target 'messagingapp' do
5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
6 | use_frameworks!
7 |
8 | # Pods for messagingapp
9 |
10 | pod ‘Firebase/Core’
11 | pod ‘Firebase/Database’
12 | pod 'Firebase/Auth'
13 | pod ‘Firebase/Storage’
14 | pod 'Firebase/Messaging'
15 | pod 'MFSideMenu'
16 | pod ‘SDWebImage’
17 | pod 'FBSDKLoginKit'
18 | pod 'FacebookCore'
19 | pod 'FacebookLogin'
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | # firebase-swift-simple-chat
6 | 
7 |
8 | Now a day trend for real time communication gets increased, web socket brings change to messaging apps development for real time communication and instant messaging. Firebase is pride great way for real-time chat using PubSub method. Here you will learn how to integrate iOS client app with firebase for real time communication. It’s easy to use and store the data in firebase real time database.
9 |
10 | [Here](https://www.logisticinfotech.com/blog/real-time-chat-application-with-firebase/) you will find step by step detail desrcription how to integrate firebase and accompish chat app.
11 |
--------------------------------------------------------------------------------
/firechat.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/firechat.gif
--------------------------------------------------------------------------------
/messagingapp.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/messagingapp.xcodeproj/project.xcworkspace/xcuserdata/Nishita.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp.xcodeproj/project.xcworkspace/xcuserdata/Nishita.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/messagingapp.xcodeproj/xcuserdata/Nishita.xcuserdatad/xcschemes/messagingapp.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/messagingapp.xcodeproj/xcuserdata/Nishita.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | messagingapp.xcscheme
8 |
9 | orderHint
10 | 5
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 611E5D3F20C00F3D0065C55A
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/messagingapp.xcodeproj/xcuserdata/nilesh.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | messagingapp.xcscheme
8 |
9 | orderHint
10 | 1
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/messagingapp.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/messagingapp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/messagingapp.xcworkspace/xcuserdata/Nishita.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp.xcworkspace/xcuserdata/Nishita.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/messagingapp.xcworkspace/xcuserdata/Nishita.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
18 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/messagingapp.xcworkspace/xcuserdata/nilesh.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp.xcworkspace/xcuserdata/nilesh.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | GoogleService-Info
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/.DS_Store
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "icon-40@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "icon-40@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "icon-small@2x.png",
19 | "scale" : "2x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "icon-small@3x.png",
25 | "scale" : "3x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "icon-40@2x-1.png",
31 | "scale" : "2x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "icon-40@3x-1.png",
37 | "scale" : "3x"
38 | },
39 | {
40 | "size" : "60x60",
41 | "idiom" : "iphone",
42 | "filename" : "icon-60@2x.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "icon-60@3x.png",
49 | "scale" : "3x"
50 | },
51 | {
52 | "size" : "20x20",
53 | "idiom" : "ipad",
54 | "filename" : "icon-20.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "icon-40.png",
61 | "scale" : "2x"
62 | },
63 | {
64 | "size" : "29x29",
65 | "idiom" : "ipad",
66 | "filename" : "icon-small.png",
67 | "scale" : "1x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "icon-small@2x-1.png",
73 | "scale" : "2x"
74 | },
75 | {
76 | "size" : "40x40",
77 | "idiom" : "ipad",
78 | "filename" : "icon-41.png",
79 | "scale" : "1x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "icon-40@2x-2.png",
85 | "scale" : "2x"
86 | },
87 | {
88 | "size" : "76x76",
89 | "idiom" : "ipad",
90 | "filename" : "icon-76.png",
91 | "scale" : "1x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "icon-76@2x.png",
97 | "scale" : "2x"
98 | },
99 | {
100 | "size" : "83.5x83.5",
101 | "idiom" : "ipad",
102 | "filename" : "icon-83.5@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "1024x1024",
107 | "idiom" : "ios-marketing",
108 | "filename" : "icon.png",
109 | "scale" : "1x"
110 | }
111 | ],
112 | "info" : {
113 | "version" : 1,
114 | "author" : "xcode"
115 | }
116 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-20.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@2x-1.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@2x-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@2x-2.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@3x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@3x-1.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-41.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-41.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-76.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small@2x-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small@2x-1.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/AppIcon.appiconset/icon.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Chat.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "chat.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "chat copy.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "chat copy 2.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Chat.imageset/chat copy 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Chat.imageset/chat copy 2.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Chat.imageset/chat copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Chat.imageset/chat copy.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Chat.imageset/chat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Chat.imageset/chat.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Check.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "selectUserWallet@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "selectUserWallet@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Check.imageset/selectUserWallet@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Check.imageset/selectUserWallet@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Check.imageset/selectUserWallet@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Check.imageset/selectUserWallet@3x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Contact.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "filename" : "add-contact.png",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Contact.imageset/add-contact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Contact.imageset/add-contact.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Edit.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "filename" : "pencil-edit-button.png",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Edit.imageset/pencil-edit-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Edit.imageset/pencil-edit-button.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Group.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "group.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "group1.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Group.imageset/group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Group.imageset/group.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Group.imageset/group1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Group.imageset/group1.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Home.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "home-icon.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "home-icon-1.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "home-icon-2.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Home.imageset/home-icon-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Home.imageset/home-icon-1.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Home.imageset/home-icon-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Home.imageset/home-icon-2.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Home.imageset/home-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Home.imageset/home-icon.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Logout.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "logout-2.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "logout-1.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "logout.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Logout.imageset/logout-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Logout.imageset/logout-1.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Logout.imageset/logout-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Logout.imageset/logout-2.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Logout.imageset/logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Logout.imageset/logout.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Profile.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "profilePIc.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "profilePIc 2.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "profilePIc 3.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Profile.imageset/profilePIc 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Profile.imageset/profilePIc 2.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Profile.imageset/profilePIc 3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Profile.imageset/profilePIc 3.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Profile.imageset/profilePIc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Profile.imageset/profilePIc.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/SideMenu.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "filename" : "menu-button.png",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/SideMenu.imageset/menu-button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/SideMenu.imageset/menu-button.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Splash.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "Default736h@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "Default736h@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Splash.imageset/Default736h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Splash.imageset/Default736h@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Splash.imageset/Default736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Splash.imageset/Default736h@3x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Uncheck.imageset/CircleWithShadow@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Uncheck.imageset/CircleWithShadow@2x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Uncheck.imageset/CircleWithShadow@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/Uncheck.imageset/CircleWithShadow@3x.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/Uncheck.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "CircleWithShadow@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "CircleWithShadow@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/User.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "filename" : "man-user.png",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Assets.xcassets/User.imageset/man-user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/logisticinfotech/firebase-swift-simple-chat/70a368a6ea90b153cfecdcd93000300936a6b061/messagingapp/DefaultResources/Assets.xcassets/User.imageset/man-user.png
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleURLTypes
20 |
21 |
22 | CFBundleURLSchemes
23 |
24 | fb170050390520579
25 |
26 |
27 |
28 | CFBundleVersion
29 | 1
30 | FacebookAppID
31 | 170050390520579
32 | FacebookDisplayName
33 | messagingapp
34 | LSApplicationQueriesSchemes
35 |
36 | fbapi
37 | fb-messenger-share-api
38 | fbauth2
39 | fbshareextension
40 |
41 | LSRequiresIPhoneOS
42 |
43 | NSContactsUsageDescription
44 | $(PRODUCT_NAME) requires to access your contacts ...
45 | UIBackgroundModes
46 |
47 | UILaunchStoryboardName
48 | LaunchScreen
49 | UIMainStoryboardFile
50 | SplashScreenSB
51 | UIRequiredDeviceCapabilities
52 |
53 | armv7
54 |
55 | UISupportedInterfaceOrientations
56 |
57 | UIInterfaceOrientationPortrait
58 | UIInterfaceOrientationLandscapeLeft
59 | UIInterfaceOrientationLandscapeRight
60 |
61 | UISupportedInterfaceOrientations~ipad
62 |
63 | UIInterfaceOrientationPortrait
64 | UIInterfaceOrientationPortraitUpsideDown
65 | UIInterfaceOrientationLandscapeLeft
66 | UIInterfaceOrientationLandscapeRight
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
67 |
81 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
143 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/messagingapp.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | messagingapp.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/messagingapp/DefaultResources/messagingapp.xcdatamodeld/messagingapp.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/messagingapp/Home/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 31/05/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import CoreData
11 | import Firebase
12 | import FirebaseMessaging
13 | import UserNotifications
14 | import FBSDKCoreKit
15 | import MFSideMenu
16 |
17 | @UIApplicationMain
18 | class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
19 |
20 | var window: UIWindow?
21 |
22 | var objSideMenu = MFSideMenuContainerViewController()
23 |
24 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
25 |
26 | FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
27 |
28 | Messaging.messaging().isAutoInitEnabled = true
29 | Messaging.messaging().delegate = self as? MessagingDelegate
30 | FirebaseApp.configure()
31 |
32 | if (Auth.auth().currentUser != nil) {
33 |
34 | self.sideMenu()
35 | }
36 | else{
37 |
38 | self.logOutSuccess()
39 |
40 | }
41 | return true
42 | }
43 | func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data){
44 | Messaging.messaging().apnsToken = deviceToken
45 | if #available(iOS 10.0, *) {
46 |
47 | UNUserNotificationCenter.current().delegate = self
48 |
49 | let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
50 | UNUserNotificationCenter.current().requestAuthorization(
51 | options: authOptions,
52 | completionHandler: {_, _ in })
53 | } else {
54 | let settings: UIUserNotificationSettings =
55 | UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
56 | application.registerUserNotificationSettings(settings)
57 | }
58 |
59 | application.registerForRemoteNotifications()
60 |
61 | }
62 | func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
63 | print("Firebase registration token: \(fcmToken)")
64 |
65 | let dataDict:[String: String] = ["token": fcmToken]
66 | NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
67 | }
68 |
69 | func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
70 | return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL!, sourceApplication: sourceApplication, annotation: annotation)
71 | }
72 |
73 | func logOutSuccess() -> Void {
74 |
75 | let navLogin = objMainSB.instantiateViewController(withIdentifier: "navLogin") as! UINavigationController
76 | self.window?.rootViewController = navLogin
77 | }
78 | func sideMenu() -> Void {
79 |
80 | let leftVC = objProfileSB.instantiateViewController(withIdentifier: "ProfileVC")
81 | leftVC.view.backgroundColor = UIColor(white: 1.0, alpha: 1)
82 |
83 | let navMain = objHomeSideSB.instantiateViewController(withIdentifier: "navHomeSide") as! UINavigationController
84 |
85 | objSideMenu = MFSideMenuContainerViewController.container(withCenter: navMain, leftMenuViewController: leftVC, rightMenuViewController: nil)
86 |
87 |
88 | self.window?.rootViewController = objSideMenu;
89 |
90 |
91 | self.window?.makeKeyAndVisible()
92 | }
93 |
94 | func showSideMenu() -> Void {
95 | objSideMenu.toggleLeftSideMenuCompletion {}
96 | }
97 |
98 |
99 | func applicationWillResignActive(_ application: UIApplication) {
100 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
101 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
102 | }
103 |
104 | func applicationDidEnterBackground(_ application: UIApplication) {
105 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
106 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
107 | }
108 |
109 | func applicationWillEnterForeground(_ application: UIApplication) {
110 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
111 | }
112 |
113 | func applicationDidBecomeActive(_ application: UIApplication) {
114 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
115 | }
116 |
117 | func applicationWillTerminate(_ application: UIApplication) {
118 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
119 | // Saves changes in the application's managed object context before the application terminates.
120 | self.saveContext()
121 | }
122 |
123 | // MARK: - Core Data stack
124 |
125 | lazy var persistentContainer: NSPersistentContainer = {
126 | /*
127 | The persistent container for the application. This implementation
128 | creates and returns a container, having loaded the store for the
129 | application to it. This property is optional since there are legitimate
130 | error conditions that could cause the creation of the store to fail.
131 | */
132 | let container = NSPersistentContainer(name: "messagingapp")
133 | container.loadPersistentStores(completionHandler: { (storeDescription, error) in
134 | if let error = error as NSError? {
135 | // Replace this implementation with code to handle the error appropriately.
136 | // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
137 |
138 | /*
139 | Typical reasons for an error here include:
140 | * The parent directory does not exist, cannot be created, or disallows writing.
141 | * The persistent store is not accessible, due to permissions or data protection when the device is locked.
142 | * The device is out of space.
143 | * The store could not be migrated to the current model version.
144 | Check the error message to determine what the actual problem was.
145 | */
146 | fatalError("Unresolved error \(error), \(error.userInfo)")
147 | }
148 | })
149 | return container
150 | }()
151 |
152 | // MARK: - Core Data Saving support
153 |
154 | func saveContext () {
155 | let context = persistentContainer.viewContext
156 | if context.hasChanges {
157 | do {
158 | try context.save()
159 | } catch {
160 | // Replace this implementation with code to handle the error appropriately.
161 | // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
162 | let nserror = error as NSError
163 | fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
164 | }
165 | }
166 | }
167 |
168 | }
169 |
170 |
--------------------------------------------------------------------------------
/messagingapp/Home/Constant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Constant.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 06/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Firebase
11 | import UIKit
12 |
13 | let objSignUpSB = UIStoryboard(name: "SignUpSB", bundle: nil)
14 |
15 | let objHomeSB = UIStoryboard(name: "HomeSB", bundle: nil)
16 |
17 | let objMainSB = UIStoryboard(name: "Main", bundle: nil)
18 |
19 | let objProfileSB = UIStoryboard(name: "ProfileSB", bundle: nil)
20 |
21 | let objProfileDetailSB = UIStoryboard(name: "ProfileDetailSB", bundle:nil)
22 |
23 | let objForgotPwdSB = UIStoryboard(name: "ForgotPwdSB", bundle:nil)
24 |
25 | let objChatSB = UIStoryboard(name: "ChatSB",bundle:nil)
26 |
27 | let objHomeSideSB = UIStoryboard(name: "HomeSideSB",bundle:nil)
28 |
29 | let objContactSB = UIStoryboard(name: "ContactSB",bundle:nil)
30 |
31 | //let objGroupSB = UIStoryboard(name: "GroupMenuSB", bundle: nil)
32 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/LoginAndRegistration/LoginVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 31/05/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Firebase
11 | import FacebookCore
12 | import FacebookLogin
13 | import FBSDKLoginKit
14 |
15 | class LoginVC: UIViewController {
16 |
17 | @IBOutlet var txtUsername: UITextField!
18 | @IBOutlet var txtPwd: UITextField!
19 |
20 | var ref: DatabaseReference!
21 |
22 | override func viewDidLoad() {
23 | super.viewDidLoad()
24 | self.title = "Login"
25 | }
26 | @IBAction func btnActionLoginWithFb(_ sender: Any) {
27 |
28 | let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
29 | fbLoginManager.logIn(withReadPermissions: ["email"], from: self) { (result, error) in
30 | if (error == nil){
31 | let fbloginresult : FBSDKLoginManagerLoginResult = result!
32 | if fbloginresult.grantedPermissions != nil {
33 | if(fbloginresult.grantedPermissions.contains("email")) {
34 | if((FBSDKAccessToken.current()) != nil){
35 | FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: { (connection, result, error) -> Void in
36 | if (error == nil){
37 | let dict = result as! NSDictionary
38 | let firstName = ["Firstname": dict.object(forKey: "first_name") as! String , "Lastname": dict.object(forKey: "last_name")as! String]
39 | let credential = FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
40 | Auth.auth().signInAndRetrieveData(with: credential) { (authResult, error) in
41 | if error != nil {
42 | return
43 | }
44 | self.ref = Database.database().reference()
45 | let imgDict = dict .object(forKey: "picture") as! NSDictionary
46 | let imgData = imgDict .object(forKey: "data") as! NSDictionary
47 | let img = imgData .object(forKey: "url") as! NSString
48 | if let url = URL(string: img as String) {
49 | var data = try? Data(contentsOf: url)
50 | let image: UIImage = UIImage(data: data!)!
51 | data = UIImageJPEGRepresentation(image, 0.8)! as NSData as Data
52 | let storageRef = Storage.storage().reference()
53 | let filePath = "\(Auth.auth().currentUser!.uid)/\("imgUserProfile")"
54 | let metaData = StorageMetadata()
55 | metaData.contentType = "image/jpg"
56 | storageRef.child(filePath).putData((data)!, metadata: metaData){(metaData,error) in
57 | if let error = error {
58 | print(error.localizedDescription)
59 | return
60 | }
61 | }
62 | }
63 | self.ref.child("users").child(Auth.auth().currentUser!.uid).setValue(["username": firstName])
64 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
65 | appDelegate.sideMenu()
66 | }
67 | }
68 | })
69 | }
70 | }
71 | }
72 | }
73 | }
74 | }
75 |
76 | @IBAction func btnActionForgetPwd(_ sender: Any) {
77 | let forgotPasswordAlert = UIAlertController(title: "Forgot password?", message: "", preferredStyle: .alert)
78 | forgotPasswordAlert.addTextField { (textField) in
79 | textField.placeholder = "Enter email address"
80 | }
81 | forgotPasswordAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
82 | forgotPasswordAlert.addAction(UIAlertAction(title: "Reset Password", style: .default, handler: { (action) in
83 | let resetEmail = forgotPasswordAlert.textFields?.first?.text
84 | Auth.auth().sendPasswordReset(withEmail: resetEmail!, completion: { (error) in
85 | if error != nil{
86 | let resetFailedAlert = UIAlertController(title: "Reset Failed", message: "Error: \(String(describing: error?.localizedDescription))", preferredStyle: .alert)
87 | resetFailedAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
88 | self.present(resetFailedAlert, animated: true, completion: nil)
89 | }else {
90 | let resetEmailSentAlert = UIAlertController(title: "Reset email sent successfully", message: "Check your email", preferredStyle: .alert)
91 | resetEmailSentAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
92 | self.present(resetEmailSentAlert, animated: true, completion: nil)
93 | }
94 | })
95 | }))
96 | self.present(forgotPasswordAlert, animated: true, completion: nil)
97 | }
98 |
99 | @IBAction func btnAction(_ sender: Any) {
100 | if self.txtUsername.text == "" || self.txtPwd.text == "" {
101 | let alertController = UIAlertController(title: "Error", message: "Please enter Email and password.", preferredStyle: .alert)
102 | let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
103 | alertController.addAction(defaultAction)
104 | self.present(alertController, animated: true, completion: nil)
105 |
106 | } else {
107 | Auth.auth().signIn(withEmail: self.txtUsername.text!, password: self.txtPwd.text!) { (user, error) in
108 | if error == nil {
109 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
110 | appDelegate.sideMenu()
111 | } else {
112 | let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
113 | let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
114 | alertController.addAction(defaultAction)
115 | self.present(alertController, animated: true, completion: nil)
116 | }
117 | }
118 | }
119 | }
120 | @IBAction func btnLogin(_ sender: Any) {
121 | let vc = objSignUpSB.instantiateViewController(withIdentifier: "SignUpVC")
122 | self.navigationController?.pushViewController(vc, animated: true)
123 | }
124 | }
125 |
126 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/LoginAndRegistration/SignUpSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/LoginAndRegistration/SignUpVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SignUpVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 01/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Firebase
11 | import FirebaseStorage
12 | import FirebaseDatabase
13 |
14 | class SignUpVC: UIViewController{
15 |
16 | @IBOutlet var imgUserProfile: UIImageView!
17 | @IBOutlet var txtFirstName: UITextField!
18 | @IBOutlet var txtLastName: UITextField!
19 | @IBOutlet var txtEmail: UITextField!
20 | @IBOutlet var txtPwd: UITextField!
21 |
22 | let storage = Storage.storage()
23 | var ref: DatabaseReference!
24 | let data = Data()
25 | let imagePicker = UIImagePickerController()
26 |
27 | @IBAction func btnAction(_ sender: Any) {
28 | imagePicker.allowsEditing = true
29 | imagePicker.sourceType = .photoLibrary
30 | present(imagePicker, animated: true, completion: nil)
31 | }
32 |
33 | override func viewDidLoad() {
34 | super.viewDidLoad()
35 | imagePicker.delegate = self
36 | self.title = "Registration"
37 | imgUserProfile.image = #imageLiteral(resourceName: "User")
38 | imgUserProfile.layer.borderWidth = 1.0
39 | imgUserProfile.layer.masksToBounds = false
40 | imgUserProfile.layer.borderColor = UIColor.white.cgColor
41 | imgUserProfile.layer.cornerRadius = imgUserProfile.frame.size.width / 2
42 | imgUserProfile.clipsToBounds = true
43 | }
44 |
45 | @IBAction func btnSignUpAction(_ sender: Any) {
46 | if txtFirstName.text == "" && txtLastName.text == "" {
47 | let alertController = UIAlertController(title: "Error", message: "Please enter Firstname & Lastname", preferredStyle: .alert)
48 | let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
49 | alertController.addAction(defaultAction)
50 | present(alertController, animated: true, completion: nil)
51 | }
52 | if txtEmail.text == ""{
53 | let alertController = UIAlertController(title: "Error", message: "Please enter your email and password", preferredStyle: .alert)
54 |
55 | let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
56 | alertController.addAction(defaultAction)
57 | present(alertController, animated: true, completion: nil)
58 | }
59 | if (self.imgUserProfile.image == #imageLiteral(resourceName: "User")){
60 | let alert = UIAlertController(title: "Alert", message: "Please Select Profile Picture", preferredStyle: UIAlertControllerStyle.alert)
61 | alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
62 | self.present(alert, animated: true, completion: nil)
63 | }
64 | else{
65 | Auth.auth().createUser(withEmail: txtEmail.text!, password: txtPwd.text!) { (user, error) in
66 | if error == nil {
67 | self.ref = Database.database().reference()
68 | var data = NSData()
69 | data = UIImageJPEGRepresentation(self.imgUserProfile.image!, 0.8)! as NSData
70 | let storageRef = Storage.storage().reference()
71 | let filePath = "\(Auth.auth().currentUser!.uid)/\("imgUserProfile")"
72 | let metaData = StorageMetadata()
73 | metaData.contentType = "image/jpg"
74 | storageRef.child(filePath).putData(data as Data, metadata: metaData){(metaData,error) in
75 | if let error = error {
76 | print(error.localizedDescription)
77 | return
78 | }
79 | }
80 | let fullname = ["Firstname": self.txtFirstName.text! , "Lastname": self.txtLastName.text!]
81 | self.ref.child("users").child((user?.uid)!).setValue(["username": fullname])
82 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
83 | appDelegate.sideMenu()
84 | } else {
85 | let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
86 | let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
87 | alertController.addAction(defaultAction)
88 | self.present(alertController, animated: true, completion: nil)
89 | }
90 | }
91 | }
92 | }
93 | }
94 | extension SignUpVC: UIImagePickerControllerDelegate, UINavigationControllerDelegate{
95 | func imagePickerController(_ imagePicker: UIImagePickerController, didFinishPickingMediaWithInfo info:[String: Any])
96 | {
97 | if let image = info[UIImagePickerControllerEditedImage] as? UIImage
98 | {
99 | imgUserProfile.image = image
100 | }
101 | self.dismiss(animated: true, completion: nil)
102 | }
103 | func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
104 | dismiss(animated: true, completion: nil)
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/LoginAndRegistration/SplashScreenSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/LoginAndRegistration/SplashScreenVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SplashScreenVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 06/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class SplashScreenVC: UIViewController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | // Do any additional setup after loading the view.
17 | }
18 |
19 | override func didReceiveMemoryWarning() {
20 | super.didReceiveMemoryWarning()
21 | // Dispose of any resources that can be recreated.
22 | }
23 |
24 |
25 | /*
26 | // MARK: - Navigation
27 |
28 | // In a storyboard-based application, you will often want to do a little preparation before navigation
29 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
30 | // Get the new view controller using segue.destinationViewController.
31 | // Pass the selected object to the new view controller.
32 | }
33 | */
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ChatSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ChatVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ChatVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 13/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Firebase
11 | import FirebaseDatabase
12 | import FirebaseStorage
13 | import QuartzCore
14 |
15 | class ChatVC: UIViewController,UITextFieldDelegate {
16 |
17 | @IBOutlet var bottomConst: NSLayoutConstraint!
18 | @IBOutlet var txtMsg: UITextField!
19 | @IBOutlet var tblChat: UITableView!
20 |
21 | var dict:NSDictionary!
22 | let arrMsg = NSMutableArray()
23 |
24 | override func viewDidLoad() {
25 | super.viewDidLoad()
26 | bottomConst.constant = 0
27 |
28 | NotificationCenter.default.addObserver(self, selector: #selector(ChatVC.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
29 | NotificationCenter.default.addObserver(self, selector: #selector(ChatVC.keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
30 |
31 | let senderDisplayName = "\(String(describing: dict.object(forKey: "Firstname")!))"
32 | title = "Chat: \(senderDisplayName)"
33 | let database = Database.database().reference()
34 | database.child("Chats").child(Auth.auth().currentUser!.uid).child("\(String(describing: dict.object(forKey: "firebaseId")!))").observe(.childAdded) { (snapshot) in
35 |
36 | let components = snapshot.key.components(separatedBy: "_")
37 | let dictMsg = NSMutableDictionary()
38 | dictMsg.setObject(components[1], forKey: "SenderId" as NSCopying)
39 | dictMsg.setObject(components[2], forKey: "ReceiverId" as NSCopying)
40 | dictMsg.setObject(snapshot.value!, forKey: "Message" as NSCopying)
41 |
42 | self.arrMsg.add(dictMsg)
43 | self.tblChat.reloadData()
44 | self.tblChat.separatorStyle = .none
45 | self.scrollToBottom()
46 | }
47 | }
48 |
49 | @IBAction func btnActionMsgSend(_ sender: Any) {
50 | if (txtMsg.text == "" || txtMsg.text == " ") {
51 | let alert = UIAlertController(title: "Alert", message: "Please type a Message", preferredStyle: UIAlertControllerStyle.alert)
52 | alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
53 | self.present(alert, animated: true, completion: nil)
54 | }
55 | else{
56 | let database = Database.database().reference()
57 | let str = "\(String(describing: self.getCurrentTimeStamp().replacingOccurrences(of: ".", with: "")))" + "_" + "\(String(describing: Auth.auth().currentUser!.uid))" + "_" + "\(String(describing: dict.object(forKey: "firebaseId")!))"
58 |
59 | database.child("Chats").child("\(String(describing: dict.object(forKey: "firebaseId")!))").child(Auth.auth().currentUser!.uid).updateChildValues([str : txtMsg.text!])
60 |
61 | database.child("Chats").child(Auth.auth().currentUser!.uid).child("\(String(describing: dict.object(forKey: "firebaseId")!))").updateChildValues([str : txtMsg.text!])
62 | self.tblChat.reloadData()
63 | txtMsg.text = " "
64 | }
65 | }
66 |
67 | func getCurrentTimeStamp() -> String {
68 | return "\(Double(NSDate().timeIntervalSince1970 * 1000))"
69 | }
70 | func scrollToBottom(){
71 | DispatchQueue.main.async {
72 | let indexPath = IndexPath(row: self.arrMsg.count-1, section: 0)
73 | self.tblChat.scrollToRow(at: indexPath, at: .bottom, animated: true)
74 | }
75 | }
76 | @objc func keyboardWillShow(notification: NSNotification) {
77 | if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
78 | bottomConst.constant = (keyboardSize.height) * -1.0
79 | self.view.layoutIfNeeded()
80 | }
81 | }
82 | @objc func keyboardWillHide(notification: NSNotification) {
83 | if ((notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue) != nil {
84 | bottomConst.constant = 0.0
85 | self.view.layoutIfNeeded()
86 | }
87 | }
88 | func textFieldShouldReturn(_ textField: UITextField) -> Bool {
89 | txtMsg.resignFirstResponder()
90 | return true
91 | }
92 | }
93 | extension ChatVC: UITableViewDataSource, UITableViewDelegate{
94 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
95 | return arrMsg.count
96 | }
97 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
98 |
99 | let dict1 = arrMsg.object(at: indexPath.row) as! NSDictionary
100 |
101 | if((String(describing: dict1.object(forKey: "SenderId")!)) == Auth.auth().currentUser?.uid){
102 | let cell2 = tableView.dequeueReusableCell(withIdentifier: "Cell2") as! Chat2TableViewCell
103 | cell2.lblSender.text = (dict1.object(forKey: "Message") as! String)
104 | cell2.lblSender.backgroundColor = UIColor(red: 0.09, green: 0.54, blue: 1, alpha: 1)
105 | cell2.lblSender.font = UIFont.systemFont(ofSize: 18)
106 | cell2.lblSender.textColor = .white
107 | cell2.lblSender?.layer.masksToBounds = true
108 | cell2.lblSender.layer.cornerRadius = 7
109 | return cell2
110 | }
111 | else
112 | {
113 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! ChatTableViewCell
114 | cell.lblReceiver.text = (dict1.object(forKey: "Message") as! String)
115 | cell.lblReceiver.backgroundColor = UIColor .lightGray
116 | cell.lblReceiver.font = UIFont.systemFont(ofSize: 18)
117 | cell.lblReceiver.textColor = UIColor.white
118 | cell.lblReceiver?.layer.masksToBounds = true
119 | cell.lblReceiver.layer.cornerRadius = 7
120 | return cell
121 | }
122 | }
123 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
124 | return UITableViewAutomaticDimension
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ContactSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ContactVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ContactVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 21/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Contacts
11 | import Firebase
12 | class ContactVC: UIViewController{
13 |
14 | @IBOutlet var tblContact: UITableView!
15 |
16 | var ref: DatabaseReference!
17 |
18 | let arrContactList = NSMutableArray()
19 |
20 | override func viewDidLoad() {
21 | super.viewDidLoad()
22 | self.title = "Contacts"
23 | let button1 = UIBarButtonItem(image: UIImage(named: "SideMenu"), style: .plain, target: self, action: #selector(ContactVC.addTapped))
24 | self.navigationItem.leftBarButtonItem = button1
25 | let store = CNContactStore()
26 | store.requestAccess(for: .contacts, completionHandler: {
27 | granted, error in
28 |
29 | guard granted else {
30 | let alert = UIAlertController(title: "Can't access contact", message: "Please go to Settings -> MyApp to enable contact permission", preferredStyle: .alert)
31 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
32 | self.present(alert, animated: true, completion: nil)
33 | return
34 | }
35 |
36 | let keysToFetch = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactPhoneNumbersKey] as [Any]
37 | let request = CNContactFetchRequest(keysToFetch: keysToFetch as! [CNKeyDescriptor] )
38 |
39 | request.sortOrder = CNContactSortOrder.givenName
40 | var cnContacts = [CNContact]()
41 |
42 | do {
43 | try store.enumerateContacts(with: request){
44 | (contact, cursor) -> Void in
45 | cnContacts.append(contact)
46 | }
47 | } catch let error {
48 | NSLog("Fetch contact error: \(error)")
49 | }
50 |
51 | for contact in cnContacts {
52 |
53 | let fullName = CNContactFormatter.string(from: contact, style: .fullName) ?? "No Name"
54 | (contact.phoneNumbers[0].value ).value(forKey: "digits")
55 |
56 | self.arrContactList.add(fullName)
57 | }
58 |
59 | self.ref = Database.database().reference()
60 | let data = NSData()
61 |
62 | let storageRef = Storage.storage().reference()
63 |
64 | let filePath = "\(Auth.auth().currentUser!.uid)/\("Contacts")"
65 | let metaData = StorageMetadata()
66 |
67 | storageRef.child(filePath).putData(data as Data, metadata: metaData){(metaData,error) in
68 | if let error = error {
69 | print(error.localizedDescription)
70 | return
71 | }
72 | }
73 | DispatchQueue.main.async {
74 | self.tblContact.reloadData()
75 | }
76 | })
77 | }
78 | @objc func addTapped(){
79 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
80 | appDelegate.showSideMenu()
81 | }
82 |
83 | }
84 | extension ContactVC : UITableViewDataSource,UITableViewDelegate{
85 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
86 | return arrContactList.count
87 | }
88 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
89 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! ContactCell
90 | cell.lblName.text = (arrContactList.object(at: indexPath.row) as! String)
91 | return cell
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomCell/Chat2TableViewCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Chat2TableViewCell.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 15/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class Chat2TableViewCell: UITableViewCell {
12 |
13 | @IBOutlet var lblSender: UILabel!
14 |
15 | @IBOutlet var imgSender: UIImageView!
16 |
17 | override func awakeFromNib() {
18 | super.awakeFromNib()
19 | // Initialization code
20 | }
21 |
22 | override func setSelected(_ selected: Bool, animated: Bool) {
23 | super.setSelected(selected, animated: animated)
24 |
25 | // Configure the view for the selected state
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomCell/ChatTableViewCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ChatTableViewCell.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 15/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ChatTableViewCell: UITableViewCell {
12 |
13 | override func awakeFromNib() {
14 | super.awakeFromNib()
15 | // Initialization code
16 | }
17 |
18 | @IBOutlet var lblReceiver: UILabel!
19 | override func setSelected(_ selected: Bool, animated: Bool) {
20 | super.setSelected(selected, animated: animated)
21 |
22 | // Configure the view for the selected state
23 | }
24 |
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomCell/ContactCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ContactCell.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 21/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ContactCell: UITableViewCell {
12 |
13 | override func awakeFromNib() {
14 | super.awakeFromNib()
15 | // Initialization code
16 | }
17 |
18 | @IBOutlet var lblName: UILabel!
19 | override func setSelected(_ selected: Bool, animated: Bool) {
20 | super.setSelected(selected, animated: animated)
21 |
22 | // Configure the view for the selected state
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomCell/GroupListCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GroupListCell.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 04/09/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class GroupListCell: UITableViewCell {
12 |
13 | @IBOutlet weak var lblUserName: UILabel!
14 | @IBOutlet weak var imgUser: UIImageView!
15 |
16 | @IBOutlet weak var btnSelect: UIButton!
17 | override func awakeFromNib() {
18 | super.awakeFromNib()
19 | // Initialization code
20 | }
21 |
22 | override func setSelected(_ selected: Bool, animated: Bool) {
23 | super.setSelected(selected, animated: animated)
24 |
25 | // Configure the view for the selected state
26 | }
27 |
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomCell/HomeSideVcCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HomeSideVcCell.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 18/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class HomeSideVcCell: UITableViewCell {
12 |
13 | override func awakeFromNib() {
14 | super.awakeFromNib()
15 | // Initialization code
16 | }
17 |
18 | @IBOutlet var lblUsername: UILabel!
19 | @IBOutlet var imgUser: UIImageView!
20 | override func setSelected(_ selected: Bool, animated: Bool) {
21 | super.setSelected(selected, animated: animated)
22 |
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomCell/HomeTableViewCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HomeTableViewCell.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 13/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class HomeTableViewCell: UITableViewCell {
12 |
13 | @IBOutlet var lblUserName: UILabel!
14 |
15 | @IBOutlet var imgUserProfile: UIImageView!
16 |
17 |
18 | override func awakeFromNib() {
19 | super.awakeFromNib()
20 |
21 | }
22 |
23 | override func setSelected(_ selected: Bool, animated: Bool) {
24 | super.setSelected(selected, animated: animated)
25 |
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomCell/ProfileCell.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ProfileCell.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 20/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ProfileCell: UITableViewCell {
12 |
13 | override func awakeFromNib() {
14 | super.awakeFromNib()
15 | // Initialization code
16 | }
17 |
18 | @IBOutlet var lblSideMenu: UILabel!
19 | @IBOutlet var imgMenu: UIImageView!
20 | override func setSelected(_ selected: Bool, animated: Bool) {
21 | super.setSelected(selected, animated: animated)
22 |
23 | // Configure the view for the selected state
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/CustomClass/CustomLabelVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CustomLabelVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 28/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class CustomLabelVC: UILabel {
12 |
13 | var topInset: CGFloat = 5.0
14 | var bottomInset: CGFloat = 5.0
15 | var leftInset: CGFloat = 7.0
16 | var rightInset: CGFloat = 7.0
17 |
18 | override func drawText(in rect: CGRect) {
19 | let insets = UIEdgeInsets.init(top: topInset, left: leftInset, bottom: bottomInset, right: rightInset)
20 | super.drawText(in: UIEdgeInsetsInsetRect(rect, insets))
21 | }
22 |
23 | override var intrinsicContentSize: CGSize {
24 | let size = super.intrinsicContentSize
25 | return CGSize(width: size.width + leftInset + rightInset,
26 | height: size.height + topInset + bottomInset)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/GroupMenuSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
49 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/GroupMenuVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GroupMenuVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 04/09/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Firebase
11 | class GroupMenuVC: UIViewController {
12 |
13 | let arrUserList = NSMutableArray()
14 | let arr = NSMutableArray()
15 |
16 |
17 | @IBOutlet weak var viewCreateGroup: UIView!
18 | @IBOutlet weak var tblGroupList: UITableView!
19 |
20 | override func viewDidLoad() {
21 | super.viewDidLoad()
22 | self.title = "Groups"
23 | self.viewCreateGroup.isHidden = true
24 | let button1 = UIBarButtonItem(image: UIImage(named: "SideMenu"), style: .plain, target: self, action: #selector(HomeVC.addTapped))
25 | self.navigationItem.leftBarButtonItem = button1
26 | let ref = Database.database().reference()
27 | ref.child("users").observeSingleEvent(of: .value, with: { (snapshot) in
28 | if snapshot.exists()
29 | {
30 | if let fruitPost = snapshot.value as? Dictionary
31 | {
32 | for(key, value) in fruitPost {
33 | if let fruitData = value as? Dictionary {
34 |
35 | if(Auth.auth().currentUser!.uid != key){
36 | let dict = NSMutableDictionary()
37 | dict.setObject(key, forKey:"firebaseId" as NSCopying)
38 | dict.setObject((fruitData["username"] as! NSDictionary).value(forKey: "Firstname")!, forKey: "Firstname" as NSCopying)
39 | dict.setObject((fruitData["username"] as! NSDictionary).value(forKey: "Lastname")!, forKey: "Lastname" as NSCopying)
40 | self.arrUserList.add(dict)
41 | }
42 | }
43 | }
44 | }
45 | print(self.arrUserList)
46 | self.tblGroupList.reloadData()
47 | }
48 | })
49 | }
50 |
51 | @objc func addTapped(){
52 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
53 | appDelegate.showSideMenu()
54 | }
55 | @objc func btnSelect(sender : UIButton){
56 | print("button click")
57 | }
58 |
59 | @IBAction func onClickCreateGroup(_ sender: Any) {
60 | if self.viewCreateGroup.isHidden == false{
61 | self.viewCreateGroup.isHidden = true
62 | }
63 | else{
64 | self.viewCreateGroup.isHidden = false
65 | }
66 | }
67 | }
68 | extension GroupMenuVC : UITableViewDelegate, UITableViewDataSource{
69 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
70 | return arrUserList.count
71 | }
72 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
73 |
74 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! GroupListCell
75 | let dict = arrUserList.object(at: indexPath.row) as! NSDictionary
76 |
77 | cell.lblUserName.text = "\(String(describing: dict.object(forKey: "Firstname")!))" + " " + "\(String(describing: dict.object(forKey: "Lastname")!))"
78 | cell.btnSelect.addTarget(self, action: #selector(self.btnSelect(sender:)), for: .touchUpInside);
79 |
80 | let imagePath = dict.object(forKey: "firebaseId")
81 | let imageName = "imgUserProfile"
82 | let reference = Storage.storage().reference(forURL: "gs://messagingapp-c035f.appspot.com")
83 | let url = reference.child(imagePath as! String).child(imageName)
84 | let placeholderImage = UIImage(named: "placeholder.jpg")
85 |
86 | url.downloadURL(completion: { (url, error) in
87 | if error != nil {
88 | print(error?.localizedDescription as Any)
89 | return
90 | }
91 | URLSession.shared.dataTask(with: url!, completionHandler: { (data, response, error) in
92 | if error != nil {
93 | print(error as Any)
94 | return
95 | }
96 | DispatchQueue.main.async {
97 | cell.imgUser.layer.borderWidth = 1.0
98 | cell.imgUser.layer.masksToBounds = false
99 | cell.imgUser.layer.borderColor = UIColor.white.cgColor
100 | cell.imgUser.layer.cornerRadius = cell.imgUser.frame.size.width / 2
101 | cell.imgUser.clipsToBounds = true
102 | cell.imgUser.sd_setImage(with: url, placeholderImage: placeholderImage)
103 | }
104 | }).resume()
105 | })
106 | return cell
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/HomeSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/HomeSideSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/HomeSideVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HomeSideVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 18/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Firebase
11 | class HomeSideVC: UIViewController{
12 |
13 | @IBOutlet var tblUserList: UITableView!
14 |
15 | let arrUserList = NSMutableArray()
16 |
17 | override func viewDidLoad() {
18 | super.viewDidLoad()
19 | self.title = "Home"
20 | self.tblUserList.separatorStyle = .none
21 | let button1 = UIBarButtonItem(image: UIImage(named: "SideMenu"), style: .plain, target: self, action: #selector(HomeSideVC.addTapped))
22 |
23 | self.navigationItem.leftBarButtonItem = button1
24 | let ref = Database.database().reference()
25 | ref.child("users").observeSingleEvent(of: .value, with: { (snapshot) in
26 | if snapshot.exists()
27 | {
28 | if let fruitPost = snapshot.value as? Dictionary
29 | {
30 | for(key, value) in fruitPost {
31 | if let fruitData = value as? Dictionary {
32 |
33 | if(Auth.auth().currentUser!.uid != key){
34 | let dict = NSMutableDictionary()
35 | dict.setObject(key, forKey:"firebaseId" as NSCopying)
36 | dict.setObject((fruitData["username"] as! NSDictionary).value(forKey: "Firstname")!, forKey: "Firstname" as NSCopying)
37 | dict.setObject((fruitData["username"] as! NSDictionary).value(forKey: "Lastname")!, forKey: "Lastname" as NSCopying)
38 | self.arrUserList.add(dict)
39 | }
40 | }
41 | }
42 | }
43 | print(self.arrUserList)
44 | self.tblUserList.reloadData()
45 | }
46 | })
47 | }
48 | @objc func addTapped(){
49 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
50 | appDelegate.showSideMenu()
51 | }
52 |
53 | }
54 | extension HomeSideVC: UITableViewDataSource,UITableViewDelegate{
55 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
56 | return arrUserList.count
57 | }
58 |
59 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
60 |
61 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! HomeSideVcCell
62 |
63 | let dict = arrUserList.object(at: indexPath.row) as! NSDictionary
64 |
65 | cell.lblUsername.text = "\(String(describing: dict.object(forKey: "Firstname")!))" + " " + "\(String(describing: dict.object(forKey: "Lastname")!))"
66 |
67 | let imagePath = dict.object(forKey: "firebaseId")
68 |
69 | let imageName = "imgUserProfile"
70 |
71 | let reference = Storage.storage().reference(forURL: "gs://messagingapp-c035f.appspot.com")
72 |
73 | let url = reference.child(imagePath as! String).child(imageName)
74 | let placeholderImage = UIImage(named: "placeholder.jpg")
75 |
76 | url.downloadURL(completion: { (url, error) in
77 | if error != nil {
78 | print(error?.localizedDescription as Any)
79 | return
80 | }
81 | URLSession.shared.dataTask(with: url!, completionHandler: { (data, response, error) in
82 | if error != nil {
83 | print(error as Any)
84 | return
85 | }
86 | DispatchQueue.main.async {
87 | cell.imgUser.layer.borderWidth = 1.0
88 | cell.imgUser.layer.masksToBounds = false
89 | cell.imgUser.layer.borderColor = UIColor.white.cgColor
90 | cell.imgUser.layer.cornerRadius = cell.imgUser.frame.size.width / 2
91 | cell.imgUser.clipsToBounds = true
92 | cell.imgUser.sd_setImage(with: url, placeholderImage: placeholderImage)
93 | }
94 | }).resume()
95 | })
96 | return cell
97 | }
98 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
99 | let vc = objChatSB.instantiateViewController(withIdentifier: "ChatVC") as! ChatVC
100 | vc.dict = arrUserList.object(at: indexPath.row) as! NSDictionary
101 | self.navigationController?.pushViewController(vc, animated: true)
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/HomeVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SuccessVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 31/05/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Firebase
11 | class HomeVC: UIViewController{
12 |
13 | @IBOutlet var tblUserList: UITableView!
14 |
15 | let arrUserList = NSMutableArray()
16 | let arr = NSMutableArray()
17 |
18 | override func viewDidLoad() {
19 | super.viewDidLoad()
20 | self.title = "Chat"
21 | let button1 = UIBarButtonItem(image: UIImage(named: "SideMenu"), style: .plain, target: self, action: #selector(HomeVC.addTapped))
22 | self.navigationItem.leftBarButtonItem = button1
23 | let ref = Database.database().reference()
24 | ref.child("Chats").child(Auth.auth().currentUser!.uid).observeSingleEvent(of: .value, with: { (snapshot) in
25 | if snapshot.exists()
26 | {
27 | if let fruitPost = snapshot.value as? Dictionary
28 | {
29 | for(key, _) in fruitPost {
30 | if(Auth.auth().currentUser!.uid != key){
31 | let dict = NSMutableDictionary()
32 | dict.setObject(key, forKey:"firebaseId" as NSCopying)
33 | self.arrUserList.add(dict)
34 | }
35 | }
36 | }
37 | print(self.arrUserList)
38 | self.tblUserList.reloadData()
39 | }
40 | })
41 | }
42 | @objc func addTapped(){
43 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
44 | appDelegate.showSideMenu()
45 | }
46 | }
47 | extension HomeVC : UITableViewDataSource, UITableViewDelegate{
48 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
49 | return arrUserList.count
50 | }
51 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
52 |
53 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! HomeTableViewCell
54 |
55 | let dict = arrUserList.object(at: indexPath.row) as! NSDictionary
56 |
57 | let firebaseId = dict.object(forKey: "firebaseId")
58 |
59 | Database.database().reference()
60 | .child("users")
61 | .child(firebaseId as! String)
62 | .child("username")
63 | .queryOrderedByKey()
64 | .observeSingleEvent(of: .value, with: { snapshot in
65 |
66 | if let dict1 = snapshot.value as? NSMutableDictionary
67 | {
68 | dict1.setObject(firebaseId!, forKey: "firebaseId" as NSCopying)
69 |
70 | let firstName = dict1["Firstname"] as? String
71 | self.arr.add(dict1)
72 |
73 | cell.lblUserName.text = firstName!
74 | }
75 | })
76 | let imagePath = firebaseId
77 | let imageName = "imgUserProfile"
78 |
79 | let reference = Storage.storage().reference(forURL: "gs://messagingapp-c035f.appspot.com")
80 | let url = reference.child(imagePath as! String).child(imageName)
81 | let placeholderImage = UIImage(named: "placeholder.jpg")
82 |
83 | url.downloadURL(completion: { (url, error) in
84 |
85 | if error != nil {
86 | print(error?.localizedDescription as Any)
87 | return
88 | }
89 | URLSession.shared.dataTask(with: url!, completionHandler: { (data, response, error) in
90 | if error != nil {
91 | print(error as Any)
92 | return
93 | }
94 | DispatchQueue.main.async {
95 | cell.imgUserProfile.layer.borderWidth = 1.0
96 | cell.imgUserProfile.layer.masksToBounds = false
97 | cell.imgUserProfile.layer.borderColor = UIColor.white.cgColor
98 | cell.imgUserProfile.layer.cornerRadius = cell.imgUserProfile.frame.size.width / 2
99 | cell.imgUserProfile.clipsToBounds = true
100 | cell.imgUserProfile.sd_setImage(with: url, placeholderImage: placeholderImage)
101 | }
102 | }).resume()
103 | })
104 | return cell
105 | }
106 |
107 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
108 | let vc = objChatSB.instantiateViewController(withIdentifier: "ChatVC") as! ChatVC
109 | vc.dict = arr.object(at: indexPath.row) as! NSDictionary
110 | self.navigationController?.pushViewController(vc, animated: true)
111 | }
112 |
113 | func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
114 | if editingStyle == .delete {
115 |
116 | let alert = UIAlertController(title: "Alert", message: "Are you sure want to Delete Chat?", preferredStyle: UIAlertControllerStyle.alert)
117 | alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil))
118 |
119 | alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (action) in
120 |
121 | let dict1 = self.arrUserList.object(at: indexPath.row) as! NSDictionary
122 |
123 | let userRef = Database.database().reference().child("Chats")
124 | .child(Auth.auth().currentUser!.uid).child(dict1.object(forKey: "firebaseId") as! String)
125 | userRef.removeValue()
126 | self.arrUserList.removeObject(at: indexPath.row)
127 |
128 | self.tblUserList.reloadData()
129 |
130 | }))
131 | self.present(alert, animated: true, completion: nil)
132 | }
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ProfileDetailSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ProfileDetailVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ProfileDetailVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 08/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | import UIKit
12 | import Firebase
13 | import FirebaseStorage
14 | import FirebaseDatabase
15 | import SDWebImage
16 |
17 | class ProfileDetailVC: UIViewController{
18 |
19 | @IBOutlet var activityIndicator: UIActivityIndicatorView!
20 | @IBOutlet var imgUserProfile: UIImageView!
21 | @IBOutlet var lblFirstName: UILabel!
22 |
23 | let imagePicker = UIImagePickerController()
24 |
25 | @IBAction func btnActionProfileChange(_ sender: Any) {
26 | imagePicker.allowsEditing = true
27 | imagePicker.sourceType = .photoLibrary
28 | present(imagePicker, animated: true, completion: nil)
29 | }
30 |
31 | override func viewDidLoad() {
32 | super.viewDidLoad()
33 | self.title = "Profile"
34 | let button1 = UIBarButtonItem(image: UIImage(named: "SideMenu"), style: .plain, target: self, action: #selector(HomeVC.addTapped))
35 |
36 | self.navigationItem.leftBarButtonItem = button1
37 | imagePicker.delegate = self
38 | activityIndicator.startAnimating()
39 | imgUserProfile.layer.borderWidth = 1.0
40 | imgUserProfile.layer.masksToBounds = false
41 | imgUserProfile.layer.borderColor = UIColor.white.cgColor
42 | imgUserProfile.layer.cornerRadius = imgUserProfile.frame.size.width / 2
43 | imgUserProfile.clipsToBounds = true
44 | Database.database().reference()
45 | .child("users")
46 | .child(Auth.auth().currentUser!.uid)
47 | .child("username")
48 | .queryOrderedByKey()
49 | .observeSingleEvent(of: .value, with: { snapshot in
50 | guard let dict = snapshot.value as? [String:Any] else {
51 | print("Error")
52 | return
53 | }
54 | let firstName = dict["Firstname"] as? String
55 | let lastName = dict["Lastname"] as? String
56 | self.lblFirstName.text = firstName! + " " + lastName!
57 | let imageName = "imgUserProfile"
58 | let reference = Storage.storage().reference(forURL: "gs://messagingapp-c035f.appspot.com")
59 | let url = reference.child(Auth.auth().currentUser!.uid).child(imageName)
60 | let placeholderImage = UIImage(named: "placeholder.jpg")
61 | url.downloadURL(completion: { (url, error) in
62 | if error != nil {
63 | print(error?.localizedDescription as Any)
64 | return
65 | }
66 | URLSession.shared.dataTask(with: url!, completionHandler: { (data, response, error) in
67 | if error != nil {
68 | print(error as Any)
69 | return
70 | }
71 | DispatchQueue.main.async {
72 | self.imgUserProfile.sd_setImage(with: url, placeholderImage: placeholderImage)
73 | }
74 | }).resume()
75 | self.activityIndicator.stopAnimating()
76 | self.activityIndicator.hidesWhenStopped = true
77 | })
78 | })
79 | }
80 | @objc func addTapped(){
81 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
82 | appDelegate.showSideMenu()
83 | }
84 | }
85 | extension ProfileDetailVC: UIImagePickerControllerDelegate, UINavigationControllerDelegate{
86 | func imagePickerController(_ imagePicker: UIImagePickerController, didFinishPickingMediaWithInfo info:[String: Any])
87 | {
88 | if let image = info[UIImagePickerControllerEditedImage] as? UIImage
89 | {
90 |
91 | imgUserProfile.image = image
92 | activityIndicator.stopAnimating()
93 | var data = NSData()
94 | data = UIImageJPEGRepresentation(self.imgUserProfile.image!, 0.8)! as NSData
95 | let storageRef = Storage.storage().reference()
96 | let filePath = "\(Auth.auth().currentUser!.uid)/\("imgUserProfile")"
97 | let metaData = StorageMetadata()
98 | metaData.contentType = "image/jpg"
99 | storageRef.child(filePath).putData(data as Data, metadata: metaData){(metaData,error) in
100 | if let error = error {
101 | print(error.localizedDescription)
102 | return
103 | }
104 | }
105 | }
106 | self.dismiss(animated: true, completion: nil)
107 | }
108 | func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
109 | dismiss(animated: true, completion: nil)
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ProfileSB.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/Home/ProfileVC.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ProfileVC.swift
3 | // messagingapp
4 | //
5 | // Created by Nishita on 08/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import Firebase
11 |
12 | class ProfileVC : UIViewController{
13 |
14 | var items = ["Home","Contact","Chat", "Profile", "Logout"]
15 |
16 | var arrImg = [UIImage(named: "Home"),UIImage(named: "Contact"), UIImage(named: "Chat"), UIImage(named: "Group"), UIImage(named: "Profile"), UIImage(named: "Logout")]
17 |
18 | @IBOutlet var tblSideMenu: UITableView!
19 |
20 | override func viewDidLoad() {
21 | super.viewDidLoad()
22 | let button1 = UIBarButtonItem(image: UIImage(named: "SideMenu"), style: .plain, target: self, action: #selector(HomeVC.addTapped))
23 | self.navigationItem.leftBarButtonItem = button1
24 | }
25 |
26 | @objc func addTapped(){
27 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
28 | appDelegate.showSideMenu()
29 | }
30 | }
31 | extension ProfileVC: UITableViewDelegate,UITableViewDataSource {
32 | func numberOfSections(in tableView: UITableView) -> Int {
33 | return 1
34 | }
35 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
36 | return items.count
37 | }
38 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
39 |
40 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! ProfileCell
41 | cell.lblSideMenu.text = items[indexPath.row]
42 | cell.imgMenu.image = arrImg[indexPath.row]
43 | return cell
44 | }
45 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
46 | if indexPath.row == 0 {
47 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
48 |
49 | let navMain = objHomeSideSB.instantiateViewController(withIdentifier: "navHomeSide") as! UINavigationController
50 |
51 | appDelegate.objSideMenu.centerViewController = navMain
52 | appDelegate.showSideMenu()
53 | }
54 | if indexPath.row == 1
55 | {
56 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
57 |
58 | let navMain = objContactSB.instantiateViewController(withIdentifier: "navContact") as! UINavigationController
59 |
60 | appDelegate.objSideMenu.centerViewController = navMain
61 | appDelegate.showSideMenu()
62 | }
63 | else if indexPath.row == 2
64 | {
65 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
66 |
67 | let navMain = objHomeSB.instantiateViewController(withIdentifier: "navMain") as! UINavigationController
68 |
69 | appDelegate.objSideMenu.centerViewController = navMain
70 | appDelegate.showSideMenu()
71 | }
72 | // else if indexPath.row == 3
73 | // {
74 | // let appDelegate = UIApplication.shared.delegate as! AppDelegate
75 | // let navMain = objGroupSB.instantiateViewController(withIdentifier: "navGroup") as! UINavigationController
76 | // appDelegate.objSideMenu.centerViewController = navMain
77 | // appDelegate.showSideMenu()
78 | //
79 | // }
80 | else if indexPath.row == 3
81 | {
82 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
83 | let navMain = objProfileDetailSB.instantiateViewController(withIdentifier: "navDetail") as! UINavigationController
84 |
85 | appDelegate.objSideMenu.centerViewController = navMain
86 | appDelegate.showSideMenu()
87 | }
88 | else if indexPath.row == 4 {
89 | try! Auth.auth().signOut()
90 | let appDelegate = UIApplication.shared.delegate as! AppDelegate
91 | appDelegate.logOutSuccess()
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/messagingapp/ViewController/SideMenu/SSB-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // SSB-Bridging-Header.h
3 | // messagingapp
4 | //
5 | // Created by Nishita on 07/06/18.
6 | // Copyright © 2018 Nishita. All rights reserved.
7 | //
8 |
9 | #ifndef SSB_Bridging_Header_h
10 | #define SSB_Bridging_Header_h
11 |
12 | #import "MFSideMenu/MFSideMenu.h"
13 |
14 |
15 | #endif /* SSB_Bridging_Header_h */
16 |
--------------------------------------------------------------------------------
/messagingapp/messagingapp.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | aps-environment
6 | development
7 |
8 |
9 |
--------------------------------------------------------------------------------