class Fastlane::Actions::NotificationAction

Public Class Methods

author() click to toggle source
# File fastlane/lib/fastlane/actions/notification.rb, line 24
def self.author
  ["champo", "cbowns", "KrauseFx", "amarcadet", "dusek"]
end
available_options() click to toggle source
# File fastlane/lib/fastlane/actions/notification.rb, line 28
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :title,
                                 description: "The title to display in the notification",
                                 default_value: 'fastlane'),
    FastlaneCore::ConfigItem.new(key: :subtitle,
                                 description: "A subtitle to display in the notification",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :message,
                                 description: "The message to display in the notification",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :sound,
                                 description: "The name of a sound to play when the notification appears (names are listed in Sound Preferences)",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :activate,
                                 description: "Bundle identifier of application to be opened when the notification is clicked",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :app_icon,
                                 description: "The URL of an image to display instead of the application icon (Mavericks+ only)",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :content_image,
                                 description: "The URL of an image to display attached to the notification (Mavericks+ only)",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :open,
                                 description: "URL of the resource to be opened when the notification is clicked",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :execute,
                                 description: "Shell command to run when the notification is clicked",
                                 optional: true)
  ]
end
category() click to toggle source
# File fastlane/lib/fastlane/actions/notification.rb, line 70
def self.category
  :notifications
end
description() click to toggle source
# File fastlane/lib/fastlane/actions/notification.rb, line 20
def self.description
  "Display a macOS notification with custom message and title"
end
example_code() click to toggle source
# File fastlane/lib/fastlane/actions/notification.rb, line 64
def self.example_code
  [
    'notification(subtitle: "Finished Building", message: "Ready to upload...")'
  ]
end
is_supported?(platform) click to toggle source
# File fastlane/lib/fastlane/actions/notification.rb, line 60
def self.is_supported?(platform)
  Helper.mac?
end
run(params) click to toggle source
# File fastlane/lib/fastlane/actions/notification.rb, line 4
def self.run(params)
  require 'terminal-notifier'

  options = params.values
  # :message is non-optional
  message = options.delete(:message)
  # remove nil keys, since `notify` below does not ignore them and instead translates them into empty strings in output, which looks ugly
  options = options.select { |_, v| v }
  option_map = {
    app_icon: :appIcon,
    content_image: :contentImage
  }
  options = options.transform_keys { |k| option_map.fetch(k, k) }
  TerminalNotifier.notify(message, options)
end