0

I am sending CFNotification from UIApplication to console application. But i did not get the notification into console application.

here is my code.

// Posting notification from UIApplication 
// this code in objective-c

CFNotificationCenterRef distributedCenter;

distributedCenter = CFNotificationCenterGetDistributedCenter();

 CFMutableDictionaryRef info = CFDictionaryCreateMutable(kCFAllocatorDefault,0,NULL,NULL);
    CFDictionaryAddValue(info, CFSTR("key"), CFSTR("value"));
    CFNotificationCenterPostNotification(distributedCenter,(__bridge CFStringRef)"notificationName",0,info,true);


// listening code in commandline application

let notifierNotificationReceiveName = "console-Notification"
let voidPtr = BridgeUtil.bridge(self)
let distributedCenter = CFNotificationCenterGetDistributedCenter()

CFNotificationCenterAddObserver(distributedCenter, voidPtr, { (_, observer, name, message, userInfo ) -> Void in

        if (observer != nil){
            let thisView : NotificationHandler = BridgeUtil.bridge(observer!)
                var i = 1
                i = i+1
            }
        }
    }, "notificationName" as CFString, nil, .deliverImmediately)
Ashkar
  • 35
  • 7

0 Answers0