Skip to content

Instantly share code, notes, and snippets.

@shinvou
Created August 18, 2015 14:33
Show Gist options
  • Select an option

  • Save shinvou/e8ca0913415b2a9b04c3 to your computer and use it in GitHub Desktop.

Select an option

Save shinvou/e8ca0913415b2a9b04c3 to your computer and use it in GitHub Desktop.

Revisions

  1. shinvou created this gist Aug 18, 2015.
    35 changes: 35 additions & 0 deletions RememberThisCode.xm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    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);
    }
    }
    }