I have some data saved with preference bundle controller class. I want to share it with its tweak file i.e. I want springboard to be able to communicate preference bundle in order to get some data from it and vice versa. I have tried to use Libobjcipc - as written in its documentation:
libobjcipc is a developer library that provides an inter-process communication (between app and SpringBoard) solution for jailbroken iOS. It handles the socket connections between SpringBoard and app processes...
I have tried to send message from tweak, but unable to figure it out how to receive incoming message in my preference bundle controller. I know the method [OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:handler:]
will be used for this purpose. But where do I use it? Hope for some positive response... Thanks..
EDIT:
I have tried using CFNotificationCenter
after suggestion of @creker. I can send notification, but my tweak cannot receive it, and so callback method callBackNotification
isn't executed. Here is changed code:
Tweak.xm
//at the end of tweak file
static void callBackNotification(CFNotificationCenterRef center,void *observer,CFStringRef name,const void *object,CFDictionaryRef userInfo)
{
NSLog(@"Notification received!");
}
%ctor
{
NSLog(@"Init cqlled!"); //this piece of code called successfully
//Register for the change notification
CFNotificationCenterRef r = CFNotificationCenterGetDarwinNotifyCenter();
CFNotificationCenterAddObserver(r, NULL, reloadPrefsNotification, CFSTR("ccom.identifier.message"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}
Preference Bundle Controller
@interface SettingsListController: PSListController {
}
@end
@implementation SettingsListController
- (id)specifiers {
if(_specifiers == nil) {
_specifiers = [[self loadSpecifiersFromPlistName:@"JRLockerSettings" target:self] retain];
}
return _specifiers;
}
-(void) postNotification()
{
CFNotificationCenterRef center = CFNotificationCenterGetLocalCenter();
// post a notification
CFDictionaryKeyCallBacks keyCallbacks = {0, NULL, NULL, CFCopyDescription, CFEqual, NULL};
CFDictionaryValueCallBacks valueCallbacks = {0, NULL, NULL, CFCopyDescription, CFEqual};
CFMutableDictionaryRef dictionary = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
&keyCallbacks, &valueCallbacks);
CFDictionaryAddValue(dictionary, CFSTR("identifier"), CFSTR("value"));
CFNotificationCenterPostNotification(center, CFSTR("com.identifier.message"), NULL, dictionary, TRUE);
CFRelease(dictionary);
}
@end