I'm a newbie phonegap developer but I have several years developing with objective-C.
I'm trying to execute code in JS (phonegap) from a remote notification in iOS. I have working for several days with https://github.com/phonegap-build/PushPlugin
What I could achieve is to:
- Get Device token
- execute code in JS when the app is in foreground
Not achieved :
- execute code in JS when the app is in background
- execute code in JS when the app is stopped.
After a close analysis of the plugin I figured out that the plugin save the notification and launches them when the app is in foreground.
Next I tried to modify the plugin to be able to execute my js code. What I did, It was to comment these lines.
<!-- language: objective-c -->
//if (application.applicationState == UIApplicationStateActive) {
PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"];
pushHandler.notificationMessage = userInfo;
pushHandler.isInline = YES;
[pushHandler notificationReceived];
//} else {
//save it for later
self.launchNotification = userInfo;
//}
I didn't succeed and I couldn't find out why the webview is not loaded and the code isn't executed. Is it possible to execute like this? Or I will have to tho a new plugin and execute the code in objective-c?