PushNotification icon indicating copy to clipboard operation
PushNotification copied to clipboard

Undefined index: headers

Open ankitindianic opened this issue 3 years ago • 7 comments

I have using this package and pass all parameter but this error is found **Undefined index: headers File: /var/www/html/indiaNic-work/echo-loud/laravel/vendor/edujugon/push-notification/src/Apn.phpLine: 255 **

ankitindianic avatar Oct 13 '21 05:10 ankitindianic

Same issue, if some one has fixed it plz lemme know.Thanks

hammad-pitafi avatar Oct 14 '21 07:10 hammad-pitafi

Same issue, if some one has fixed it plz lemme know.Thanks

darshantank1995 avatar Oct 23 '21 13:10 darshantank1995

any update on this issue...

usmanjdn93 avatar Oct 25 '21 11:10 usmanjdn93

vendor\edujugon\push-notification\src download Apn.php in bellow url. replace given in file. it will work find.

https://github.com/darshantank1995/apnforpushnotification/blob/master/Apn.php

darshantank1995 avatar Oct 26 '21 04:10 darshantank1995

thanks @darshantank1995 ... but the problem is, this is issue happened in current release v5.0.0, your file works fine but it's the old code with APN sandbox URL. @Edujugon have any time to look into it

usmanjdn93 avatar Oct 26 '21 05:10 usmanjdn93

I just ran into this the past few days. If you update your payload to contain a headers key it will get around that error. Just testing this in production, you now need to specify an apns-topic which is the bundle ID when using a production certificate.

$push->setMessage([
            'aps' => [
                'alert' => [
                    'title' => 'This is the title',
                    'body' => 'This is the body'
                ],
                'sound' => 'default',
                'badge' => 1

            ],
            'headers' => [
                'apns-topic' => 'com.mycompany.myapp'
            ]
        ])
    ->setDevicesToken(['deviceToken1','deviceToken2','deviceToken3'...]);

kreitje avatar Jan 04 '22 21:01 kreitje

Maybe for iOS 13+ this is better (not tested):

'headers' => [
    'apns-push-type' => 'alert'
]

tumispro avatar Jul 26 '22 13:07 tumispro