应如何通知客户端主服务器离线。以及如何集成类似于Whatsapp的视频通话UI。谁能建议最好的解决方案?
答案 0 :(得分:0)
这将成为您应用逻辑的一部分。有几种方法可以实现此目的,但一种方法是查看特定用户是否正在前台运行该应用程序并将其作为标志记录在数据库中。
例如,此处使用的是Firebase:
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
// user is offline
let ref = Database.database().reference.child("isOnline").child(user)
ref.setValue(false) // NO
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
let ref = Database.database().reference.child("isOnline").child(user)
ref.setValue(true) // YES
}
对于视频通话用户界面,您实际上可以使用Agora.io demo apps
中随附的用户界面之一轻松自定义该界面