Is there a away to detect the event when iOS device goes to sleep mode (when the screen gets blackened)?

You basically already have the solution, which I’m guessing you found from one of my recent answers 🙂 Use the com.apple.springboard.hasBlankedScreen event. There are multiple events that occur when the screen blanks, but this one should suffice: CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center NULL, // observer hasBlankedScreen, // callback CFSTR(“com.apple.springboard.hasBlankedScreen”), // event name NULL, // object CFNotificationSuspensionBehaviorDeliverImmediately); where the … Read more

iOS touch event notifications (private API)

You can use the IOHID stuff in IOKit to get the x, y coordinates. #include <IOHIDEventSystem.h> create IOHIDEventSystemClient: void *ioHIDEventSystem = IOHIDEventSystemClientCreate(kCFAllocatorDefault); register callback: IOHIDEventSystemClientScheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); IOHIDEventSystemClientRegisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL); unregister callback: IOHIDEventSystemClientUnregisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL); IOHIDEventSystemClientUnscheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); callback: void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) { if (IOHIDEventGetType(event)==kIOHIDEventTypeDigitizer){ IOHIDFloat … Read more

Detect carrier connection type (3G / EDGE / GPRS)

From iOS 7 on you can use: CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new]; NSLog(@”Current Radio Access Technology: %@”, telephonyInfo.currentRadioAccessTechnology); [NSNotificationCenter.defaultCenter addObserverForName:CTRadioAccessTechnologyDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification *note) { NSLog(@”New Radio Access Technology: %@”, telephonyInfo.currentRadioAccessTechnology); }]; I have also found this to detect a slow or fast connection: – (BOOL)isFast:(NSString*)radioAccessTechnology { if ([radioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) { return NO; } else … Read more

Get CellID, MCC, MNC, LAC, and Network in iOS 5.1

I know three ways on how you can do it on iOS 5.x – 7.x. All of them use private APIs from CoreTelephony.framework. Supports both GSM and UMTS. 1) Using cell monitor struct CTResult { int flag; int a; }; extern CFStringRef const kCTCellMonitorCellType; extern CFStringRef const kCTCellMonitorCellTypeServing; extern CFStringRef const kCTCellMonitorCellTypeNeighbor; extern CFStringRef const … Read more

Finding Private API Call _terminateWithStatus

You have to run otool on the executable, not on the app wrapper. For example (sorry for the formatting weirdness): $ otool -L WriteRoom.app/Contents/MacOS/WriteRoom WriteRoom.app/Contents/MacOS/WriteRoom (architecture ppc): @executable_path/../Frameworks/Blocks.framework/Versions/A/Blocks (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.3) … Read more

How to set lock screen , wallpaper and Ringtone programmatically in iPhone?

This can all be done easily, but will be rejected by Apple. The ringtone can be changed by altering com.apple.SpringBoard.plist, specifically the ringtone key. The following code can be used to read the actual ringtone title of custom ringtones (synced by iTunes). NSMutableDictionary *custDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@”/private/var/mobile/Media/iTunes_Control/iTunes/Ringtones.plist”]; NSMutableDictionary *dictionary = [custDict objectForKey:@”Ringtones”]; NSArray *keys … Read more