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

Zend dependencies are abandoned #197

Open
risototh opened this issue Aug 27, 2020 · 5 comments
Open

Zend dependencies are abandoned #197

risototh opened this issue Aug 27, 2020 · 5 comments

Comments

@risototh
Copy link

Composer outputs:

Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead.
Package zendframework/zend-json is abandoned, you should avoid using it. Use laminas/laminas-json instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead.
Package zendframework/zend-loader is abandoned, you should avoid using it. Use laminas/laminas-loader instead.
Package zendframework/zend-http is abandoned, you should avoid using it. Use laminas/laminas-http instead.
Package zendframework/zendservice-google-gcm is abandoned, you should avoid using it. No replacement was suggested.
Package zendframework/zendservice-apple-apns is abandoned, you should avoid using it. No replacement was suggested.

@seyfer
Copy link
Collaborator

seyfer commented Aug 27, 2020

@risototh yes this is known. Do you have time to contribute?

@risototh
Copy link
Author

@seyfer not sure, if I have the time. Depends, on how much it will require. I only went around, when updating this library from the 2.0.0 version in our code ;D Maybe I can spent some hours on that, but I don't even know, what this library is for and how to test it...

@kw-pr
Copy link

kw-pr commented Mar 5, 2021

We are running out of time here. Apple just wrote:

If you still send push notifications with the legacy binary protocol, make sure to upgrade to the APNs provider API as soon as possible. APNs will no longer support the legacy binary protocol after March 31, 2021.

@seyfer seyfer added asap and removed bug labels Mar 9, 2021
@sarveshamrit
Copy link

@risototh Sir any update , i am not able to send push to apple anymore, it goes to android but not to ios , on same side it goes when i try from pushtry.com? @seyfer @kw-pr

@lstrojny
Copy link

To get the ball rolling, here is a quick implementation of an HTTP based adapter. It uses apple/apn-push. It’s probably not complete, probably has bugs and so on but it works for simple cases in my testing.

class ApnsHttp extends BaseAdapter
{
    public function push(PushInterface $push): DeviceCollection
    {
        $certificate = new Certificate($this->getParameter('certificate'), $this->getParameter('passPhrase'));
        $authenticator = new CertificateAuthenticator($certificate);

        $builder = new Http20Builder($authenticator);
        $sender = $builder->build();
        $pushedDevices = new DeviceCollection();

        /** @var DeviceInterface $device */
        foreach ($push->getDevices() as $device) {
            $receiver = new Receiver(new DeviceToken($device->getToken()), $this->getParameter('bundleId'));
            try {
                $sender->send($receiver, $this->toNotification($device, $push->getMessage()), $this->isDevelopmentEnvironment());
                $push->addResponse($device, ['success' => true]);
                $push->pushed();

                $pushedDevices->add($device);
            } catch (SendNotificationException $e) {
                throw new PushException($e->getMessage(), null, $e);
            }
        }

        return $pushedDevices;
    }

    private function toNotification(DeviceInterface $device, Message $message): Notification
    {
        $alert = (new Alert())
            ->withBody($message->getText())
            ->withTitle($message->getOption('title') ?? '')
            ->withLaunchImage($message->getOption('launchImage') ?? '');

        if ($message->getOption('locKey')) {
            $alert = $alert->withBodyLocalized(
                new Localized($message->getOption('locKey'), $message->getOption('locArgs', []))
            );
        }

        if ($message->getOption('actionLocKey')) {
            $alert = $alert->withActionLocalized(
                new Localized($message->getOption('actionLocKey'), $message->getOption('actionLocKeyArgs', []))
            );
        }

        if ($message->getOption('titleLocKey')) {
            $alert = $alert->withLocalizedTitle(
                new Localized($message->getOption('titleLocKey'), $message->getOption('titleLocArgs', []))
            );
        }

        $aps = (new Aps($alert))
            ->withSound($message->getOption('sound') ?? '')
            ->withContentAvailable($message->getOption('content-available', false))
            ->withMutableContent($message->getOption('mutable-content', false))
            ->withCategory($message->getOption('category') ?? '');

        if ($message->hasOption('badge')) {
            $aps = $aps->withBadge($message->getOption('badge') + $device->getParameter('badge', 0));
        }

        $payload = (new Payload($aps));

        foreach ($message->getOption('custom', []) as $key => $value) {
            $payload = $payload->withCustomData($key, $value);
        }

        return (new Notification($payload))
            ->withExpiration(
                $message->getOption('expire') ? new Expiration(new DateTime($message->getOption('expire'))) : null
            );
    }

    public function supports($token): bool
    {
        return ctype_xdigit($token);
    }

    public function getDefinedParameters(): array
    {
        return [];
    }

    public function getDefaultParameters(): array
    {
        return ['passPhrase' => ''];
    }

    public function getRequiredParameters(): array
    {
        return ['certificate', 'bundleId'];
    }
}

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

5 participants