-
Notifications
You must be signed in to change notification settings - Fork 50
[BUG] "The application xx is not open anymore" #141
Copy link
Copy link
Closed
Description
Describe the bug
Using a rebranded version of the application, when running it as a Notification Center alert, sometimes when the notification is clicked a macOS error appears as below, saying "The application $rebranded_name is not open anymore".
The script continues as normal and action is taken based on what the user clicked, but this error message shows about 1/3 of the time. I can't confirm for sure, but it appears to happen when the user waits more than 5-10 minutes before clicking the notification.
To Reproduce
Steps to reproduce the behavior:
- Rebrand IBM Notifier and deploy the package to a machine via JAMF.
- Run the rebranded IBM Notifier package with a script deployed from JAMF, calling
-type alert - User waits 5-10 minutes, then clicks on the notification.
- See error
Expected behavior
Script should continue without showing the error.
Screenshots
Here's my script code:
#!/bin/bash
pending_updates=$(tail -n -1 /var/log/auto-update.log | awk '{ print $8 }')
notifier_path="/Applications/Utilities/Riskified Notifier.app/Contents/MacOS/Riskified Notifier"
BANNER_TITLE="App Updates Available"
BANNER_SUBTITLE="You have ${pending_updates} pending updates, click to install."
BUTTON_LABEL="Update"
# Runs on error, reporting the error w/ line number and exiting.
function error()
{
local parent_lineno="$1"
local message="$2"
local code="${3:-1}"
if [[ -n "$message" ]] ; then
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
else
echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
fi
exit "${code}"
}
# Any error will trigger the above error() function and exit
trap 'error ${LINENO}' ERR
# Get logged in user
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil |
/usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
loggedInUID=$(/usr/bin/id -u "$loggedInUser" 2>/dev/null)
# Check for logged in user
if [[ -z "$loggedInUser" ]]; then
echo "No logged in user. Exiting..." >&2; exit 1
else
echo "User "${loggedInUser}" is logged in"
fi
# Check for notifier application
if [ ! -f "$notifier_path" ]; then
echo "Notifier application not present. Exiting..." >&2; exit 1
fi
# Show notification if updates are pending, exit if none
if [[ $pending_updates -gt 0 ]]; then
echo "${pending_updates} updates pending. Sending notification..."
command_result=$(/bin/launchctl asuser "$loggedInUID" "$notifier_path" -type alert -title "$BANNER_TITLE" -subtitle "$BANNER_SUBTITLE" -main_button_label "$BUTTON_LABEL"; echo $?)
else
echo "No updates pending. Exiting..."
exit 0
fi
# Open Auto-Update application if notification is clicked
if [ "$command_result" -eq 0 ] 2>/dev/null; then
echo "Notification clicked. Opening Auto-Update..."
/bin/launchctl asuser "$loggedInUID" open -a "/Applications/Managed Software Center.app"
elif [ "$command_result" -eq 239 ] 2>/dev/null; then
echo "Notification closed. Exiting..."
else
echo "Error ${command_result}"
fiDesktop (please complete the following information):
- OS: macOS 13.0.1
- Project version: 2.9.1 Build 96
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
