Vous pouvez utiliser darwin notification center et utilisez le nom de l'événement com.apple.springboard.fullycharged.
De cette façon, vous obtiendrez une notification à votre méthode personnalisée, voici un code snip:
// Registering for a specific notification
NSString *notificationName = @"com.apple.springboard.fullycharged";
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
yourCustomMethod,
(__bridge CFStringRef)notificationName,
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
// The custom method that will receive the notification
static void yourCustomMethod(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
NSString *nameOfNotification = (__bridge NSString*)name;
if([nameOfNotification isEqualToString:notificationName])
{
// Do whatever you want...
}
}
Belle touche sur la liaison Google, je ris. Bonne question, m'a fait gagner du temps. Merci à vous et aux contributeurs. –