Skip to content

Commit

Permalink
Merge pull request #1480 from HedvigInsurance/feature/GEN-2509-OPEN-C…
Browse files Browse the repository at this point in the history
…ONTACT-push-notification

GEN-2509: Added support for the OPEN_CONTACT_INFO notification type
  • Loading branch information
sladan-hedvig authored Aug 30, 2024
2 parents cdfb2cb + 539be1d commit f5ca4e9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions Projects/App/Sources/AppDelegate+Notifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ enum PushNotificationType: String {
case OPEN_FOREVER_TAB
case OPEN_INSURANCE_TAB
case CROSS_SELL
case OPEN_CONTACT_INFO
}
8 changes: 8 additions & 0 deletions Projects/App/Sources/Journeys/LoggedInNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ class LoggedInNavigationViewModel: ObservableObject {
case .CROSS_SELL:
UIApplication.shared.getRootViewController()?.dismiss(animated: true)
self.selectedTab = 1
case .OPEN_CONTACT_INFO:
UIApplication.shared.getRootViewController()?.dismiss(animated: true)
self.selectedTab = 4
self.profileNavigationVm.pushToProfile()
}
}
}
Expand Down Expand Up @@ -544,6 +548,10 @@ class LoggedInNavigationViewModel: ObservableObject {
self.terminateInsuranceVm.start(with: contractsConfig)
case .openChat:
NotificationCenter.default.post(name: .openChat, object: nil)
case .contactInfo:
UIApplication.shared.getRootViewController()?.dismiss(animated: true)
self.selectedTab = 4
self.profileNavigationVm.pushToProfile()
case nil:
openUrl(url: url)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ extension OctopusGraphQL.MessageFragment {

private var messageType: MessageType {
if let text = self.asChatMessageText?.text {
if let url = URL(string: text), text.isUrl {
if text.isGIFURL {
let urlText = text.trimmingCharacters(in: .whitespacesAndNewlines)
if let url = URL(string: urlText), urlText.isUrl {
if urlText.isGIFURL {
return .file(file: .init(id: self.id, size: 0, mimeType: .GIF, name: "", source: .url(url: url)))
} else if text.isCrossSell {
} else if urlText.isCrossSell {
return .crossSell(url: url)
} else if text.isDeepLink {
} else if urlText.isDeepLink {
return .deepLink(url: url)
} else {
return .otherLink(url: url)
Expand Down
6 changes: 6 additions & 0 deletions Projects/Profile/Sources/Navigation/ProfileNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public class ProfileNavigationViewModel: ObservableObject {

public let profileRouter = Router()

public func pushToProfile() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [weak self] in
self?.profileRouter.push(ProfileRouterType.myInfo)
}
}

public init() {}
}

Expand Down
3 changes: 3 additions & 0 deletions Projects/hCore/Sources/DeepLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum DeepLink: String, Codable, CaseIterable {
case moveContract = "move-contract"
case terminateContract = "terminate-contract"
case openChat = "open-chat"
case contactInfo = "contact-info"

public func wholeText(displayText: String) -> String {
return L10n.generalGoTo(displayText)
Expand Down Expand Up @@ -48,6 +49,8 @@ public enum DeepLink: String, Codable, CaseIterable {
return L10n.hcQuickActionsTerminationTitle
case .openChat:
return L10n.chatTitle
case .contactInfo:
return L10n.profileMyInfoTitle
}
}

Expand Down

0 comments on commit f5ca4e9

Please sign in to comment.