mac上推送自定义消息(右上角提示)
2015-04-01 13:42
281 查看
1、下载 http://download.s32cdn.com/21/202517/706564/Growl-1.2.2.dmg
2、然后利用applescript调用growl api,下面php例子中 调用 send_message()即可
2、然后利用applescript调用growl api,下面php例子中 调用 send_message()即可
function send_message($title , $content){ $as_content = create_applescript($title , $content); file_put_contents(THIS_DIR.'/hmail/_applescript.script', $as_content); exec('osascript '.THIS_DIR.'/hmail/_applescript.script'); } function create_applescript($title , $content){ $application_name = '未读邮件提醒脚本'; return ' tell application "System Events" set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0 end tell if isRunning then tell application id "com.Growl.GrowlHelperApp" set the allNotificationsList to ¬ {"The Notification"} set the enabledNotificationsList to ¬ {"The Notification"} register as application ¬ "'.$application_name.'" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Script Editor" -- Send a Notification... notify with name ¬ "The Notification" title ¬ "'.$title.'" description ¬ "'.$content.'" application name "'.$application_name.'" end tell end if '; /* * * tell application "System Events" set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0 end tell if isRunning then tell application id "com.Growl.GrowlHelperApp" -- Make a list of all the notification types -- that this script will ever send: set the allNotificationsList to ¬ {"Test Notification", "Another Test Notification"} -- Make a list of the notifications -- that will be enabled by default. -- Those not enabled by default can be enabled later -- in the 'Applications' tab of the growl prefpane. set the enabledNotificationsList to ¬ {"Test Notification"} -- Register our script with growl. -- You can optionally (as here) set a default icon -- for this script's notifications. register as application ¬ "Growl AppleScript Sample" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Script Editor" -- Send a Notification... notify with name ¬ "Test Notification" title ¬ "Test Notification" description ¬ "This is a test AppleScript notification." application name "Growl AppleScript Sample" notify with name ¬ "Another Test Notification" title ¬ "Another Test Notification :) " description ¬ "Alas — you won't see me until you enable me..." application name "Growl AppleScript Sample" end tell end if * */ }
相关文章推荐
- 极光推送自定义消息提示铃声
- iOS自定义推送消息提示框
- app在前台时 如何播放自定义推送消息提示声
- 清除APP右上角的数字,推送消息改为0
- 接收到推送消息时,提示声音
- GoogleMapsV3-----基础地图(自定义消息提示OverlayView) (转)
- android自定义tabbar,并带badgeview消息提示
- ios菜鸟之路:消息推送之badgeNum、右上角小红圈数字不显示问题
- 消息提示(右上角数字标识)
- Android自定义消息推送
- 实现友盟推送消息的完全自定义处理
- Phalcon框架上扩展自定义Flash消息提示
- js自定义消息机制研究学习(一) ——看百度搜索输入提示
- Android自定义小红点消息提示
- 微信自定义推送模版消息
- 使用极光推送自定义消息打造个性的消息推送效果
- GoogleMapsV3-----基础地图(自定义消息提示OverlayView)
- 自定义Field 级别的错误提示消息
- Android自定义类似于QQ的消息提示框
- Andriod之使用极光推送自定义消息打造个性的消息推送效果