应该如何通知客户端主服务器离线。以及如何集成类似于 Whatsapp 的视频通话 UI。谁能建议最好的解决方案?
问问题
497 次
1 回答
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演示应用程序中包含的用户界面之一轻松自定义它
于 2018-08-07T06:45:55.793 回答