Phonegap插件 - 将行添加到app delegate

Asa*_*saf 8 config ios phonegap-plugins cordova

我正在开发一个phonegap插件.到现在为止还挺好.现在我想通过config.xml将1或2个方法附加到AppDelegate.m,以便自动为开发人员填充它.可能吗?

谢谢.

jce*_*ile 7

看一下Push Plugin,他们使用了appDelegate的objective-c类别

https://github.com/phonegap-build/PushPlugin

如果您只是想在应用程序变为活动状态时收到通知,则无需更改AppDelegate上的任何内容,只需将其放在您的插件上:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil]; 

- (void)onAppDidBecomeActive:(NSNotification*)notification
{

     NSLog(@"%@",@"applicationDidBecomeActive");

}
Run Code Online (Sandbox Code Playgroud)