直接上代码,首先是在daemon中创建了一个server
<p class="p1"><span class="s1">@interface</span> Capture : NSObject</p>
<p class="p1">- (<span class="s1">void</span>)startcallback:(NSString *)name userInfo:(NSDictionary *)userInfo;</p>
<p class="p1"></p>
<p class="p2">@end</p>
<p class="p3">
</p>
<p class="p2">@implementation<span class="s2"> Capture</span></p>
<p class="p1">- (<span class="s1">void</span>)startcallback:(NSString *)name userInfo:(NSDictionary *)userInfo;</p>
<p class="p1">{</p>
<p class="p3"> </p>
<p class="p4"><span class="s2"> NSLog(</span>@"lw:callback~"<span class="s2">);</span></p>
<p class="p1">}</p><p class="p1">
</p><p class="p1">
</p><p class="p1">
</p>
然后呢,app中的client:
- (IBAction)findme:(id)sender
输出:
并没有执行callback。(在iOS6上是可以的)
然后网上搜了一下,发现iphonewiki上说了这么一段话:
If you want to run a server inside a daemon, then you still need a simple SpringBoard tweak, that just has to call bootstrap_unlock with the service name (take the code from the rocket bootstrap header and include bootstrap.h). Then you can run a server with the same name inside your daemon. rocketbootstrap_distributedmessagingcenter_apply must still be called on both the server and on the clients. It even works for sendMessageAndReceiveReplyName.
大概是说在daemon创建CPD的server的话必须先在一个SB的tweak中调用bootstrap_unlock(your-server-name)。于是我又新建了一个sb的tweak,并在里面调用了bootstrap_unlock
#import <rocketbootstrap.h>
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application{
%orig;
rocketbootstrap_unlock("123lw");
NSLog(<span id="kM0.21753494115546346">@"lw:start 123lw"</span>);
}
%end
但是还是不行,哭了~~
谁能指点一下,先谢过了~