edamov / pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key)
MIT License
378 stars 121 forks source link

ErrorException in Client.php 99: Undefined offset: 1 #19

Closed mlusas closed 7 years ago

mlusas commented 7 years ago

Hello, I've followed the Readme, and when triggering $client->push() via Laravel, I receive the follow error. We've tried triggering a notification via Node.js using this tutorial and we were able to successfully trigger a notification.

Any thoughts on how we may be able to fix or troubleshoot this? Thank you,

ErrorException in Client.php line 99:
Undefined offset: 1
in Client.php line 99
at HandleExceptions->handleError(8, 'Undefined offset: 1', '/var/www/domain.com/qa/releases/20170424153008/vendor/edamov/pushok/src/Client.php', 99, array('mh' => resource, 'handles' => array(resource, resource), 'notification' => object(Notification), 'k' => 1, 'request' => object(Request), 'ch' => resource, 'active' => 0, 'mrc' => 0, 'responseCollection' => array(), 'handle' => resource, 'result' => null, 'headers' => '')) in Client.php line 99
at Client->push() in CharacterLikedJob.php line 75
at CharacterLikedJob->handle()
isaiasmac commented 7 years ago

Same problem here:

PHP Notice: Undefined offset: 1 in /vendor/edamov/pushok/src/Client.php on line 99

lucadegasperi commented 7 years ago

Same problem here at the same line.

edamov commented 7 years ago

I think it is the same issue as here #7. Please read my answer(comment)

lucadegasperi commented 7 years ago

In my case this was indeed caused by curl not having http2 support on the Mac.

To solve I did the following things (assuming you are using homebrew):

First check if you actually have http2 support by trying to curl to an http2 url:

curl -I --http2 https://www.cloudflare.com/

this should result in an unsupported protocol error

Next install curl

brew install curl --with-nghttp2
brew link curl --force

Finally recompile php and tell it to use the curl library provided by homebrew

brew reinstall php71 --with-homebrew-curl
antonioreyna commented 5 years ago

Hello, I am getting the same error in:

vendor/edamov/pushok/src/Client.php:122

edamov commented 5 years ago

@antonioreyna Do you have lib-curl compiled with http/2 support on the server? What version of pushok library do you use?

antonioreyna commented 5 years ago

It was the http2 issue i just installed and now it works great. thank you!

@antonioreyna Do you have lib-curl compiled with http/2 support on the server? What version of pushok library do you use?