• Stars
    star
    119
  • Rank 297,930 (Top 6 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Swift project which can post macOS alert or banner notifications on 10.15+ clients

Copyright 2023 DATA JAR LTD

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Notifier

Notifier is a Swift app which can post macOS alert or banner notifications on 10.10+ clients.

On macOS 10.10-10.14 the deprecated NSUserNotifications API is used, for 10.15+ the UserNotifications Framework are used.

This project was originally intended for use with jamJAR

Usage

Basic Usage

./Notifier.app/Contents/MacOS/Notifier 
OVERVIEW: Notifier: Sends banner or alert notifications.

USAGE: notifier --type <alert/banner> --message <some message> <options>

OPTIONS:
  --message               message text - REQUIRED if not passing --remove all
  --messageaction         The action to be performed when the message is clicked. Either pass 'logout' or path to 
                          item to open on click. Can be a .app, file, URL etc. With non-.app items being opened in 
                          their default handler
  --messagebutton         alert type only. Sets the message buttons text
  --messagebuttonaction   alert type only. The action to be performed when the message button is clicked. Either 
                          pass 'logout' or path to item to open on click. Can be a .app, file, URL etc. With non-.app 
                          items being opened in their default handler. Requires '--messagebutton' to be passed
  --remove                "prior" or "all". If passing "prior", the full message will be required too. Including all 
                          passed flags
  --sound                 sound to play. Pass "default" for the default macOS sound, else the name of a sound in 
                          /Library/Sounds or /System/Library/Sounds. If the sound cannot be found, macOS will use the 
                          "default" sound
  --subtitle              message subtitle
  --title                 message title
  --type                  alert or banner - REQUIRED
  --verbose               Enables logging of actions. Check console for  'Notifier Log:' messages
  --help                  Display available options

SEE ALSO: https://github.com/dataJAR/Notifier

When looking at the above, --messagebutton & --messagebuttonaction refer to the button for Alert notifications as shown in the green box.

Other verbs apply to the main message area, the red box.

Example Usage

Example 1 This example shows a basic banner notification.

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type banner --message "message"

Example 2 This example shows a basic alert notification.

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message "message" --messagebutton "Logout" --messagebuttonaction "Logout"

Example 3 This example shows both alert & banner notifications, (sleep used for the example gif, not needed in use but below for completeness sake).

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message "Please Logout" --messagebutton "Logout" --title "Logout"

sleep 2

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type banner --message "message" --title "Notification ;)"

Example 4 This example shows removal of a prior notification, (sleep used for the example gif, not needed in use but below for completeness sake).

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message 'Look at me!!'

sleep 5

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message "message" --messagebutton "Logout"

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message 'Look at me!!' --remove prior

Example 5 This example shows removal of all alert notifications, for banner alerts this will remove from Notification Center. Sleep used for the example gif, not needed in use but below for completeness sake.

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message "message" --messagebutton "Logout"

sleep 2

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message "message2" --messagebutton "Logout"

sleep 2

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --message "message3" --messagebutton "Logout"

/Applications/Utilities/Notifier.app/Contents/MacOS/Notifier --type alert --remove all

Deployment

PKG

PKG's will be supplied for every release, & can be found in the releases section

This will place the Notifier.app within /Applications/Utilities/, removing /Applications/Utilities/Notifier.app if found prior.

macOS 10.15+

If running Notifier on macOS 10.15+, you'll want to deploy the supplied profile (https://github.com/dataJAR/Notifier/blob/master/profile/Allow%20Notifier%20Notifications.mobileconfig) to UAMDM devices.

This will allow Notifier to post Notifications without prompting the user to allow & needs to be deployed when a device is running 10.15+ & not before.

How it works

When using the deprecated NSUserNotifications API, the notification type (alert or banner), is defined by the NSUserNotificationAlertStyle key in the Applications info.plist.

For the UserNotifications Framework, the user can choose the notification type or an admin can define this in a profile.

Notifier follows the above rules, by actually being not one but three applications.

An enclosing Notifier.app & two sub apps, with one used to post Alert notifications & another Banner notifications. As per the below:

Notifier.app/Contents/Resources/
                               alert/Notifier - Alerts.app
                               banner/Notifier - Notifications.app

These sub applications contain code for both the NSUserNotifications API & UserNotifications Framework, as well as the relevant NSUserNotificationAlertStyle key in the Applications info.plist for the NSUserNotifications API.

The apps themselves seamlessly transition between the NSUserNotifications API when running on macOS 10.10-10.14, & the UserNotifications Framework when running on 10.15+ via the @available declaration attribute.

So why the Notifier.app?

This is to give a single app to call, the Notifier.app will also check the parsed args & then pass to the required sub application.

Notifier.app also checks tha Notification Center is running, & runs the sub apps in the user context. As well as having an enclosing Notifier.app allows for some of the rebrand options below without adjusting any code.

Rebranding

If you find the Notifier logo too garish &/or want to rename the notifications as they show in Notification Center, then you can follow the below rebrand guidelines.

NOTE: It's likely that these will change regularly, PR's accepted to correct &/or clarify any of the below or any or this README.

Requirements

  1. Apple Xcode
  2. A macOS developer account signed into Xcode
  3. A copy of this project downloaded, & the Notifier.xcodeproj file loaded into Xcode

Re-signing

Notifier is made up of three applications, the enclosing Notifier.app & the sub apps with one used to post Alert notifications & another Banner notifications.

As such, all three will need to be re-signed with your developer certificate & it is worth making sure this is all compile-able before proceeding.

See this guide, for where to change the signing identity per app.

(Note: You may also need to change the signing in "Build Settings" as well as "Signing and Capabilities" for each app.)

Those steps will need to be repeated for each of the three apps, & they are highlighted in the Xcode screenshot below:

Renaming

The name which is shown within Notification Center is the name of the applications themselves capitalised, so to change them follow the below. This will need to be repeated for both the Alert & Banner applications.

  1. Select the app that you're looking to rename in Xcode's project navigator.

2. Slowly double click, or press enter to make the field editable & change the name as needed, presssing enter when done.

3. Approve the changes in the drop down.

4. Click the disclosure triangle next to the app target you renamed above, change the folder name to the same as the application name.

5. Repeat steps 2-4 for the other application as wanted, note: you cannot name both applications the same.

6. With the applications renamed, from Xcode's menubar click "Product" > "Schemes" > "Manage Schemes".

7. For each renamed app, select the scheme & rename.

8. Repeat 7 until all the renamed apps have had their schemes renamed.

9. With the apps renamed, we need to add them back to the main Notifier.app. Click the Notifier target in Xcode's project navigator, then in Xcode's project editor click "Build Phases" & expand "Dependencies". If you renamed both the Alert & Banner applications then this will be empty, if you've renamed just one then that will be missing only.

10. Click the + button, select the missing renamed Alert & Banner applications as required & click "Add".

11. Still within the "Build Phases" tab of the main Notifier.app scroll down to the "Copy Files" steps, this will be empty where the Alert or Banner application was renamed earlier.

12. Click the + button to add the wanted application, it's important that you pay attention to the "subpath" value. As one is called "alerts" & is for the Alert application, the other "banner" & is for the Banner application.

13. Now build the project to test, if the build fails please review the above & attempt again.

Changing Icons

The application icons for the Alert & Banner applications can be changed to fit with your requirements.

At a minimum, you'll need a PNG of 1024 x 1024 for this.

But if you'd like to supply all the sizes offered, then you'll want PNG's in the below sizes:

β€’Β 1024 x 1024

β€’Β 512 x 512

β€’Β 256 x 256

β€’Β 128 x 128

β€’Β 64 x 64

β€’Β 32 x 32

β€’Β 16 x 16

Below is the process,

  1. Select the application that you're looking to change the icon in Xcode's project navigator, click the disclosure triangle for the application, click the sub folder, click "Assets.xcassets" & lastly click "AppIcon".

2. Either replace each icon with icons of the correct size (a ⚠️ will be shown if the wrong size PNG is supplied), or delete all & just supply the last "AppStore -2x".

3. Repeat for which of the Alert or Banner applications are to have their icons changed, the main Notifier.app icon doesn't need to be changed as will not be shown to customers when notifications are posted. But could be changed as per the above too if wanted.
4. Now build the project to test, if the build fails please review the above & attempt again.
5. If you now test your new icons on a macOS device on which Notifier has run before, you'll likely see the previous icon. So test in a VM or try to reset Notification Center as per the Resetting Notifications Center steps below.

Miscellaneous

Resetting Notifications Center

The below should rest Notifications Center, but please test & submit a PR with a better method as applicable.

  1. rm -rf $(getconf DARWIN_USER_DIR)/com.apple.notificationcenter/*
  2. Logout & then log back in, or:
  • For macOS 10.16+: killall "NotificationCenter"
  1. Test the Notifier once more

FAQs

Q1: Why start at version 2?

A1: At dataJAR, we already had a v1 "Notifier" app deployed.

Q2: How can you post both banner & alert notifications?

A2: See How it works

Q3: The users are being prompted to allow.. help!

A3: This can be due to a few things:

  1. Was the notifications profile installed? If not, install.
  2. Was the notifications profile installed when running macOS 10.10-10.14? If it was, re-install when running 10.15+.
  3. Is the device under UAMDM? If not, check with your MDM vendor on making the device UAMDM. Then try again & maybe reinstall the profile once under UAMDM.
  4. Did you change the Bundle ID of either the Alert or Banner applications? If so you'll need to amend the notifications profile accordingly.

Q4: Is that logo magen...

A4: No, it's a shade of pink...

Q5: Banner or Notifications?

A5: The temporary notifications are referred to as "banner" notifications in Apple's documentation, but it seems that most folks call them "Notifications" with the persistent notifications being referred to as alerts by folks as well as within Apple's documentation.

Q6: I'm seeing alerts when expecting banner notifications, & vice versa

A6: Check step 12 of Renaming, it's likely the wrong app is in the wrong folder.

Q7: --remove prior, didn't clear my last message.

A7: Make sure you pass EXACTLY the same message to be cleared.

Q8: I've rebranded, but the old icon is being shown..

A8: Please reset Notification Center as per the Resetting Notifications Center, then try again.

Q9: I'm struggling with rebranding &/or would like some changes for my organisation that are bespoke to us.

A9: We should be able to help, please visit our website & fill out the contact form or join us in the #datajar channel on the macadmins.org slack & we can arrange a quote as needed.

Q10: The NSUserNotifications API was deprecated in 10.14, why not use the UserNotifications Framework for 10.14+ instead of 10.15+?

A10: Simply, macOS 10.14 didn't support managing the notification type via a profile, where 10.15+ does.

Q11: Some functionality is missing.. why is this?

A11: Notifier supports 10.10+, multiple API's & notification types. One of the main drivers was for consistency across the vast OS versions & differing API's, so if one API doesn't support a function.. it'll not be added to keep a consistent KISS approach.

Alternatives

The below projects can be used instead of Notifier & were very much instrumental in Notifiers creation

Alert Notifications

Yo

Banner Notifications

Terminal Notifier

More Repositories

1

PPPC-Utility

Privacy Preferences Policy Control (PPPC) Utility
Swift
748
star
2

CVE-2020-0796-RCE-POC

CVE-2020-0796 Remote Code Execution POC
Python
533
star
3

aftermath

Aftermath is a free macOS IR framework
Swift
474
star
4

DEPNotify-Starter

Bash script to start DEPNotify and run policies during enrollment with Jamf Pro
Shell
370
star
5

NetSUS

NetBoot and Software Update Server
PHP
304
star
6

MakeMeAnAdmin

Provides temporary admin access for a standard user via Jamf Self Service
Shell
258
star
7

CVE-2020-0796-LPE-POC

CVE-2020-0796 Local Privilege Escalation POC
Python
242
star
8

FreeTheSandbox_LPE_POC_13.7

Jailbreak for iOS 13.7 and earlier
C
225
star
9

jamfprotect

A repository for open-source resources created for use with or alongside Jamf Protect.
Shell
188
star
10

Jamf-Nation-Scripts

Scripts Migrated from Jamf Nation
Shell
186
star
11

CVE-2020-1206-POC

CVE-2020-1206 Uninitialized Kernel Memory Read POC
C#
146
star
12

FileVault2_Scripts

Scripts and Extension Attributes for use with FileVault 2 on Mountain Lion
Shell
146
star
13

JamfMigrator

A tool to migrate data granularly between Jamf Pro servers
Swift
143
star
14

mut

Swift
138
star
15

JAWA

Jamf Automation and Webhook Assistant
HTML
133
star
16

CIS-for-macOS-Catalina-CP

CIS Benchmarks for macOS Catalina
Shell
122
star
17

Jamf-Nation-Extension-Attributes

Shell
118
star
18

zecops_public

Objective-C
114
star
19

API_Scripts

Scripts that make use of the JAMF Software Server API
Shell
114
star
20

JamfPrivacyPreferencePolicyControlProfiles

Shell
110
star
21

CIS-for-macOS-Sierra

Shell
105
star
22

ReEnroller

Migrate macOS devices from one Jamf Server to another.
Swift
103
star
23

Jamf-Environment-Test

Admin Utility for testing an environments network for success with Apple Devices
Shell
102
star
24

jamfStatus

Menu app to monitor JamfCloud status
Swift
101
star
25

jamJAR

jamJAR: Jamf, AutoPKG & Munki combined by dataJAR
Python
98
star
26

jamfconnect

A repository for Jamf Connect scripts, configuration profile templates,EAs and more!
Shell
93
star
27

jamfpro

JamfPro Docker image
Shell
71
star
28

regatta

Regatta is a distributed key-value store. It is Kubernetes friendly with emphasis on high read throughput and low operational cost.
Go
64
star
29

NoMAD-2

A complete ground-up rewrite of NoMAD utilizing the same AD Auth Framework found in NoMAD Login.
Swift
63
star
30

NoMADLogin-AD

Login to an AD user account without binding your Mac to AD.
Swift
51
star
31

JamfSync

Jamf Sync utility for synchronizing between Jamf Pro distribution points and/or file folders
Swift
48
star
32

SMBGhost-SMBleed-scanner

SMBGhost (CVE-2020-0796) and SMBleed (CVE-2020-1206) Scanner
Python
46
star
33

DEPNotify

Swift
43
star
34

Classic-API-Postman-Collection

42
star
35

2016_JNUC_Security_Reporting_Compliance

Repo for code used in all presentation slides from the 2016 JNUC Presentation "Digging into Security, Compliance, and Reporting"
Shell
42
star
36

Provisioning-Workflows

Provisioning Workflows for a Post-Imaging World
Shell
41
star
37

CIS-for-macOS-High-Sierra-CP

Shell
40
star
38

jamf-printer-manager

macOS app to upload printer configurations to Jamf Pro
Swift
39
star
39

jamf-laps-public

A GUI app for retrieving Jamf Pro LAPS ("Local Administrator Password Solution") credentials
Swift
38
star
40

ManagedAppConfigLib

Makes Managed AppConfig on iOS, tvOS, and macOS easier to work with.
Swift
37
star
41

Jamf-Connect-Resources

A repository for Jamf Connect scripts, configuration profile templates, and legacy content.
Shell
36
star
42

Subprocess

Swift library for macOS providing interfaces for both synchronous and asynchronous process execution
Swift
34
star
43

powerbi

Jamf PowerBi Integration
32
star
44

NoMAD

Get all of AD, with none of the bind!
Swift
30
star
45

JamfProvisioner

An Automated Erase/Install Workflow for macOS and Jamf Pro
Shell
30
star
46

ol

Misc Jamf-related Projects
PowerShell
26
star
47

Mac-Asset-Tag

A script that generates a GUI to accept a user input asset tag for the Mac.
Python
26
star
48

CIS-for-macOS-Sierra-CP

CIS for macOS 10.12 remediated with script and configuration profiles
Shell
26
star
49

AppConfig-Generator

Java
25
star
50

Scripting-101-Webinar

Resources for the "Scripting 101 for Apple Admins" webinar - June 2019
Shell
25
star
51

Jamf-Pro-Object-LookUp

Script to query Jamf Pro and find what an Object is associated with
Shell
23
star
52

STIG-macOS-10_14

STIG for macOS Mojave - audit and remediation with scripts and Configuration Profiles
Shell
21
star
53

Munki-Catalog-Browser

Munki Catalog Browser is an app which allows for easy browsing of items in your devices Munki catalogs as well as exporting to CSV
Swift
20
star
54

homebrew-tap

Ruby
19
star
55

CIS-for-macOS-High-Sierra

Shell
17
star
56

JamfConnectUninstall

Shell
16
star
57

NoMAD-ADAuth

Swift
14
star
58

CertificateSDK

Get Certificates From Jamf Pro Into Your iOS Apps
Objective-C
13
star
59

Jamf-Switcher

Jamf Switcher is an app which points either Jamf Pro applications or your browser to a particular Jamf deployment and is configured by Self Service Bookmarks
Swift
13
star
60

jamf_connectwise

An integration between Connectwise and Jamf Pro
Python
12
star
61

SmashingJamfProDashboards

Example jobs, dashboard and YAML file for use with Jamf Pro and Smashing
Ruby
11
star
62

rendr

A project scaffolding tool
Rust
10
star
63

AppConfigSpecCreator

Tool for Generation of Managed App Config Spec Files
JavaScript
10
star
64

authchanger

Utility for making changes to the macOS authorization database to easily allow for changing loginwindow mechanisms.
Swift
9
star
65

Jamf-Connect-Configurations-Templates

8
star
66

JamfSupport

Shell
8
star
67

JSS-LDAP-Sync

Sync department and building objects in the JSS with LDAP records
PowerShell
7
star
68

TableauIntegrations

JavaScript
7
star
69

groupsync

Sync LDAP groups with GitHub teams (and possibly more in the future).
Go
7
star
70

Classic-API-Swagger-Specification

7
star
71

JamfProtect-PPPC-Profile

A PPPC configuration profile to allow full disk and accessibility permissions for computers with the Jamf Protect agent.
6
star
72

SplunkBase

Jamf's Published Splunk Base Integration
Python
6
star
73

anti-phishing-extension

Augment the web with indicators that help detect phishing attempts
JavaScript
6
star
74

regatta-go

Regatta client for Go language
Go
5
star
75

JamfProFlow

Database application for managing configuration sets and change-managed workflows in Jamf Pro
Roff
5
star
76

GDPRAutomationTool

Python
5
star
77

Haversack

A Swift library for keychain access on Apple devices
Swift
5
star
78

kinobi-title-editor

Shell
4
star
79

gitlab_license_exporter

Gitlab License Information exporter
Go
3
star
80

testrail-reporting

Easily send results of your tests to Test Rail.
Groovy
3
star
81

RADAR_API_Postman_Collection

3
star
82

billboard

Swift
2
star
83

TELUGU_CVE-2018-4124_POC

Objective-C
2
star
84

regatta-helm

Helm Chart for the distributed key-value store Regatta.
Smarty
2
star
85

JamfProFlow-Sets

Configs for Jamf Pro
2
star
86

kyverno-test-util

Python
2
star
87

homebrew-internal-tap

Homebrew Internal Tap
Ruby
1
star
88

rendr-sample-blueprint-go-microservice

Shell
1
star
89

aurorasnapshot

Aurora Cluster snapshot handler (Allows to create and delete Aurora DB Snapshots based in tags)
Python
1
star
90

regatta-java

This repository hosts the code of Regatta client for JVM languages.
Java
1
star
91

ms-security-copilot-plugin

Basic Jamf Pro OpenAPI spec for use with Microsoft Security CoPilot plugin
1
star
92

jamf_entries_menu_manager

ExpressionEngine add-on to rearrange the Entries Menu in the CMS
JavaScript
1
star