I implemented my local notifications and app shows notification. I have actions under notification like reply, cancel, open app
If app is in background and once user taps on "Open App" I would like to open app
Please let me know how do i handle this i.e., on user tap of notificationAction, open app if it is in background/inactive state
As of now in my didReceive response , I have below code..but it isnt opening app . Pls advice
if UIApplication.shared.canOpenURL(appHookUpURL! as URL)
{
UIApplication.sharedApplication.openURL(appHookUpURL! as URL)
}
You simply need to configure your action as:
let openAppAction = UNNotificationAction(identifier: "YOUR_IDENTIFIER", title: "Open App", options: .foreground)
Set the options
to .foreground
.
UNNotificationActionOptions - foreground
The action causes the app to launch in the foreground.
When the user selects an action containing this option, the system brings the app to the foreground, asking the user to unlock the device as needed. Use this option for actions that require the user to interact further with your app. Do not use this option simply to bring your app to the foreground.
No need to call UIApplication.sharedApplication.openURL
.