Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap Plugin - append lines to app delegate

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.

like image 644
Asaf Avatar asked Jan 31 '14 21:01

Asaf


1 Answers

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");

}
like image 105
jcesarmobile Avatar answered Sep 30 '22 05:09

jcesarmobile