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

No response #95

Closed FelixTraxler closed 4 years ago

FelixTraxler commented 4 years ago

Trying to get the example script to work. I have changed the key_id, team_id, app_bundle_id, private_key_path (to a .p8 file) and the deviceTokens. If I run it, I do not get any error messages and the response array is empty.

Using the exact same credentials, I can however send push notifications via the PushNotifications App by onmyway133.

Any ideas what I am doing wrong?

var_dump for Notifications array (for a single device id):

array(1) {
  [0]=>
  object(Pushok\Notification)#14 (6) {
    ["payload":"Pushok\Notification":private]=>
    object(Pushok\Payload)#17 (9) {
      ["alert":"Pushok\Payload":private]=>
      object(Pushok\Payload\Alert)#18 (9) {
        ["title":"Pushok\Payload\Alert":private]=>
        string(6) "Hello!"
        ["subtitle":"Pushok\Payload\Alert":private]=>
        NULL
        ["body":"Pushok\Payload\Alert":private]=>
        string(23) "First push notification"
        ["titleLocKey":"Pushok\Payload\Alert":private]=>
        NULL
        ["titleLocArgs":"Pushok\Payload\Alert":private]=>
        NULL
        ["actionLocKey":"Pushok\Payload\Alert":private]=>
        NULL
        ["locKey":"Pushok\Payload\Alert":private]=>
        NULL
        ["locArgs":"Pushok\Payload\Alert":private]=>
        NULL
        ["launchImage":"Pushok\Payload\Alert":private]=>
        NULL
      }
      ["badge":"Pushok\Payload":private]=>
      NULL
      ["sound":"Pushok\Payload":private]=>
      string(7) "default"
      ["contentAvailable":"Pushok\Payload":private]=>
      NULL
      ["mutableContent":"Pushok\Payload":private]=>
      NULL
      ["category":"Pushok\Payload":private]=>
      NULL
      ["threadId":"Pushok\Payload":private]=>
      NULL
      ["customValues":"Pushok\Payload":private]=>
      array(1) {
        ["acme2"]=>
        string(4) "test"
      }
      ["pushType":"Pushok\Payload":private]=>
      NULL
    }
    ["deviceToken":"Pushok\Notification":private]=>
    string(64) "-------DEVICE-TOKEN-REMOVED---------"
    ["id":"Pushok\Notification":private]=>
    NULL
    ["expirationAt":"Pushok\Notification":private]=>
    NULL
    ["priority":"Pushok\Notification":private]=>
    NULL
    ["collapseId":"Pushok\Notification":private]=>
    NULL
  }
}
edamov commented 4 years ago

Does your environment meet all requirements (like php, lib-curl, lib-openssl)?

FelixTraxler commented 4 years ago

Thanks for the fast response!

Just checked and indeed one requirement (HTTP/2) was not met. My bad. My machine does support HTTP/2, but it seems as the Xampp server does not.

I installed the newest version of xampp (7.4.1) on my machine, but HTTP/2 is still disabled. If I use the curl command in the terminal, HTTP/2 works, but phpinfo() still shows it as disabled.

FelixTraxler commented 4 years ago

I have uploaded my script to another server with HTTP/2 enabled and it worked. I don't know why HTTP/2 is disabled in xampp, but it seems like that was the issue. Thanks for your help!

ZUCheema commented 4 years ago

I faced the same issue with xampp running on my Mac. I uploaded the same code on cPanel hosting it working right away.