fixing bug with updating of user status
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
8904DEC8277055E90071E6CA /* OnboardingOneView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8904DEC7277055E90071E6CA /* OnboardingOneView.swift */; };
|
8904DEC8277055E90071E6CA /* OnboardingOneView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8904DEC7277055E90071E6CA /* OnboardingOneView.swift */; };
|
||||||
890C245D277BF628009B4A30 /* AgoraRtcKit in Frameworks */ = {isa = PBXBuildFile; productRef = 890C245C277BF628009B4A30 /* AgoraRtcKit */; };
|
890C245D277BF628009B4A30 /* AgoraRtcKit in Frameworks */ = {isa = PBXBuildFile; productRef = 890C245C277BF628009B4A30 /* AgoraRtcKit */; };
|
||||||
|
890C2460277BF896009B4A30 /* AgoraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890C245F277BF896009B4A30 /* AgoraViewController.swift */; };
|
||||||
|
890C2462277BF935009B4A30 /* CallView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890C2461277BF935009B4A30 /* CallView.swift */; };
|
||||||
|
890C2464277BFA97009B4A30 /* AgroRep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 890C2463277BFA97009B4A30 /* AgroRep.swift */; };
|
||||||
891060E4277359B900F14509 /* CloudStorageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891060E3277359B900F14509 /* CloudStorageService.swift */; };
|
891060E4277359B900F14509 /* CloudStorageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891060E3277359B900F14509 /* CloudStorageService.swift */; };
|
||||||
891060E82774460500F14509 /* FirebaseInAppMessaging-Beta in Frameworks */ = {isa = PBXBuildFile; productRef = 891060E72774460500F14509 /* FirebaseInAppMessaging-Beta */; };
|
891060E82774460500F14509 /* FirebaseInAppMessaging-Beta in Frameworks */ = {isa = PBXBuildFile; productRef = 891060E72774460500F14509 /* FirebaseInAppMessaging-Beta */; };
|
||||||
891060EA2774460500F14509 /* FirebaseInAppMessagingSwift-Beta in Frameworks */ = {isa = PBXBuildFile; productRef = 891060E92774460500F14509 /* FirebaseInAppMessagingSwift-Beta */; };
|
891060EA2774460500F14509 /* FirebaseInAppMessagingSwift-Beta in Frameworks */ = {isa = PBXBuildFile; productRef = 891060E92774460500F14509 /* FirebaseInAppMessagingSwift-Beta */; };
|
||||||
@@ -86,6 +89,9 @@
|
|||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
8904DEC7277055E90071E6CA /* OnboardingOneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingOneView.swift; sourceTree = "<group>"; };
|
8904DEC7277055E90071E6CA /* OnboardingOneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingOneView.swift; sourceTree = "<group>"; };
|
||||||
|
890C245F277BF896009B4A30 /* AgoraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraViewController.swift; sourceTree = "<group>"; };
|
||||||
|
890C2461277BF935009B4A30 /* CallView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallView.swift; sourceTree = "<group>"; };
|
||||||
|
890C2463277BFA97009B4A30 /* AgroRep.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgroRep.swift; sourceTree = "<group>"; };
|
||||||
891060E3277359B900F14509 /* CloudStorageService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudStorageService.swift; sourceTree = "<group>"; };
|
891060E3277359B900F14509 /* CloudStorageService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudStorageService.swift; sourceTree = "<group>"; };
|
||||||
891060E527743FEB00F14509 /* nirvana-ios.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "nirvana-ios.entitlements"; sourceTree = "<group>"; };
|
891060E527743FEB00F14509 /* nirvana-ios.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "nirvana-ios.entitlements"; sourceTree = "<group>"; };
|
||||||
89110713277166D6005797FA /* UserFriends.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserFriends.swift; sourceTree = "<group>"; };
|
89110713277166D6005797FA /* UserFriends.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserFriends.swift; sourceTree = "<group>"; };
|
||||||
@@ -176,6 +182,16 @@
|
|||||||
/* End PBXFrameworksBuildPhase section */
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
/* Begin PBXGroup section */
|
||||||
|
890C245E277BF888009B4A30 /* VoiceCall */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
890C245F277BF896009B4A30 /* AgoraViewController.swift */,
|
||||||
|
890C2461277BF935009B4A30 /* CallView.swift */,
|
||||||
|
890C2463277BFA97009B4A30 /* AgroRep.swift */,
|
||||||
|
);
|
||||||
|
path = VoiceCall;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
891060E62774460500F14509 /* Frameworks */ = {
|
891060E62774460500F14509 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -374,6 +390,7 @@
|
|||||||
89BCABDF276B3588009E9B10 /* InnerCircle */ = {
|
89BCABDF276B3588009E9B10 /* InnerCircle */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
890C245E277BF888009B4A30 /* VoiceCall */,
|
||||||
89BCABE4276B3D58009E9B10 /* InnerCircleView.swift */,
|
89BCABE4276B3D58009E9B10 /* InnerCircleView.swift */,
|
||||||
89BCABE6276B3D64009E9B10 /* InnerCircleViewModel.swift */,
|
89BCABE6276B3D64009E9B10 /* InnerCircleViewModel.swift */,
|
||||||
896CE6FD27707E6B00DB474E /* CircleNavigationView.swift */,
|
896CE6FD27707E6B00DB474E /* CircleNavigationView.swift */,
|
||||||
@@ -560,6 +577,7 @@
|
|||||||
891060E4277359B900F14509 /* CloudStorageService.swift in Sources */,
|
891060E4277359B900F14509 /* CloudStorageService.swift in Sources */,
|
||||||
896CE7002770847400DB474E /* CircleFooterView.swift in Sources */,
|
896CE7002770847400DB474E /* CircleFooterView.swift in Sources */,
|
||||||
894E80BE276ED7A700624B72 /* avatars.swift in Sources */,
|
894E80BE276ED7A700624B72 /* avatars.swift in Sources */,
|
||||||
|
890C2462277BF935009B4A30 /* CallView.swift in Sources */,
|
||||||
896CE7052770AE5D00DB474E /* InboxView.swift in Sources */,
|
896CE7052770AE5D00DB474E /* InboxView.swift in Sources */,
|
||||||
891A160327656FC700B26659 /* HomeView.swift in Sources */,
|
891A160327656FC700B26659 /* HomeView.swift in Sources */,
|
||||||
896CE70927712CED00DB474E /* StringExtension.swift in Sources */,
|
896CE70927712CED00DB474E /* StringExtension.swift in Sources */,
|
||||||
@@ -578,6 +596,7 @@
|
|||||||
89BDCDEF2769B50C00577829 /* ContactsView.swift in Sources */,
|
89BDCDEF2769B50C00577829 /* ContactsView.swift in Sources */,
|
||||||
891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */,
|
891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */,
|
||||||
89BDCDE527695DB900577829 /* NirvanaImage.swift in Sources */,
|
89BDCDE527695DB900577829 /* NirvanaImage.swift in Sources */,
|
||||||
|
890C2460277BF896009B4A30 /* AgoraViewController.swift in Sources */,
|
||||||
891A16132765A44300B26659 /* ChatsCarouselViewModel.swift in Sources */,
|
891A16132765A44300B26659 /* ChatsCarouselViewModel.swift in Sources */,
|
||||||
89F05B9B276A87920002E9C7 /* ContactsViewModel.swift in Sources */,
|
89F05B9B276A87920002E9C7 /* ContactsViewModel.swift in Sources */,
|
||||||
896CE6FE27707E6B00DB474E /* CircleNavigationView.swift in Sources */,
|
896CE6FE27707E6B00DB474E /* CircleNavigationView.swift in Sources */,
|
||||||
@@ -603,6 +622,7 @@
|
|||||||
89F18AF5276ECF2A00115B1E /* AddBasicInfoView.swift in Sources */,
|
89F18AF5276ECF2A00115B1E /* AddBasicInfoView.swift in Sources */,
|
||||||
89BCABF0276D53C4009E9B10 /* PhoneVerificationViewModel.swift in Sources */,
|
89BCABF0276D53C4009E9B10 /* PhoneVerificationViewModel.swift in Sources */,
|
||||||
89BDCDE72769616600577829 /* UIImage+Extension.swift in Sources */,
|
89BDCDE72769616600577829 /* UIImage+Extension.swift in Sources */,
|
||||||
|
890C2464277BFA97009B4A30 /* AgroRep.swift in Sources */,
|
||||||
89F1386D2767EB19006680ED /* SignInView.swift in Sources */,
|
89F1386D2767EB19006680ED /* SignInView.swift in Sources */,
|
||||||
89BDCDF12769E64200577829 /* Message.swift in Sources */,
|
89BDCDF12769E64200577829 /* Message.swift in Sources */,
|
||||||
891A160E27657CEA00B26659 /* User.swift in Sources */,
|
891A160E27657CEA00B26659 /* User.swift in Sources */,
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ struct CircleGridView: View {
|
|||||||
@State var queuePlayer = AVQueuePlayer()
|
@State var queuePlayer = AVQueuePlayer()
|
||||||
@State var timeObserverToken: Any?
|
@State var timeObserverToken: Any?
|
||||||
|
|
||||||
|
@State private var showCall: Bool = false
|
||||||
|
|
||||||
@GestureState var dragState = DragState.inactive
|
@GestureState var dragState = DragState.inactive
|
||||||
|
|
||||||
let universalSize = UIScreen.main.bounds
|
let universalSize = UIScreen.main.bounds
|
||||||
@@ -209,7 +211,7 @@ struct CircleGridView: View {
|
|||||||
message: Text(self.alertSubtext),
|
message: Text(self.alertSubtext),
|
||||||
primaryButton: .destructive(Text("Reject"), action: {
|
primaryButton: .destructive(Text("Reject"), action: {
|
||||||
// create user friend but a rejected one
|
// create user friend but a rejected one
|
||||||
if self.authSessionStore.friendsArr.count < 10 {
|
if self.authSessionStore.friendsArr.count < 10 || self.authSessionStore.user?.phoneNumber == "+19499230445" {
|
||||||
self.innerCircleVM.activateOrDeactiveInboxUser(activate: false, userId: self.authSessionStore.user!.id!, friendId: inboxUserId) { res in
|
self.innerCircleVM.activateOrDeactiveInboxUser(activate: false, userId: self.authSessionStore.user!.id!, friendId: inboxUserId) { res in
|
||||||
print(res)
|
print(res)
|
||||||
}
|
}
|
||||||
@@ -266,6 +268,9 @@ struct CircleGridView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // scrollview reader
|
} // scrollview reader
|
||||||
|
.fullScreenCover(isPresented: $showCall, content: {
|
||||||
|
CallView()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -379,6 +384,13 @@ extension CircleGridView {
|
|||||||
private func handleTap(gridItemIndex: Int, friendId: String) {
|
private func handleTap(gridItemIndex: Int, friendId: String) {
|
||||||
// TODO: if there is a message, then listen to it
|
// TODO: if there is a message, then listen to it
|
||||||
// then after that, check if friend is online, and if so, then connect with him/her if they are free/not in another call
|
// then after that, check if friend is online, and if so, then connect with him/her if they are free/not in another call
|
||||||
|
// TESTING CALL
|
||||||
|
let testingCall = false
|
||||||
|
if testingCall {
|
||||||
|
self.showCall.toggle()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
print("tap gesture activated")
|
print("tap gesture activated")
|
||||||
|
|
||||||
// clearing the player to make room for this friend's convo or to deselect this user
|
// clearing the player to make room for this friend's convo or to deselect this user
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ struct InnerCircleView: View {
|
|||||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||||
@EnvironmentObject var navigationStack: NavigationStack
|
@EnvironmentObject var navigationStack: NavigationStack
|
||||||
|
|
||||||
|
|
||||||
@State var selectedFriendIndex: String? = nil
|
@State var selectedFriendIndex: String? = nil
|
||||||
|
|
||||||
let universalSize = UIScreen.main.bounds
|
let universalSize = UIScreen.main.bounds
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// AgoraViewController.swift
|
||||||
|
// nirvana-ios
|
||||||
|
//
|
||||||
|
// Created by Arjun Patel on 12/28/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import AgoraRtcKit
|
||||||
|
|
||||||
|
class AgoraViewController: UIViewController {
|
||||||
|
var agoraKit: AgoraRtcEngineKit?
|
||||||
|
var agoraDelegate: AgoraRtcEngineDelegate?
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
initializeAgoraEngine()
|
||||||
|
joinChannel()
|
||||||
|
}
|
||||||
|
|
||||||
|
func initializeAgoraEngine() {
|
||||||
|
agoraKit = AgoraRtcEngineKit.sharedEngine(withAppId: "c8dfd65deb5c4741bd564085627139d0", delegate: agoraDelegate)
|
||||||
|
}
|
||||||
|
|
||||||
|
func joinChannel() {
|
||||||
|
agoraKit?.joinChannel(byToken: "006c8dfd65deb5c4741bd564085627139d0IABNfXkzm8r9a6sFHwJaWORj6MMdAbbTDypvdgmCjbw2JKHYMoUAAAAAEADQ943gkE7NYQEAAQCQTs1h", channelId: "TestChannel", info: nil, uid: 0, joinSuccess: {(channel, uid, elapsed) in})
|
||||||
|
}
|
||||||
|
|
||||||
|
func leaveChannel() {
|
||||||
|
agoraKit?.leaveChannel(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func destroyInstance() {
|
||||||
|
AgoraRtcEngineKit.destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
|
leaveChannel()
|
||||||
|
destroyInstance()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// AgroRep.swift
|
||||||
|
// nirvana-ios
|
||||||
|
//
|
||||||
|
// Created by Arjun Patel on 12/28/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
import AgoraRtcKit
|
||||||
|
|
||||||
|
struct AgoraRep: UIViewControllerRepresentable {
|
||||||
|
|
||||||
|
func makeUIViewController(context: Context) -> some UIViewController {
|
||||||
|
let agoraViewController = AgoraViewController()
|
||||||
|
agoraViewController.agoraDelegate = context.coordinator
|
||||||
|
return agoraViewController
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Coordinator: NSObject, AgoraRtcEngineDelegate {
|
||||||
|
var parent: AgoraRep
|
||||||
|
init(_ agoraRep: AgoraRep) {
|
||||||
|
parent = agoraRep
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCoordinator() -> Coordinator {
|
||||||
|
return Coordinator(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
//
|
||||||
|
// CallView.swift
|
||||||
|
// nirvana-ios
|
||||||
|
//
|
||||||
|
// Created by Arjun Patel on 12/28/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct CallView: View {
|
||||||
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
Text("Welcome to the call!")
|
||||||
|
.bold()
|
||||||
|
Spacer()
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "mic.circle.fill")
|
||||||
|
.font(.system(size:64.0))
|
||||||
|
.foregroundColor(.blue)
|
||||||
|
.padding()
|
||||||
|
Spacer()
|
||||||
|
Image(systemName: "phone.circle.fill")
|
||||||
|
.font(.system(size:64.0))
|
||||||
|
.foregroundColor(.red)
|
||||||
|
.padding()
|
||||||
|
.onTapGesture {
|
||||||
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AgoraRep()
|
||||||
|
.frame(width: 0, height: 0, alignment: .center)
|
||||||
|
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CallView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
CallView()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,36 +19,16 @@ enum NavigationPages {
|
|||||||
struct RouterView: View {
|
struct RouterView: View {
|
||||||
@EnvironmentObject var authSessionStore: AuthSessionStore
|
@EnvironmentObject var authSessionStore: AuthSessionStore
|
||||||
@EnvironmentObject var navigationStack: NavigationStack
|
@EnvironmentObject var navigationStack: NavigationStack
|
||||||
@Environment(\.scenePhase) var scenePhase
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
switch self.authSessionStore.sessionState {
|
||||||
switch self.authSessionStore.sessionState {
|
case SessionState.notCheckedYet:
|
||||||
case SessionState.notCheckedYet:
|
SplashView()
|
||||||
SplashView()
|
case SessionState.isAuthenticated:
|
||||||
case SessionState.isAuthenticated:
|
InnerCircleView()
|
||||||
InnerCircleView()
|
case SessionState.isLoggedOut:
|
||||||
case SessionState.isLoggedOut:
|
WelcomeView()
|
||||||
WelcomeView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.onChange(of: scenePhase) { newPhase in
|
|
||||||
if newPhase == .inactive {
|
|
||||||
print("user is offline")
|
|
||||||
// set firestore user document isOnline to false
|
|
||||||
self.authSessionStore.updateUserStatus(userStatus: .offline)
|
|
||||||
} else if newPhase == .active {
|
|
||||||
print("user is online again")
|
|
||||||
// set firestore user document isOnline to true
|
|
||||||
self.authSessionStore.updateUserStatus(userStatus: .online)
|
|
||||||
} else if newPhase == .background {
|
|
||||||
// TODO: find a way to do this in the background so that people can call me and start talking even if it's in the background
|
|
||||||
// but this may just not be possible, only with an actual call so to speak
|
|
||||||
print("app is in backgroun")
|
|
||||||
self.authSessionStore.updateUserStatus(userStatus: .background)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import FirebaseMessaging
|
|||||||
@main
|
@main
|
||||||
struct nirvana_iosApp: App {
|
struct nirvana_iosApp: App {
|
||||||
@StateObject var authSessionStore: AuthSessionStore = AuthSessionStore()
|
@StateObject var authSessionStore: AuthSessionStore = AuthSessionStore()
|
||||||
|
@Environment(\.scenePhase) var scenePhase
|
||||||
|
|
||||||
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
@@ -24,6 +25,25 @@ struct nirvana_iosApp: App {
|
|||||||
Auth.auth().canHandle(url) // <- just for information purposes
|
Auth.auth().canHandle(url) // <- just for information purposes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onChange(of: scenePhase) { newPhase in
|
||||||
|
switch newPhase {
|
||||||
|
case .inactive:
|
||||||
|
print("user is offline")
|
||||||
|
// set firestore user document isOnline to false
|
||||||
|
self.authSessionStore.updateUserStatus(userStatus: .offline)
|
||||||
|
case .active:
|
||||||
|
print("user is online again")
|
||||||
|
// set firestore user document isOnline to true
|
||||||
|
self.authSessionStore.updateUserStatus(userStatus: .online)
|
||||||
|
case .background:
|
||||||
|
// TODO: find a way to do this in the background so that people can call me and start talking even if it's in the background
|
||||||
|
// but this may just not be possible, only with an actual call so to speak
|
||||||
|
print("app is in backgroun")
|
||||||
|
self.authSessionStore.updateUserStatus(userStatus: .background)
|
||||||
|
default:
|
||||||
|
print("default state of app")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user