Skip to content

Conversation

Stafox
Copy link
Contributor

@Stafox Stafox commented Jan 30, 2017

Add possibility to get headers when send push to be able to fetch X-Push-Status-Id

@montymxb
Copy link
Contributor

@Stafox Took a look at this locally to verify everything. X-Parse-Push-Status-Id is present and accounted for in the return value. There is one issue I found regarding a missing parameter in the final return call in ParsePush::send:

return ParseClient::_request(
            'POST',
            'push',
            null,
            json_encode(ParseClient::_encode($data, true)),
            $useMasterKey,
            'application/json',
            true
        );

Directly after $useMasterKey and before the content type there is another parameter called$appRequest. You should update your call to ParseClient::_request to account for that parameter as follows.

return ParseClient::_request(
            'POST',
            'push',
            null,
            json_encode(ParseClient::_encode($data, true)),
            $useMasterKey,
            false,    // app request parameter
            'application/json',
            true
        );

You can simply use false, which is the default (the parameter is only ever used in ParseApp, which is somewhat vestigial at this point to be honest).

Once you make that change I'll take another look. And thanks for submitting this PR in the first place by the way 👍 .

@Stafox
Copy link
Contributor Author

Stafox commented Jan 31, 2017

@montymxb Wow, you're right. I just missed it:( Fixed.

X-Parse-Push-Status-Id is present and accounted for in the return value

Yes, returned array will contain _headers key with headers, so you will able to get push status id by ```

$response = ParsePush::send( [
      'channels' => [''],
      'data'     => ['alert' => 'sample message'],
 ]);

$pushStatusId = $response['_headers']['X-Push-Status-Id'];

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@montymxb montymxb merged commit 1150217 into parse-community:master Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants