跨进程传输数据问题

想使用rocketbootstrap实现一个主app和分身app的同步功能。通过主app发送数据给分身app,然后分身app调用app类中的方法
server端的代码,hook springboard可以接收到消息,在app中initService方法中注册监听接收不了消息是为什么?
另外我尝试使用全局变量来保存springboard接收到的数据,但是在MessengerAppDelegate中调用该变量内容却是空的。

%hook MessengerAppDelegate

  • (void)initService
    {
    %orig;
    CPDistributedMessagingCenter *c = [%c(CPDistributedMessagingCenter) centerNamed:@“com.my.check”];
    rocketbootstrap_distributedmessagingcenter_apply(c);
    [c runServerOnCurrentThread];
    [c registerForMessageName:@“myMessageName” target:self selector:@selector(handleMessageNamed:withUserInfo:)];
    NSLog(@“注册监听 start”);

}
%new

  • (void)handleMessage:(NSString *)name withUserInfo:(NSDictionary *)userInfo {
    NSLog(@“handleMessage withUserInfo:%@”,userInfo);

    //TODO:something
    }

%end

%hook SpringBoard

  • (void)applicationDidFinishLaunching:(id)application {
    %orig;
    CPDistributedMessagingCenter *c = [%c(CPDistributedMessagingCenter) centerNamed:@“com.my.check”];
    rocketbootstrap_distributedmessagingcenter_apply(c);
    [c runServerOnCurrentThread];
    [c registerForMessageName:@“myMessageName” target:self selector:@selector(handleMessage:withUserInfo:)];
    NSLog(@“注册监听 start123123”);
    }

%new

  • (void)handleMessage:(NSString *)name withUserInfo:(NSDictionary *)userInfo {
    //NSLog(@“handleMessage%@ withUserInfo:%@”,name, userInfo);
    //TODO:something
    NSLog(@“message nsParmas %@”, nsParmas);
    }

%end

希望大神们帮帮我。实在是一点头绪都没了。

不嫌麻烦的话,跨进程本地通讯还有个方案就是socket,创建TCP通道来通讯。
端口用1024以上的数字,避开常用端口,如1080 8888等。

感谢您的回帖帮助,现在暂时的解决办法是 在SpringBoard中起一个服务进行双向通讯来解决跨进程数据共享的问题。
就是不知道能否有更好的解决方案。

XPC直接解决,本身就支持不同app内对象互相调用

楼主,请问解决主App发送数据给另外app了吗?