Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

MacOS Native Plugin - NSApplicationDidFinishLaunchingNotification

Discussion in 'macOS' started by erlemaitre, Jan 16, 2021.

  1. erlemaitre

    erlemaitre

    Joined:
    Oct 30, 2018
    Posts:
    24
    Hello,
    I'm trying to create a native plugin for macOS. My goal is to subscribe to the NSApplicationDidFinishLaunchingNotification inside my plugin, but I can't get it working.

    I setup my class to subscribe to the notification inside the load() method, but the notification is never received. It works perfectly on iOS and tvOS, but not on macOS.

    Here is the Objective-C code:
    Code (CSharp):
    1. + (void)load{
    2.     NSLog(@"The plugin is loaded!");
    3. #if TARGET_OS_OSX
    4.     [[NSNotificationCenter defaultCenter] addObserver:[self shared] selector:@selector(applicationDidFinishLaunching:) name:NSApplicationDidFinishLaunchingNotification object:nil];
    5. #else
    6.     [[NSNotificationCenter defaultCenter] addObserver:[self shared] selector:@selector(applicationDidFinishLaunching:) name:UIApplicationDidFinishLaunchingNotification object:nil];
    7. #endif
    8. }
    Any idea why this is not working ?