Created
August 18, 2015 14:33
-
-
Save shinvou/e8ca0913415b2a9b04c3 to your computer and use it in GitHub Desktop.
Present notifications that keep in notification center
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" CFTypeRef SecTaskCopyValueForEntitlement(void* task, CFStringRef entitlement, CFErrorRef *error); | |
static void PresentBannerWithMessageForIdentifier(NSString *message, NSString *identifier, NSDictionary *userInfo) | |
{ | |
UILocalNotification *notification = [objc_getClass("UILocalNotification") new]; | |
[notification setAlertBody:message]; | |
[notification setUserInfo:userInfo]; | |
//[notification setApplicationIconBadgeNumber:0]; | |
[notification setHasAction:YES]; | |
[notification setAlertAction:nil]; | |
[SBSLocalNotificationClient scheduleLocalNotification:notification bundleIdentifier:identifier]; | |
} | |
CFTypeRef (*original__SecTaskCopyValueForEntitlement)(void *task, CFStringRef entitlement, CFErrorRef *error); | |
CFTypeRef replaced__SecTaskCopyValueForEntitlement(void *task, CFStringRef entitlement, CFErrorRef *error) | |
{ | |
CFTypeRef ret = original__SecTaskCopyValueForEntitlement(task, entitlement, error); | |
NSString *entitlementString = CFBridgingRelease(entitlement); | |
if ([entitlementString isEqualToString:@"com.apple.localnotification.schedulingproxy"]) { | |
ret = kCFBooleanTrue; | |
} | |
return ret; | |
} | |
%ctor { | |
@autoreleasepool { | |
if ([[[NSClassFromString(@"NSProcessInfo") processInfo] processName] isEqualToString:@"SpringBoard"]) { | |
MSHookFunction(MSFindSymbol(NULL, "_SecTaskCopyValueForEntitlement"), (void *)replaced__SecTaskCopyValueForEntitlement, (void **)&original__SecTaskCopyValueForEntitlement); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment