Skip to content

Commit

Permalink
Support http links in actions (#772)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
  • Loading branch information
digitaldan authored Jun 30, 2024
1 parent 23538b3 commit 2d52489
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 2d52489

Please sign in to comment.