havesource / cordova-plugin-push

Register and receive push notifications
MIT License
150 stars 283 forks source link

Notifications arrive when using "notification" but rarely when using "data". #57

Open spinninghamster opened 3 years ago

spinninghamster commented 3 years ago

My $data payload is:

                          'tag'=>'new_messages',
             'title'=>$val['push_title'],
             'body'=>$val['push_message'],
             'vibrate'  => 1,           
                  'soundname'=> 'beep',
                  'android_channel_id'=>$channel,
                  'content-available'=>1,
                  'count'=>1,
                  'badge'=>1,
                  'notId'=>1,
                  'push_type'=>$val['push_type'],
                  'icon'=>'icon_default',
                  'iconColor'=>'green',
                  'image'=>'icon_large_default',

I initially had the code like:

                         'registration_ids'     => $registrationIds,
            'data' => $data,
            'priority'=>'high',
            'collapse_key'=>'new_messages',

and notifications rarely arrived. Maybe 1 out of 20 arrived. When I switched from "data" to "notification", they arrived immediately, without missing even a single one. The problem is, the parameters like "iconColor", etc. don't seem to get picked up.

                         'registration_ids'     => $registrationIds,
            'notification' => $data,
            'priority'=>'high',
            'collapse_key'=>'new_messages',

What could be the reason for this? I can't figure it out. They really almost never arrive when using "data" but immediately and always when using "notification".

IllusionVK commented 3 years ago

Hey @spinninghamster are you using iOS or Android ? and do you send through APNS or FCM ? My understanding is that android and iOS need the data structured in different ways, as we previously had problems with this between the platforms. I'd be interested to know if you resolved this as we also need to send data messages.