Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
109 stars 139 forks source link

Error When Receiving Push Notification on Android #361

Closed jamesonnetworks-clearcost closed 2 years ago

jamesonnetworks-clearcost commented 2 years ago

I'm getting the following error when I push a notification to pushwoosh

E/Pushwoosh: [CordovaPlugin] Not correct parameters passed (missing parameters) org.json.JSONException: No value for userData at org.json.JSONObject.get(JSONObject.java:403) at org.json.JSONObject.getString(JSONObject.java:564) at com.pushwoosh.plugin.pushnotifications.PushNotifications.createLocalNotification(PushNotifications.java:304) at java.lang.reflect.Method.invoke(Native Method) at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:677) at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98) at org.apache.cordova.PluginManager.exec(PluginManager.java:140) at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:335) at android.os.Looper.loopOnce(Looper.java:161) at android.os.Looper.loop(Looper.java:288) at android.os.HandlerThread.run(HandlerThread.java:67)

When I debug, the payload is:

{"msg":"This is a test message","seconds":30}

which does not include the userData field

wfhm commented 2 years ago

@jamesonnetworks-clearcost Checking it. Meanwhile could you please specify what cordova-android version is used in your project?

jamesonnetworks-clearcost commented 2 years ago

cordova-android is at version 10.1.0.

I've also reached out through support and they informed me that my AndroidManifest file doesn't include FirebaseMessaging classes, so I'm looking into that as well. I was under the impression that Ionic 5 and Cordova would automagically handle that stuff, but I def could have things misconfigured.

wfhm commented 2 years ago

@jamesonnetworks-clearcost yes, that service is added by our SDK, and manifest merger should add it to your final AndroidManifest.xml automatically. And this service is unrelated to handling local notifications, so it should not be the source of the issue.

Right now, the createLocalNotification() method expects 3 parameters, including "userData", while our docs clearly state that "userData" should be optional. We'll fix this with the next plugin release, meanwhile, you can add an additional "userData" parameter with any value to the createLocalNotification() method call as a workaround.

jamesonnetworks-clearcost commented 2 years ago

That's awesome @wfhm and def looks like it will fix my issue. Thanks for your support on this!

wfhm commented 2 years ago

Fixed with the latest version.