العودة لقائمة المشاريع
مستقل محترف PHP larval بإشعارات الفايربيز
الميزانية
$25.00 - $50.00
التصنيف
برمجة، تطوير المواقع والتطبيقات
المهارات المطلوبة
لارافيل
PHP
فايربيس
تطوير البرمجيات
برمجة
لارافيل
PHP
فايربيس
تطوير البرمجيات
برمجة
الوصف
كنت استخدم فانكشن الفايربيز للاشعارات ولكن تم وقفها بشكل نهائي من الفايربيز ودا الكود وكنت احتاج مبرمج محترف لتغيير الفانكشن بالفانكشن الجديدة وتشغيل الأشعارات
public static function send_push_notif_to_topic($data, $topic, $type,$web_push_link = null)
{
$key = BusinessSetting::where(['key' => 'push_notification_key'])->first()->value;
$url = "https://fcm.googleapis.co...;;
$header = array(
"authorization: key=" . $key . "",
"content-type: application/json"
);
if(isset($data['module_id'])){
$module_id = $data['module_id'];
}else{
$module_id = '';
}
if(isset($data['order_type'])){
$order_type = $data['order_type'];
}else{
$order_type = '';
}
if(isset($data['zone_id'])){
$zone_id = $data['zone_id'];
}else{
$zone_id = '';
}
$click_action = "";
if($web_push_link){
$click_action = ',
"click_action": "'.$web_push_link.'"';
}
if (isset($data['order_id'])) {
$postdata = '{
"to" : "/topics/' . $topic . '",
"mutable_content": true,
"data" : {
"title":"' . $data['title'] . '",
"body" : "' . $data['description'] . '",
"image" : "' . $data['image'] . '",
"order_id":"' . $data['order_id'] . '",
"module_id":"' . $module_id . '",
"order_type":"' . $order_type . '",
"zone_id":"' . $zone_id . '",
"is_read": 0,
"type":"' . $type . '"
},
"notification" : {
"title":"' . $data['title'] . '",
"body" : "' . $data['description'] . '",
"image" : "' . $data['image'] . '",
"order_id":"' . $data['order_id'] . '",
"title_loc_key":"' . $data['order_id'] . '",
"body_loc_key":"' . $type . '",
"type":"' . $type . '",
"is_read": 0,
"icon" : "new",
"sound": "notification.wav",
"android_channel_id": "6ammart"
'.$click_action.'
}
}';
} else {
$postdata = '{
"to" : "/topics/' . $topic . '",
"mutable_content": true,
"data" : {
"title":"' . $data['title'] . '",
"body" : "' . $data['description'] . '",
"image" : "' . $data['image'] . '",
"is_read": 0,
"type":"' . $type . '"
},
"notification" : {
"title":"' . $data['title'] . '",
"body" : "' . $data['description'] . '",
"image" : "' . $data['image'] . '",
"body_loc_key":"' . $type . '",
"type":"' . $type . '",
"is_read": 0,
"icon" : "new",
"sound": "notification.wav",
"android_channel_id": "6ammart"
'.$click_action.'
}
}';
}
$ch = curl_init();
$timeout = 120;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
// Get URL content
$result = curl_exec($ch);
// close handle to release resources
curl_close($ch);
info('result of notification '.$result);
return $result;
}