14

How can we bounce the dock icon of our application?

Eimantas
  • 48,927
  • 17
  • 132
  • 168
Amit Battan
  • 305
  • 3
  • 12

2 Answers2

25

You can use the requestUserAttention: from NSApplication. The NSRequestUserAttentionType allows you to specify whether the Dock icon will bounce once or until the application is activated.

vrwim
  • 13,020
  • 13
  • 63
  • 118
Laurent Etiemble
  • 27,111
  • 5
  • 56
  • 81
8

sorry it works... my focus was on my application when I test it... Its works when my focus is not on application

[NSApp requestUserAttention:NSCriticalRequest];

Is any way to bounce the icon even focus on application...

Amit Battan
  • 305
  • 3
  • 12
  • 3
    I think you don't have to request user attention if your application is active as the user is, well, using your application. Maybe you should consider using the Growl framework to display visual notifications. – Laurent Etiemble Jan 08 '10 at 12:25
  • Swift 3: `NSApp.requestUserAttention(.criticalRequest)` There is also: `.informationalRequest` Which seems to only bounce a few times. @Laurent Etiemble More subtle. – Sentry.co Aug 13 '17 at 19:25