How can I process a notification action when my app is closed?Best practices for loading and refreshing time-sensitive dataHow can I develop for iPhone using a Windows development machine?How can I disable the UITableView selection?How to change the name of an iOS app?How can I make a UITextField move up when the keyboard is present - on starting to edit?What happens when my app receives multiple push notifications?Is there a callback to the app delegate when a remote notification is received?Local notification override Remote notification (Actionable notification) setting in iOS 9?Detecting an actionable notification button when launching app from force quit - SwiftAppdelegate launch options nil from notification actionHow can my app open Siri shortcuts recording phrase view
What is the use case for non-breathable waterproof pants?
How to capitalise every letter in odd position as in memes?
“For nothing” = “pour rien”?
Why does FOO=bar; export the variable into my environment
Is keeping the forking link on a true fork necessary (Github/GPL)?
Why is 'additive' EQ more difficult to use than 'subtractive'?
Why A=2 and B=1 in the call signs for Spirit and Opportunity?
Best shape for a necromancer's undead minions for battle?
Who knighted this character?
How did NASA Langley end up with the first 737?
First Program Tic-Tac-Toe
Count all vowels in string
Why isn't Tyrion mentioned in 'A song of Ice and Fire'?
Why do the i8080 I/O instructions take a byte-sized operand to determine the port?
Why was this character made Grand Maester?
The Most Powerful Number
Possibility of faking someone's public key
How to deceive the MC
Where is Jon going?
How to make parshape work inside a tikz node?
Expected maximum number of unpaired socks
Finding all files with a given extension whose base name is the name of the parent directory
Heat lost in ideal capacitor charging
Using too much dialogue?
How can I process a notification action when my app is closed?
Best practices for loading and refreshing time-sensitive dataHow can I develop for iPhone using a Windows development machine?How can I disable the UITableView selection?How to change the name of an iOS app?How can I make a UITextField move up when the keyboard is present - on starting to edit?What happens when my app receives multiple push notifications?Is there a callback to the app delegate when a remote notification is received?Local notification override Remote notification (Actionable notification) setting in iOS 9?Detecting an actionable notification button when launching app from force quit - SwiftAppdelegate launch options nil from notification actionHow can my app open Siri shortcuts recording phrase view
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
SUMMARY OF THE PROBLEM
I am writing an iOS app that sends reminder notifications to let a user run other apps via their x-callback-url. I have everything working perfectly if the app is in the foreground or background, but it won't work when my app is closed.
When my app is closed, the notifications deliver properly as well and the user can dismiss it or choose a custom actions to launch another app via it's x-callback-url. My app launches just fine when the user takes any action on the notification.
What doesn't work when the app is launched directly from a closed state is triggering launching the x-callback-url to launch the Shortcuts app.
HERE IS THE CODE
This is the code that is in my AppDelegate related to notifications:
// Handle what we need to after the initial application load
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
// Setup our custom notification options and notification category.
// Note that The table view controller will register to handle the actual notification actions.
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) (granted, Error) in
if !granted
os_log("AppDelegate: Notification authorization NOT granted.", log: OSLog.default, type: .info)
else
os_log("AppDelegate: Notification authorization granted.", log: OSLog.default, type: .info)
// Define our custom notification actions
let runAction = UNNotificationAction(identifier: "RUN_SHORTCUT", title: "Run Shortcut", options: [.foreground])
let snoozeAction = UNNotificationAction(identifier: "SNOOZE", title: "Snooze 10 Minutes", options: [])
let skipAction = UNNotificationAction(identifier: "SKIP_SHORTCUT", title: "Skip Shortcut", options: [])
// Define our custom notification categories
let shortcutCategory =
UNNotificationCategory(identifier: "SHORTCUT_REMINDER", actions: [snoozeAction, runAction, skipAction], intentIdentifiers: [], options: .customDismissAction)
let noshortcutCategory =
UNNotificationCategory(identifier: "NO_SHORTCUT_REMINDER", actions: [snoozeAction], intentIdentifiers: [], options: .customDismissAction)
// Register the nofication category and actions with iOS
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.setNotificationCategories([shortcutCategory, noshortcutCategory])
os_log("AppDelegate: Set our custom notification categories and actions.", log: OSLog.default, type: .info)
//endif
//endfunc
return true
This is the code in my main table view controller that is the delegate to receive the notifications:
// Handle notifications when our app is in the background
// Note that this isn't triggered when the notification is delivered, but rather when the user interacts with the notification
//
// TO-DO: THIS DOESN'T RUN THE SHORTCUT IF THE APP WAS CLOSED WHEN THE NOTIFICATION WAS RESPONDED TO!!!
//
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void)
// Get the user info from the notification
let userInfo = response.notification.request.content.userInfo
// Get the specific record id that triggered this notification
let itemID = userInfo["ITEM_ID"] as? String
let itemTitle = userInfo["ITEM_TITLE"] as? String
let itemShortcut = userInfo["ITEM_SHORTCUT"] as? String
let itemURL = userInfo["ITEM_URL"] as? String
// Handle the notification action
print("RemindersViewController: Received notification. actionIdentifier:", response.actionIdentifier)
switch response.actionIdentifier
// If user selected the Run Shortcut option or simply tapped the notification, run the associated shortcut
case "RUN_SHORTCUT", "com.apple.UNNotificationDefaultActionIdentifier":
os_log("RemindersViewController: Notification Action Received: RUN_SHORTCUT: %public@ for shortcut %public@", log: .default, type: .info, String(describing: itemTitle!), String(describing: itemShortcut!))
if (itemShortcut != nil && itemShortcut != "")
if (itemURL != nil)
print("RemindersViewController: Shortcut URL=", itemURL!)
let launchURL = URL(string: itemURL!)
if UIApplication.shared.canOpenURL(launchURL!)
UIApplication.shared.open(launchURL!, options: [:], completionHandler: (success) in
print("RemindersViewController: Notification Action: Run shortcut: Open url : (success)")
)
else
let alert = UIAlertController(title: "You don't have the Shortcuts app installed", message: "Please download from the Apple App Store", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: User doesn't have the Shortcuts app.")
else
let alert = UIAlertController(title: "You don't have a shortcut name filled in", message: "Please fill in a shortcut name on your reminder", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: No shortcut name filled in!")
break
default:
os_log("RemindersViewController: Default action selected, which is: %public@. Doing nothing.", log: .default, type: .info, response.actionIdentifier)
break
// Call the completion handler to close out the notification
completionHandler()
EXPECTED AND ACTUAL RESULTS
I expect that when the app is launched from a closed state due to user interaction with a notification, that the custom "Run Shortcut" action should launch the Shortcuts app with its x-callback-url stored in the notification user data.
ios notifications
add a comment |
SUMMARY OF THE PROBLEM
I am writing an iOS app that sends reminder notifications to let a user run other apps via their x-callback-url. I have everything working perfectly if the app is in the foreground or background, but it won't work when my app is closed.
When my app is closed, the notifications deliver properly as well and the user can dismiss it or choose a custom actions to launch another app via it's x-callback-url. My app launches just fine when the user takes any action on the notification.
What doesn't work when the app is launched directly from a closed state is triggering launching the x-callback-url to launch the Shortcuts app.
HERE IS THE CODE
This is the code that is in my AppDelegate related to notifications:
// Handle what we need to after the initial application load
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
// Setup our custom notification options and notification category.
// Note that The table view controller will register to handle the actual notification actions.
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) (granted, Error) in
if !granted
os_log("AppDelegate: Notification authorization NOT granted.", log: OSLog.default, type: .info)
else
os_log("AppDelegate: Notification authorization granted.", log: OSLog.default, type: .info)
// Define our custom notification actions
let runAction = UNNotificationAction(identifier: "RUN_SHORTCUT", title: "Run Shortcut", options: [.foreground])
let snoozeAction = UNNotificationAction(identifier: "SNOOZE", title: "Snooze 10 Minutes", options: [])
let skipAction = UNNotificationAction(identifier: "SKIP_SHORTCUT", title: "Skip Shortcut", options: [])
// Define our custom notification categories
let shortcutCategory =
UNNotificationCategory(identifier: "SHORTCUT_REMINDER", actions: [snoozeAction, runAction, skipAction], intentIdentifiers: [], options: .customDismissAction)
let noshortcutCategory =
UNNotificationCategory(identifier: "NO_SHORTCUT_REMINDER", actions: [snoozeAction], intentIdentifiers: [], options: .customDismissAction)
// Register the nofication category and actions with iOS
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.setNotificationCategories([shortcutCategory, noshortcutCategory])
os_log("AppDelegate: Set our custom notification categories and actions.", log: OSLog.default, type: .info)
//endif
//endfunc
return true
This is the code in my main table view controller that is the delegate to receive the notifications:
// Handle notifications when our app is in the background
// Note that this isn't triggered when the notification is delivered, but rather when the user interacts with the notification
//
// TO-DO: THIS DOESN'T RUN THE SHORTCUT IF THE APP WAS CLOSED WHEN THE NOTIFICATION WAS RESPONDED TO!!!
//
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void)
// Get the user info from the notification
let userInfo = response.notification.request.content.userInfo
// Get the specific record id that triggered this notification
let itemID = userInfo["ITEM_ID"] as? String
let itemTitle = userInfo["ITEM_TITLE"] as? String
let itemShortcut = userInfo["ITEM_SHORTCUT"] as? String
let itemURL = userInfo["ITEM_URL"] as? String
// Handle the notification action
print("RemindersViewController: Received notification. actionIdentifier:", response.actionIdentifier)
switch response.actionIdentifier
// If user selected the Run Shortcut option or simply tapped the notification, run the associated shortcut
case "RUN_SHORTCUT", "com.apple.UNNotificationDefaultActionIdentifier":
os_log("RemindersViewController: Notification Action Received: RUN_SHORTCUT: %public@ for shortcut %public@", log: .default, type: .info, String(describing: itemTitle!), String(describing: itemShortcut!))
if (itemShortcut != nil && itemShortcut != "")
if (itemURL != nil)
print("RemindersViewController: Shortcut URL=", itemURL!)
let launchURL = URL(string: itemURL!)
if UIApplication.shared.canOpenURL(launchURL!)
UIApplication.shared.open(launchURL!, options: [:], completionHandler: (success) in
print("RemindersViewController: Notification Action: Run shortcut: Open url : (success)")
)
else
let alert = UIAlertController(title: "You don't have the Shortcuts app installed", message: "Please download from the Apple App Store", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: User doesn't have the Shortcuts app.")
else
let alert = UIAlertController(title: "You don't have a shortcut name filled in", message: "Please fill in a shortcut name on your reminder", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: No shortcut name filled in!")
break
default:
os_log("RemindersViewController: Default action selected, which is: %public@. Doing nothing.", log: .default, type: .info, response.actionIdentifier)
break
// Call the completion handler to close out the notification
completionHandler()
EXPECTED AND ACTUAL RESULTS
I expect that when the app is launched from a closed state due to user interaction with a notification, that the custom "Run Shortcut" action should launch the Shortcuts app with its x-callback-url stored in the notification user data.
ios notifications
As an update: I have now specified the Run Shortcut action with both .foreground and .authenticationRequired to ensure that the app will get loaded and the user has to unlock their device. I figured perhaps the issue was that the app couldn't launch another app while the device was locked. But alas, that didn't fix anything. For some reason the app won't launch another app if my app was closed when the notification is acted upon.
– Tim Nicholson
Mar 25 at 15:43
add a comment |
SUMMARY OF THE PROBLEM
I am writing an iOS app that sends reminder notifications to let a user run other apps via their x-callback-url. I have everything working perfectly if the app is in the foreground or background, but it won't work when my app is closed.
When my app is closed, the notifications deliver properly as well and the user can dismiss it or choose a custom actions to launch another app via it's x-callback-url. My app launches just fine when the user takes any action on the notification.
What doesn't work when the app is launched directly from a closed state is triggering launching the x-callback-url to launch the Shortcuts app.
HERE IS THE CODE
This is the code that is in my AppDelegate related to notifications:
// Handle what we need to after the initial application load
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
// Setup our custom notification options and notification category.
// Note that The table view controller will register to handle the actual notification actions.
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) (granted, Error) in
if !granted
os_log("AppDelegate: Notification authorization NOT granted.", log: OSLog.default, type: .info)
else
os_log("AppDelegate: Notification authorization granted.", log: OSLog.default, type: .info)
// Define our custom notification actions
let runAction = UNNotificationAction(identifier: "RUN_SHORTCUT", title: "Run Shortcut", options: [.foreground])
let snoozeAction = UNNotificationAction(identifier: "SNOOZE", title: "Snooze 10 Minutes", options: [])
let skipAction = UNNotificationAction(identifier: "SKIP_SHORTCUT", title: "Skip Shortcut", options: [])
// Define our custom notification categories
let shortcutCategory =
UNNotificationCategory(identifier: "SHORTCUT_REMINDER", actions: [snoozeAction, runAction, skipAction], intentIdentifiers: [], options: .customDismissAction)
let noshortcutCategory =
UNNotificationCategory(identifier: "NO_SHORTCUT_REMINDER", actions: [snoozeAction], intentIdentifiers: [], options: .customDismissAction)
// Register the nofication category and actions with iOS
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.setNotificationCategories([shortcutCategory, noshortcutCategory])
os_log("AppDelegate: Set our custom notification categories and actions.", log: OSLog.default, type: .info)
//endif
//endfunc
return true
This is the code in my main table view controller that is the delegate to receive the notifications:
// Handle notifications when our app is in the background
// Note that this isn't triggered when the notification is delivered, but rather when the user interacts with the notification
//
// TO-DO: THIS DOESN'T RUN THE SHORTCUT IF THE APP WAS CLOSED WHEN THE NOTIFICATION WAS RESPONDED TO!!!
//
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void)
// Get the user info from the notification
let userInfo = response.notification.request.content.userInfo
// Get the specific record id that triggered this notification
let itemID = userInfo["ITEM_ID"] as? String
let itemTitle = userInfo["ITEM_TITLE"] as? String
let itemShortcut = userInfo["ITEM_SHORTCUT"] as? String
let itemURL = userInfo["ITEM_URL"] as? String
// Handle the notification action
print("RemindersViewController: Received notification. actionIdentifier:", response.actionIdentifier)
switch response.actionIdentifier
// If user selected the Run Shortcut option or simply tapped the notification, run the associated shortcut
case "RUN_SHORTCUT", "com.apple.UNNotificationDefaultActionIdentifier":
os_log("RemindersViewController: Notification Action Received: RUN_SHORTCUT: %public@ for shortcut %public@", log: .default, type: .info, String(describing: itemTitle!), String(describing: itemShortcut!))
if (itemShortcut != nil && itemShortcut != "")
if (itemURL != nil)
print("RemindersViewController: Shortcut URL=", itemURL!)
let launchURL = URL(string: itemURL!)
if UIApplication.shared.canOpenURL(launchURL!)
UIApplication.shared.open(launchURL!, options: [:], completionHandler: (success) in
print("RemindersViewController: Notification Action: Run shortcut: Open url : (success)")
)
else
let alert = UIAlertController(title: "You don't have the Shortcuts app installed", message: "Please download from the Apple App Store", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: User doesn't have the Shortcuts app.")
else
let alert = UIAlertController(title: "You don't have a shortcut name filled in", message: "Please fill in a shortcut name on your reminder", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: No shortcut name filled in!")
break
default:
os_log("RemindersViewController: Default action selected, which is: %public@. Doing nothing.", log: .default, type: .info, response.actionIdentifier)
break
// Call the completion handler to close out the notification
completionHandler()
EXPECTED AND ACTUAL RESULTS
I expect that when the app is launched from a closed state due to user interaction with a notification, that the custom "Run Shortcut" action should launch the Shortcuts app with its x-callback-url stored in the notification user data.
ios notifications
SUMMARY OF THE PROBLEM
I am writing an iOS app that sends reminder notifications to let a user run other apps via their x-callback-url. I have everything working perfectly if the app is in the foreground or background, but it won't work when my app is closed.
When my app is closed, the notifications deliver properly as well and the user can dismiss it or choose a custom actions to launch another app via it's x-callback-url. My app launches just fine when the user takes any action on the notification.
What doesn't work when the app is launched directly from a closed state is triggering launching the x-callback-url to launch the Shortcuts app.
HERE IS THE CODE
This is the code that is in my AppDelegate related to notifications:
// Handle what we need to after the initial application load
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
// Setup our custom notification options and notification category.
// Note that The table view controller will register to handle the actual notification actions.
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) (granted, Error) in
if !granted
os_log("AppDelegate: Notification authorization NOT granted.", log: OSLog.default, type: .info)
else
os_log("AppDelegate: Notification authorization granted.", log: OSLog.default, type: .info)
// Define our custom notification actions
let runAction = UNNotificationAction(identifier: "RUN_SHORTCUT", title: "Run Shortcut", options: [.foreground])
let snoozeAction = UNNotificationAction(identifier: "SNOOZE", title: "Snooze 10 Minutes", options: [])
let skipAction = UNNotificationAction(identifier: "SKIP_SHORTCUT", title: "Skip Shortcut", options: [])
// Define our custom notification categories
let shortcutCategory =
UNNotificationCategory(identifier: "SHORTCUT_REMINDER", actions: [snoozeAction, runAction, skipAction], intentIdentifiers: [], options: .customDismissAction)
let noshortcutCategory =
UNNotificationCategory(identifier: "NO_SHORTCUT_REMINDER", actions: [snoozeAction], intentIdentifiers: [], options: .customDismissAction)
// Register the nofication category and actions with iOS
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.setNotificationCategories([shortcutCategory, noshortcutCategory])
os_log("AppDelegate: Set our custom notification categories and actions.", log: OSLog.default, type: .info)
//endif
//endfunc
return true
This is the code in my main table view controller that is the delegate to receive the notifications:
// Handle notifications when our app is in the background
// Note that this isn't triggered when the notification is delivered, but rather when the user interacts with the notification
//
// TO-DO: THIS DOESN'T RUN THE SHORTCUT IF THE APP WAS CLOSED WHEN THE NOTIFICATION WAS RESPONDED TO!!!
//
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void)
// Get the user info from the notification
let userInfo = response.notification.request.content.userInfo
// Get the specific record id that triggered this notification
let itemID = userInfo["ITEM_ID"] as? String
let itemTitle = userInfo["ITEM_TITLE"] as? String
let itemShortcut = userInfo["ITEM_SHORTCUT"] as? String
let itemURL = userInfo["ITEM_URL"] as? String
// Handle the notification action
print("RemindersViewController: Received notification. actionIdentifier:", response.actionIdentifier)
switch response.actionIdentifier
// If user selected the Run Shortcut option or simply tapped the notification, run the associated shortcut
case "RUN_SHORTCUT", "com.apple.UNNotificationDefaultActionIdentifier":
os_log("RemindersViewController: Notification Action Received: RUN_SHORTCUT: %public@ for shortcut %public@", log: .default, type: .info, String(describing: itemTitle!), String(describing: itemShortcut!))
if (itemShortcut != nil && itemShortcut != "")
if (itemURL != nil)
print("RemindersViewController: Shortcut URL=", itemURL!)
let launchURL = URL(string: itemURL!)
if UIApplication.shared.canOpenURL(launchURL!)
UIApplication.shared.open(launchURL!, options: [:], completionHandler: (success) in
print("RemindersViewController: Notification Action: Run shortcut: Open url : (success)")
)
else
let alert = UIAlertController(title: "You don't have the Shortcuts app installed", message: "Please download from the Apple App Store", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: User doesn't have the Shortcuts app.")
else
let alert = UIAlertController(title: "You don't have a shortcut name filled in", message: "Please fill in a shortcut name on your reminder", preferredStyle: .alert)
let action = UIAlertAction(title: "Ok", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
print("RemindersViewController: Notification Action: No shortcut name filled in!")
break
default:
os_log("RemindersViewController: Default action selected, which is: %public@. Doing nothing.", log: .default, type: .info, response.actionIdentifier)
break
// Call the completion handler to close out the notification
completionHandler()
EXPECTED AND ACTUAL RESULTS
I expect that when the app is launched from a closed state due to user interaction with a notification, that the custom "Run Shortcut" action should launch the Shortcuts app with its x-callback-url stored in the notification user data.
ios notifications
ios notifications
asked Mar 23 at 23:13
Tim NicholsonTim Nicholson
63
63
As an update: I have now specified the Run Shortcut action with both .foreground and .authenticationRequired to ensure that the app will get loaded and the user has to unlock their device. I figured perhaps the issue was that the app couldn't launch another app while the device was locked. But alas, that didn't fix anything. For some reason the app won't launch another app if my app was closed when the notification is acted upon.
– Tim Nicholson
Mar 25 at 15:43
add a comment |
As an update: I have now specified the Run Shortcut action with both .foreground and .authenticationRequired to ensure that the app will get loaded and the user has to unlock their device. I figured perhaps the issue was that the app couldn't launch another app while the device was locked. But alas, that didn't fix anything. For some reason the app won't launch another app if my app was closed when the notification is acted upon.
– Tim Nicholson
Mar 25 at 15:43
As an update: I have now specified the Run Shortcut action with both .foreground and .authenticationRequired to ensure that the app will get loaded and the user has to unlock their device. I figured perhaps the issue was that the app couldn't launch another app while the device was locked. But alas, that didn't fix anything. For some reason the app won't launch another app if my app was closed when the notification is acted upon.
– Tim Nicholson
Mar 25 at 15:43
As an update: I have now specified the Run Shortcut action with both .foreground and .authenticationRequired to ensure that the app will get loaded and the user has to unlock their device. I figured perhaps the issue was that the app couldn't launch another app while the device was locked. But alas, that didn't fix anything. For some reason the app won't launch another app if my app was closed when the notification is acted upon.
– Tim Nicholson
Mar 25 at 15:43
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319237%2fhow-can-i-process-a-notification-action-when-my-app-is-closed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319237%2fhow-can-i-process-a-notification-action-when-my-app-is-closed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
As an update: I have now specified the Run Shortcut action with both .foreground and .authenticationRequired to ensure that the app will get loaded and the user has to unlock their device. I figured perhaps the issue was that the app couldn't launch another app while the device was locked. But alas, that didn't fix anything. For some reason the app won't launch another app if my app was closed when the notification is acted upon.
– Tim Nicholson
Mar 25 at 15:43