Edujugon / PushNotification

PHP and Laravel Package to send push notifications to Android and IOS devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"success":0,"failure":1,"tokenFailList"

luccasefr opened this issue · comments

I'm trying to send ios push notification and the response is that error "success":0,"failure":1,"tokenFailList"

This is my code to send the push

`function send_ios_push($user_id, $title, $message, $type) {

$iosPush = new PushNotification('apn');
\Log::debug(print_r($iosPush,true));

$iosPush->setMessage([
	'aps' => [
		'alert' => [
			'title' => $title,
			'body' => $message
		],
		'sound' => 'default',
		'badge' => 1

	],
	'extraPayLoad' => [
		'custom' => $type,
	]
])
->setDevicesToken([$user_id])
->send();

}
`

And this is my pushnotification config

return [
'gcm' => [
'priority' => 'normal',
// 'dry_run' => false,
'apiKey' => 'AAAAFYzAkdg:A...',
],
'fcm' => [
'priority' => 'normal',
// 'dry_run' => false,
'apiKey' => 'AAAAFYzAkdg:A...',
],
'apn' => [

  'certificate' => __DIR__ . '/iosCertificates/pushcert.pem',
  // 'passPhrase' => '1234', //Optional
  'passFile' => __DIR__ . '/iosCertificates/pushcert.pem', //Optional
  'dry_run' => 'false',

]
];

And this is my response of getFeedback()

(
[service:protected] => Edujugon\PushNotification\Apn Object
(
[sandboxUrl:Edujugon\PushNotification\Apn:private] => ssl://gateway.sandbox.push.apple.com:2195
[productionUrl:Edujugon\PushNotification\Apn:private] => ssl://gateway.push.apple.com:2195
[feedbackSandboxUrl:Edujugon\PushNotification\Apn:private] => ssl://feedback.sandbox.push.apple.com:2196
[feedbackProductionUrl:Edujugon\PushNotification\Apn:private] => ssl://feedback.push.apple.com:2196
[feedbackUrl:Edujugon\PushNotification\Apn:private] => ssl://feedback.sandbox.push.apple.com:2196
[maxAttempts:Edujugon\PushNotification\Apn:private] => 3
[attempts:Edujugon\PushNotification\Apn:private] => 0
[url:protected] => ssl://gateway.sandbox.push.apple.com:2195
[config:protected] => Array
(
[certificate] => /var/www/dev3.motoristaprivado.com.br/config/iosCertificates/pushcert.pem
[passFile] => /var/www/dev3.motoristaprivado.com.br/config/iosCertificates/pushcert.pem
[dry_run] => false
)

[feedback:protected] => stdClass Object
(
[success] => 0
[failure] => 1
[tokenFailList] => Array
(
[0] => Array
(
[0] => 843B9461E3824##############################
)

)

)

)

[servicesList:protected] => Array
(
[gcm] => Edujugon\PushNotification\Gcm
[apn] => Edujugon\PushNotification\Apn
[fcm] => Edujugon\PushNotification\Fcm
)

[defaultServiceName:Edujugon\PushNotification\PushNotification:private] => gcm
[deviceTokens:protected] => Array
(
[0] => Array
(
[0] => 843B9461E3824343A89D575803554A9BDEFC539B0F6FD5C67481D8485CFA93A6
)

)

[message:protected] => Array
(
[aps] => Array
(
[alert] => Array
(
[title] => teste
[body] => teste
)

[sound] => default
[badge] => 1
)

[extraPayLoad] => Array
(
[custom] =>
)

)

)

My android push is working fine.

What could be happening?

Hi @luccasefr ,

Make sure you're using the correct certificate based on the environment you are sending the notification through.

You can switch between either test and production environment with the dry_run config variable.