Phonegap Plugin - append lines to app delegate

2019-06-16 11:40发布

I'm developing a phonegap plugin. So far so good. Now I would like to append 1 or 2 methods to the AppDelegate.m through the config.xml so it will be populated for the developer automatically. Is it possible?

Thanks.

1条回答
虎瘦雄心在
2楼-- · 2019-06-16 12:09

take a look into the Push Plugin, they use an objective-c category for the appDelegate

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

If you just want to be notified when the app becomes active you don't need to change anything on the AppDelegate, just put this on your plugin:

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

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

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

}
查看更多
登录 后发表回答