The application is located in PhoneGap. I am using the push notification function with https://github.com/marknutter/GCM-Cordova
I implemented the whole function and worked until yesterday. When I checked the application on the last day, the push notification does not work when the application does not work. All notifications are received on my device, clicking on the message opens the application.
But the controls do not get in the javascript part where the message notification is processed.
Code from the GCMIntentService.java file:
JSONObject json; json = new JSONObject().put("event", "message"); json.put("message", extras.getString("message")); json.put("link", extras.getString("link")); Log.v(ME + ":onMessage ", json.toString()); GCMPlugin.sendJavascript( json );
This code will work when a message is received. But at that time, the application is not working.
When I click on a notification, the application opens, as usual, without registering a message event; thereby not gaining control of JavaScript to handle push notifications.
The code for CORDOVA_GCM_script.js is available at:
https://github.com/marknutter/GCM-Cordova/blob/master/assets/www/CORDOVA_GCM_script.js
Note : it works fine when the application is running.
EDIT: Notification is sometimes done. JavaScript receives a random message event.
EDIT 2:
I definitely know the problem.
From the java file, it runs javascript code when opening the application by clicking on the push notification message. But at that time, WebView is not loading, so the script (which is the event trigger) cannot be executed. This condition, everyone who uses the plugin will experience the same thing. Is there any workaround or some fix for it?
Am I doing something wrong?