NSUserNotification not showing action button

前端 未结 4 1378
梦毁少年i
梦毁少年i 2021-01-30 16:47

I\'m using this code:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    NSUserNo         


        
4条回答
  •  遥遥无期
    2021-01-30 17:41

    As a contrary instance for other answers we can use iTunes - it still showing "Skip" button even when we setup alert style to banners. So I continued searching and found this github repo where Indragie Karunaratne provide some useful additional properties in NSUserNotification private headers. You can check for full list of the properties in the NSUserNotification_Private.h file, but actual for showing buttons in banner notification style is

    @property BOOL _showsButtons; // @dynamic _showsButtons;
    

    so you can just add this line to you code

    [notification setValue:@YES forKey:@"_showsButtons"];
    

    and your notification action button will become independent on alert style.

提交回复
热议问题