1

I spent almost 3 days getting PushPlugin work with my app. I had the following issues and for this I had to modify the PushPlugin as suggested by "https://github.com/kentmw/PushPlugin"

  1. When app is paused or closed pushBundle was not getting passed to the app. (There were so many strugling with this issue. This issue has been discussed on the gitbucket also. The discussion was not very clear on how to solve this issue. So I am writing this question and answering it too.)

  2. If the notification is cleared(not clicked) by user, pushBundle was not getting passed to the app.

  3. I am making few more changes suitable for my app.

Kishor Pawar
  • 3,386
  • 3
  • 28
  • 61
  • Great question. I [answered](http://stackoverflow.com/a/29437083/1761793) a similar problem before. It probably solves #1 and #2. Please create and submit a pull request at [PushPlugin](https://github.com/phonegap-build/PushPlugin), and add a comment to my answer. That way more people will come to know of this solution. It might even get merged in the original repository. – Ajoy Aug 24 '15 at 04:09
  • Also, it would be less complex, if you keep this question specifically for one purpose. You could solve all changes in #3 in a different question. – Ajoy Aug 24 '15 at 04:11

1 Answers1

1

So according to the author, you have to register your app with Google GCM server everytime you open the app, in order to make callback function available to call when the notification received.

So I did the following changes accordingly.

In Plugin the changes are diffed here.

Here in this changes look deeply for pushCachedExtras(). on what occasions it has been called.

The changes have made to 2 files
1. src/android/com/plugin/gcm/PushPlugin.java
2. www/PushNotification.js

in you code you have to do something like

if(ALREADY_REGISTERED) {  
    pushNotification.setECB(success, error, { "senderID" :"SENDER_ID_HERE","ecb": "window.onNotificationGCM" });  
 } else { 
    pushNotification.register(success, error, { "senderID" :"SENDER_ID_HERE","ecb": "window.onNotificationGCM" });  
 }  

Every time you have to make event callback available when the app starts, till then pushBundle is "cached".

Debugging Plugin

adb logcat -s GCMIntentService:* PushPlugin:*

Note : I am working on 2 and 3 point, and shall made changes to plugin for iOS also.

lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
Kishor Pawar
  • 3,386
  • 3
  • 28
  • 61