Based on CFNotificationCenter example here
https://stackoverflow.com/a/6969178/5329717
#include <CoreFoundation/CoreFoundation.h>
#include <UIKit/UIApplication.h>
void uiApplicationWillResignNotificationCallback (CFNotificationCenterRef center,
void * observer,
CFStringRef name,
const void * object,
CFDictionaryRef userInfo) {
CFShow(CFSTR("Received uiApplicationWillResignNotification"));
}
void exampleHandling() {
CFNotificationCenterRef center = CFNotificationCenterGetLocalCenter();
// add an observer
CFNotificationCenterAddObserver(center, NULL, uiApplicationWillResignNotificationCallback,
(__bridge CFStringRef)UIApplicationWillResignActiveNotification, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
//remove observer
CFNotificationCenterRemoveObserver(center, uiApplicationWillResignNotificationCallback, (__bridge CFStringRef)UIApplicationWillResignActiveNotification, NULL);
}