Details
-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
Description
If a configuration string with either no alert field or an alert field with an empty string is sent to a cordova Android app that is in the background, the plugin crashes the app. When the App is in the foreground, the notification works OK.
e.g. if the following confirmation payload is passed to the Android variant on a Push server
{
variants => [ "Android variant String" ] ,
alias => [ "Android device" ] ,
ttl => 600 ,
message => {
data =>
}
when the Android Cordova app is simply in the background, then a message pops up saying the app has stopped.
{
variants => [ "Android variant String" ] ,
alias => [ "Android device" ] ,
ttl => 600 ,
message => {
alert => "Notification" ,
data => { Verb => "GetDisruptions" }
}
If you add an alert string with something in it, then there is no crash. However alert => "" will still cause a crash.
It appears to be related to this line
54 if (!PushPlugin.isInForeground() && message.getString("alert").length() != 0)
in the github repository aerogear-cordova-push/src/android/org/jboss/aerogear/cordova/push/NotificationMessageHandler.java
I think the behaviour should be that when a notification is received in the background without and alert field OR and an empty alert field string, a call is simply made to the notification handler and NO notification is displayed. This would mimic the content-available:1 flag in iOS.
Rob