Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

iOS: Can't process background notification on low battery #2937

Open
KorzeniewskiGrzegorz opened this issue Jul 23, 2020 · 0 comments
Open

Comments

@KorzeniewskiGrzegorz
Copy link

Expected Behaviour

In iOS,background notifications should be processed every time, regardless the low battery (<20%).

Actual Behaviour

On iOS, i am able to process notification in background ONLY if the battery percentage is greater than 20% . If it's less , i only receive the notification, but it is not processed in background (doesn't matter if the device is being charged or not).

Steps to Reproduce

  1. Battery percentage less than 20% ( doesn't matter if the device is being charged or not).
  2. Send notification to the device with content_available set to true (FCM legacy API).
  3. See if notification is processed in background.
  4. Charge battery more than 20%.
  5. Send notification.
  6. The device should process the notification in background.

Platform and Version

iOS 13.5.1

Cordova CLI version and cordova platform version

cordova --version              9.0.0
cordova platform version ios   5.1.1
xcode                          11.3

Plugin version

 phonegap-plugin-push  2.3.0

Sample Push Data Payload

I am using legacy FCM API :

{
"registration_ids":"aValidToken",
"notification":{
    "body":"Some body",
    "title":"Some Title",
    "vibrate":1,
    "sound":"default",
    },
 "content_available":true,
 "data":{
      "tipomensaje":"mensajesimple",
     },
 "priority":"high",
}

Sample Code that illustrates the problem

code that I use to process notification:

` push = PushNotification.init({
            android: {},
          browser: {
            pushServiceURL: 'http://push.api.phonegap.com/v1/push'
          },
          ios: {
            alert: 'true',
            badge: 'true',
            sound: 'true'
          },
          windows: {}
        });
        push.on('registration', function(data) {
            localStorage.setItem('regId', data.registrationId);
            $('#regId').val(data.registrationId);
        });
        push.on('error', function(e) {
            debug("push error = " + e.message);
        });

        push.on('notification', function(data) {
            push.getApplicationIconBadgeNumber(function(count) {
                debug('get badge : ' + count);
                count++;

                push.setApplicationIconBadgeNumber(function() {
                    debug('set badge : ' + count);
                }, function() {
                    debug('set badge error');
                }, count);

            }, function() {
               debug('get badge error: ' + count);
            });

            var configuracion = data.additionalData;

            if(configuracion.foreground){
                $('#centro_mensajes').css('display','block');
                $('#aviso_mensaje').text(data.title +"\n"+data.message);
                actualizaruids();
            }

            msg_id = data.additionalData['gcm.message_id'];
             push.finish(
            () => {
                debug('processing of push data is finished for ID=' +  msg_id);
            },
            () => {
                debug('something went wrong with push.finish for ID =' +  msg_id);
            },
           msg_id
        );
        });

Logs taken while reproducing problem

none

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant