parse-community / parse-community/parse-server-push-adapter

Remote notifications with an expiration date not being delivered

Open
#56 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
96
Forks
108
PR merge metrics
No merged PRs in 30d

Description

So my application is using the Parse platform to send notifications to different devices and to ensure that the device receives the notification I've added an expiration time to it.

This works sometimes whenever the device is in airplane mode but it almost never works whenever I switch the device off and turn it back on the notification doesn't get delivered to the device. Below are the steps I take to test this:

  • Put phone in airplane mode for more than 5 minutes and connect back to wifi: Sometimes the notification is delivered or it's delivered with a delay with no sound or vibrations.
  • Switch the phone off completely for more than 5 minutes and turn it back on: The notification is never delivered.

Like I mentioned I'm using the Parse SDK and I'm mainly using the cloud code which is written in JS to get the time 4 hours from now and create a date object from this since this is what is required for the expiration_time parameter.

Here is the code I'm using to get the time 4 hours from now.

// Expiration date
var now = new Date();
var futureTime = now.setHours(now.getHours() + 4);
var expireDate = new Date(futureTime);

Then I'm using an object to create my own payload since I want to use rich notifications within my iPhone application. Below is the structure of the JS object of the payload, note the expireDate used from above.

// Get the device from installations
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo("deviceToken", withToken);

// APNS Payload
var payload = {
    where: pushQuery,
    expiration_time: expireDate,
    data: {
        sound : "Wakeup.wav",
        aps: {
            alert: {
                title : "Good morning!",
                subtitle: "Today's forcast in " + withCity,
                body: withSummary
            },
           "mutable-content" : 1,
           icon: withIcon
        }
    }
};

Then this is just sent using the standard Parse push function as you can see below.

Parse.Push.send(payload,{ useMasterKey: true,
    success: function() {
        response.success("Successful push, future time: " + futureTime + " Date object: " + new Date(futureTime));
    },
    error: function(error) {
        response.error("Failed");
    }

});

I was just wondering if anyone could give any insight into why this may be happening at all? I don't know if this will help but the device I'm using is and it's current status is:

  • Device: iPhone 5
  • OS: iOS 10.2
  • Battery level: 49%

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JavaScript cloud-code path calling Parse.Push.send and inspect how expiration_time is handled alongside the APNS payload. Reproduce the airplane-mode and powered-off cases described for the iPhone 5 on iOS 10.2; done means identifying whether delivery behavior is an adapter or APNS limitation and documenting or correcting the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.