Skip to content

Commit

Permalink
Support http links in actions
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan committed Jun 30, 2024
1 parent 9861666 commit 18999f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NotificationService/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NotificationService: UNNotificationServiceExtension {
let title = actionDict["title"] {
var options: UNNotificationActionOptions = []
// navigate options need to bring the app forward
if action.hasPrefix("ui") {
if action.hasPrefix("ui") || action.hasPrefix("http") {
options = [.foreground]
}
let notificationAction = UNNotificationAction(
Expand Down
12 changes: 10 additions & 2 deletions openHAB/OpenHABRootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,10 @@ class OpenHABRootViewController: UIViewController {
let cmd = action.split(separator: ":").dropFirst().joined(separator: ":")
if action.hasPrefix("ui") {
uiCommandAction(cmd)
}
if action.hasPrefix("command") {
} else if action.hasPrefix("command") {
sendCommandAction(cmd)
} else if action.hasPrefix("http") {
httpCommandAction(action)
}
}
}
Expand Down Expand Up @@ -253,6 +254,13 @@ class OpenHABRootViewController: UIViewController {
}
}

private func httpCommandAction(_ command: String) {
if let url = URL(string: command) {
let vc = SFSafariViewController(url: url)
present(vc, animated: true)
}
}

func showSideMenu() {
os_log("OpenHABRootViewController showSideMenu", log: .viewCycle, type: .info)
if let menu = SideMenuManager.default.rightMenuNavigationController {
Expand Down

0 comments on commit 18999f6

Please sign in to comment.