FCM - Android and IOS sample push data


#1

1. Android

if(count($device_android)>0){
				$body['data']['title'] = $row['title'];
				$body['data']['message'] = $row['msg'];
				$body['data']['link_type'] = $row['link_type'];
				$body['data']['link_url'] = $row['link_url'];
				$body['data']['push_idx'] = $row['push_idx'];
				if(!empty($row['img_path']) && !empty($row['img_name'])) {
					$body['data']['img'] = 'http://dev-api.martjangbogo.com/common/img_download?img_path=' . $row['img_path'] . '&img_file=' . $row['img_name'];
				}
				else {
					$body['data']['img'] = '';
				}
				$body['data']['alarm_sound'] = '1';
				$return = $this->common->send_fcm($device_android, $body);
			}
			

2. IOS

			if(count($device_ios) > 0){
				$body['priority'] = 'high';
				$body['content_available'] = true;
				$body['notification']['sound'] = true;
				$body['notification']['vibrate'] = true;
				$body['notification']['title'] = $row['title'];
				$body['notification']['body'] = $row['msg'];
				$body['notification']['link_type'] = $row['link_type'];
				$body['notification']['link_url'] = $row['link_url'];
				$body['notification']['push_idx'] = $row['push_idx'];
				if(!empty($row['img_path']) && !empty($row['img_name'])) {
						$body['notification']['image'] = 'http://dev-api.martjangbogo.com/common/img_download?img_path=' . $row['img_path'] . '&img_file=' . $row['img_name'];
				}
				else {
					$body['notification']['image'] = '';
				}
				$body['notification']['sound'] = '1';
				$return = $this->common->send_fcm($device_ios, $body);
			}

reference link

https://levelup.gitconnected.com/custom-push-notification-in-ios-swift-5-210552643e86