I am using PushNotification (by Edujogon) for push notification services.
So, for that I created a file in config/pushnotification
and set my key and all for fcm and apn
.
On this file I set
'fcm' => [
'priority' => 'normal',
'dry_run' => false,
'apiKey' => 'My-Api-key',
],
And sending on fcm
key to sendFCM
function
if(count($fcmDeviceIds) > 0) {
$this->sendFCM($fcmDeviceIds, $payload, $addedPost);
}
And my sendFCM
function :
private function sendFCM($tokens, $payload, $addedPost) {
$poroductDetail = Product::find($addedPost->product_id)->first();
$productTitle = $poroductDetail->title;
$payloadData = ([$addedPost, 'notificationType' => 'postNotification']);
try {
$push = new PushNotification('fcm');
$feedback = $push->setMessage([
'fcm' => [
'alert' => [
'title' => isset($payload['title']) ? $payload['title'] : 'myTitle',
'body' => $payload['body']." for ".$productTitle
],
'sound' => isset($payload['sound']) ? $payload['sound'] : 'default'
],
'extraPayLoad' => $payloadData
])->setDevicesToken($tokens)->send()->getFeedback();
} catch (\Exception $ex) {
Log::error($ex->getTraceAsString());
}
}
So when I check in local I got all notifications but on live i did'nt gt any notification.What's the problem in my code ?