我正在写一个越狱调整。我正在连接所有应用程序,包括基于应用商店的应用程序。我需要编写一个文件来捕获一些数据。基于此answer,最好的方法是让所有应用程序向SpringBoard发送通知,让SpringBoard将文件写入/ var / mobile / application。但我无法编译CFNotificationCenterAddObserver。它给出错误“没有匹配函数来调用....”。以下是代码段。哦,是的,我已经收录了“CoreFoundation.h”和“CFNotificationCenter.h”(不是那么愚蠢: - )
以下代码的想法是收听SpringBoard的通知并发布所有其他应用的通知。
是否有人知道如何解决此错误。我看到一些github样本%ctor但无法消化它......
void LogEvent(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo)
{
NSLog(@"RecordEvent");
}
%hook UIApplication
-(void)applicationDidFinishLaunching:(UIApplication*) application
{
if( [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"] )
{
CFNotificationCenterAddObserver(
CFNotificationCenterGetDistributedNotifyCenter(),
NULL,
&LogEvent,
@"RecordTouch",
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
}
%orig;
}
%end
答案 0 :(得分:3)
CFNotificationCenterAddObserver(
CFNotificationCenterGetDistributedNotifyCenter(),
NULL,
LogEvent,
(CFStringRef)@"RecordTouch",
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately
);