display notification number in MAC cocoa application - macos

i want to display notification (like the number that exist when a application is minimized in utorrent or itunes (when u have some update) or in outlook the number of unread mails).
I am using this for a messaging application so when the application is minimized and i receive a message then it must display the number of unread messages.
Do i need to use apple push notification as in the case of iPhone applications if so is there some other way ?
Thanks

You can do this using NSDockTile. See also the Dock Tile Programming Guide.

If your refering to the little red badge in the top right corner of an application dock icon then thats called the Dock Badge Label, You can easly set this through code, Because I do all my programing in Cocoa Applescript / AppleScript Objective C i struggle with C so Ill use a simple code:
You should be able to set the Dock Icon Badge with this:
[[NSApp dockTile] setBadgeLabel: #"1"];
// Sets the Dock Badge to "1"
(PS I just guessed this because I had to mentally convert this to Objective C) but this should work

Related

Unable to move small window when making a phone call in Facetime on macOS 10.15.7

It is possible to make audio phone calls directly from macOS using the Facetime app and this works very well. Unfortunately a small Window is placed on the top/right counter of the screen and I cannot seem to be able to move or minimize this window. Has anyone an idea on how to customize the location of this window?
You can't move or minimize the window that supports a call, it's a sort of static notification.
More people are annoyed by this:
https://discussions.apple.com/thread/8095870
https://discussions.apple.com/thread/8085443?page=1
You can disable the notification via System Preferences > Notifications > Facetime by unticking "Badge app icon".
I do appreciate the notification to answer the call. Even though my MacBook has a touch bar which also allows me to Answer/End, Video or Mute. Also note the touch bar doesn't sport the button you need when you have to dial during a call ("Select 1 for department A, Select 2 for department B"). So, you'll need the pop-up.
You can kill the pop-up as documented over here:
https://apple.stackexchange.com/a/313721
(somebody even shared a script for the kill command using an Automator Applet)
Don't forget to provide Apple feedback on this. Even though it's been a few years, hopefully they'll find a better solution than the current notification.
https://www.apple.com/feedback/macbook.html
I recently discovered a simple way to hide the call window. Right click on the FaceTime dock icon and click Hide. That's it. You can also move the window by clicking and dragging the waveform area.

How to show the notify icon in taskbar for windows 7?

I implement a notify icon for my application by call Shell_NotifyIcon.
In the default, the notify icon display in the notify icon area instead of task bar in windows 7.
If the user want to show the notify icon in the task bar, he/she need to open the Notification Area Icons control panel item, find the application and set "Show icon and notifications" for the application.
I think it will be difficult to the user with poor windows knowledge. I want to implement this function that show the notify icon in the task bar in my VC++ code or installer. Is it possible? If yes, what should I do?
Appreciate.
No, this is not possible.
Windows 7 introduces a feature where notification icons can be hidden. It is an attempt to reduce the noise created by decades of developers dumping notification icons in the taskbar for no good reason.
In order for that feature to work effectively, there can't be a loophole for applications to get around it, because everyone thinks their application is the most important and the most deserving of prime real estate. Eventually, nothing is sacred anymore.
Raymond Chen has blogged about this very request, and provides some additional background info.
You just create the notification icon and provide the user with instructions in the documentation on how to show it permanently, if they so desire.
Why not just pin your application to the task bar? They can just click it and it will launch the application?

Always show Badge Count in OS X

Apple's own apps such as Reminders show Badge count even if they are not running or after quitting them
Other apps (some even with Helper apps) show badge when they are running, but it disappears as soon as you quit the application
is there a way, user side, or programming side, we can do to always show this badge, even when the app is not running?
I searched a lot in Google, didn't find anything about "always" showing this badge, maybe "badge count" is the wrong keyword
Yes, Create dock Tile Plug-in.
Starting in OS X v10.6, you can customize an application’s Dock tile
icon and menu when the application is not running.
When your application needs to customize the Dock tile, it manipulates the NSDockTile object that was provided to the initial call to the setDockTile: method.
To dynamically change the application's Dock icon, you can draw a Dock icon using a custom view. See Using a Custom View to Draw a Dock Icon.
To add text to a Dock icon, you can apply a badge label. See Changing the Text of a Badge Label.

Possible to tell if NSApplicationActivationPolicyProhibited application is active?

Using JUCE with TUIO, I'm developing a multi-touch utility to send "hot keys" commands to other applications (I am using a usb touch frame that sends TUIO messages). For instance, I provide an interface through which users can touch-and-hold to program a key combo and then tap that button to send the programmed key combo to another app. They way I accomplish this on OSX is by running my utility as a "background only" application (NSApplicationActivationPolicyProhibited). I use [NSWindow setCanHide: NO] so the GUI of my utility is visible even though it runs as a background app.
It works well except in the case that a window from another application is on top of mine. What happens is that touches get passed through that other app into mine- causing unintentional button pushes in my app. Normally, I could have my app only listen to the TUIO touch callback whenever is is the active application, [NSApp isActive]. But, since my app is background only, it is never active and I have no way to tell if another window is covering it to prevent touches.
So, is there any way for a "background only" app to be able to tell if it is on top of all other windows? Or, is there a way from within my app to get a list of all Cocoa windows from other applications and be able to tell if they are appearing on top of my "background only" app?
Also, does anyone know how I would go about all of the above in Windows? In other words, what is the Windows equivalent of NSApplicationActivationPolicyProhibited and would I be able to tell if it is covered by other applications' windows?

Non-modal notification bars?

How can I implement a non-modal sliding notification bar, such as Firefox, Beyond Compare, and VMware Workstation 6.5 use, in client-side Windows apps?
Any language or framework is fine for now; my current app is in Delphi / C++Builder, but I'm also interested in comparing frameworks and prototyping some UIs.
Related question: This question asks about doing so in Java.
Beyond Compare's notification bar doesn't slide, it just pops open, so I can't offer any help on that. The notification bar itself is just a TPanel with a TImage and TLabel for the image/text. It's placed on the main window at design time and it's set to align bottom. Normally it's hidden, and when there's a message to display we set the Visible property to true.
There's different ways to hide the notification, depending on how you want it to behave. In BC we install keyboard and mouse hooks (SetWindowsHookEx with WH_KEYBOARD or WH_MOUSE) and hide it on key up and mouse button events. Alternatively, like Mark said, you could hide it after a delay, add a close button to the side, or just watch for specific events in your app and manually hide it then.
In Delphi, I believe that you can change a property on the Dialog itself (change the window type away from "Dialog" and select the standard windowed alternative). Sorry I cannot be more specific, it has been about two years since I last worked on a Delphi app.

Resources