푸시, 딥링크 - 라이브 탭으로 이동하지 않아도 실행되도록 수정

This commit is contained in:
Yu Sung
2023-09-01 00:35:50 +09:00
parent d76b1c7a59
commit a41c423991
5 changed files with 75 additions and 41 deletions

View File

@@ -95,16 +95,26 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
Messaging.messaging().appDidReceiveMessage(userInfo)
let roomIdString = userInfo["room_id"] as? String
let audioContentIdString = userInfo["audio_content_id"] as? String
let contentIdString = userInfo["content_id"] as? String
let channelIdString = userInfo["channel_id"] as? String
let messageIdString = userInfo["message_id"] as? String
if let roomIdString = roomIdString, let roomId = Int(roomIdString), roomId > 0 {
AppState.shared.pushRoomId = roomId
}
if let audioContentIdString = audioContentIdString, let audioContentId = Int(audioContentIdString), audioContentId > 0 {
if let contentIdString = contentIdString, let audioContentId = Int(contentIdString), audioContentId > 0 {
AppState.shared.pushAudioContentId = audioContentId
}
if let channelIdString = channelIdString, let channelId = Int(channelIdString), channelId > 0 {
AppState.shared.pushChannelId = channelId
}
if let messageIdString = messageIdString, let messageId = Int(messageIdString), messageId > 0 {
AppState.shared.pushMessageId = messageId
}
completionHandler()
}
}

View File

@@ -26,6 +26,7 @@ class AppState: ObservableObject {
@Published var pushRoomId = 0
@Published var pushChannelId = 0
@Published var pushMessageId = 0
@Published var pushAudioContentId = 0
@Published var roomId = 0 {
didSet {

View File

@@ -26,7 +26,8 @@ struct SodaLiveApp: App {
let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: true)?.queryItems
let roomId = queryItems?.filter({$0.name == "room_id"}).first?.value
let channelId = queryItems?.filter({$0.name == "channel_id"}).first?.value
let audioContentId = queryItems?.filter({$0.name == "audio_content_id"}).first?.value
let messageId = queryItems?.filter({$0.name == "message_id"}).first?.value
let audioContentId = queryItems?.filter({$0.name == "content_id"}).first?.value
if let roomId = roomId {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
@@ -40,6 +41,12 @@ struct SodaLiveApp: App {
}
}
if let messageId = messageId {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
AppState.shared.pushMessageId = Int(messageId) ?? 0
}
}
if let audioContentId = audioContentId {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
AppState.shared.pushAudioContentId = Int(audioContentId) ?? 0