@@ -64,19 +64,29 @@ protected void onMessage(Context context, Intent intent) {
64
64
if (extras != null )
65
65
{
66
66
// if we are in the foreground, just surface the payload, else post it to the statusbar
67
- if (PushPlugin .isInForeground ()) {
67
+ if (PushPlugin .isInForeground ()) {
68
68
extras .putBoolean ("foreground" , true );
69
- PushPlugin .sendExtras (extras );
69
+ PushPlugin .sendExtras (extras );
70
70
}
71
71
else {
72
72
extras .putBoolean ("foreground" , false );
73
-
74
- // Send a notification if there is a message
75
- if (extras .getString ("message" ) != null && extras .getString ("message" ).length () != 0 ) {
76
- createNotification (context , extras );
77
- }
78
- }
79
- }
73
+ String message = extras .getString ("message" );
74
+
75
+ if (message === null ) {
76
+ // Providers like Parse always send a 'data' as root object, so "Parse" that
77
+ try {
78
+ JSONObject object_example = new JSONObject (extras .getString ("data" ));
79
+ message = object_example .getString ("alert" );
80
+ }
81
+ catch (JSONException e ) {}
82
+ }
83
+
84
+ // Send a notification if there is a message
85
+ if (message && message .length () != 0 ) {
86
+ createNotification (context , extras );
87
+ }
88
+ }
89
+ }
80
90
}
81
91
82
92
public void createNotification (Context context , Bundle extras )
0 commit comments