来自申请
notify_post("com.yourcompany.yourapp.yournotification");
来自 迪利布
#import <objc/runtime.h>
#import <SpringBoard/SBWiFiManager.h>
HOOK(SpringBoard, applicationDidFinishLaunching$, void, id app) {
//Listen for events via DARWIN NOTIFICATION CENTER
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL,
&NotificationReceivedCallback, CFSTR("com.yourcompany.yourapp.yournotification"), NULL,
CFNotificationSuspensionBehaviorCoalesce);
}
//THIS IS WHERE THE MAGIC HAPPENS
static void NotificationReceivedCallback(CFNotificationCenterRef center,
void *observer, CFStringRef name,
const void *object, CFDictionaryRef
userInfo)
{
[[objc_getClass("SBWiFiManager") sharedInstance] setWiFiEnabled:NO];
}
Note:
如果你在使用Hook方法时遇到错误,可以参考这个link http://brandontreb.com/beginning-jailbroken-ios-development-your-first-tweak它演示了如何挂钩 SpringBoard 中的 init 方法以在启动手机时显示警报消息。
Warning:
由于使用了私有 api,因此您不能将其用于应用商店应用程序。
参考 https://stackoverflow.com/a/2152933/730807
归因 https://stackoverflow.com/users/171206/wrightscs
希望这可以帮助。