Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement iOS 13 updates #78

Open
edamov opened this issue Oct 13, 2019 · 11 comments
Open

Implement iOS 13 updates #78

edamov opened this issue Oct 13, 2019 · 11 comments

Comments

@zek
Copy link

zek commented Oct 24, 2019

In order to send VOIP push notifications we need to set
$this->headers[self::HEADER_APNS_PUSH_TYPE] = 'voip';

@angvp
Copy link
Contributor

angvp commented Nov 13, 2019

I've tried adding that on Request.php but it also needs to be set

$this->headers[self::HEADERS_APNS_TOPIC] == bundleId."voip"

When I'm doing the auth I know I'm sending that header but I can't retrieve it from Request.php (I don't know how, I've tried multiple stuff).. so what I did waws, a sort of a hack, sending a customValue (from my app) on the payload, and updating Request.php with the following code

// new header required to support iOS 13
        $this->headers[self::HEADER_APNS_PUSH_TYPE] = 'alert';
        $payload = $notification->getPayload();
        try {
            $apnsTopic = $payload->getCustomValue(self::HEADER_APNS_TOPIC);
        } catch (InvalidPayloadException $e) {
        }
        if ($notification->getPayload()->isContentAvailable()) {
            $this->headers[self::HEADER_APNS_PUSH_TYPE] = 'background';
        }
        if (isset($apnsTopic) && !empty($apnsTopic)) {
            $this->headers[self::HEADER_APNS_TOPIC] = $apnsTopic;
            $this->headers[self::HEADER_APNS_PUSH_TYPE] = 'voip';
        }

But I know this is not ideal, and we might just recover that value (appBundleId) from the headers and then we might add a validation if strpos($appBundleId, 'voip') then we can set $this->headers[self::HEADER_APNS_PUSH_TYPE] = 'voip'

I would like to work in a patch, but I'm trying to understand the codebase and why that header is "lost" after the authentication :/

@edamov
Copy link
Owner Author

edamov commented Nov 16, 2019

But can we check if HEADER_APNS_TOPIC exists, then add HEADER_APNS_PUSH_TYPE=void?

if ($notification->getPayload()->isContentAvailable()) {
    $this->headers[self::HEADER_APNS_PUSH_TYPE] = 'background';
} elseif (isset($this->headers[self::HEADER_APNS_TOPIC]))
    $this->headers[self::HEADER_APNS_PUSH_TYPE] = 'voip';
}

@angvp
Copy link
Contributor

angvp commented Nov 17, 2019

@edamov I'll try this today and I'll let you know if it works. Thanks!

angvp pushed a commit to angvp/pushok that referenced this issue Nov 17, 2019
@angvp
Copy link
Contributor

angvp commented Nov 19, 2019

Hmm I think I misunderstood you, how come I can have $this->headers[self::HEADER_APNS_TOPIC] with the value of the bundleId."voip" ? automatically, as this is being sent when we authenticate against apple api?

@edamov
Copy link
Owner Author

edamov commented Nov 19, 2019

Seems now I understand what do you mean 😃
Request class is not accessible. We need to improve Request class with the code I wrote above.
Will it make sense? Can you create PR?

@angvp
Copy link
Contributor

angvp commented Nov 19, 2019

Ok I will create the PR with this code, although I will create a branch with the modifications I need to make it work on my project, then after when everything is upstream I'll point to that branch.

Thanks!

@angvp
Copy link
Contributor

angvp commented Nov 20, 2019

I made a PR: #91 that will solve the voip part.

@edamov
Copy link
Owner Author

edamov commented Nov 20, 2019

Thanks!
I just found there are much more push types like mdm, fileprovider, complication.
It is very good that it is possible now to set them

@chimit
Copy link
Contributor

chimit commented Mar 9, 2020

I tried to send voip push notifications, but apparently this package doesn't automatically add a .voip suffix to the bundle id.

voip
...
If you set this push type, the apns-topic header field must use your app’s bundle ID with .voip appended to the end.

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns/

@chimit
Copy link
Contributor

chimit commented May 5, 2020

Apparently, we can close this issue along with this one #97

@edamov edamov added this to the 1.0 milestone Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants