其实我已经添加了数据功能,这个简单的添加事件。我想向超过3000个用户发送推送通知,这些用户数据也在数据库中。因此,为了向他们发送通知,我将必须检索所有活动用户数据,这就是我所做的。问题是在添加事件脚本之后检索用户并在while循环中逐个发送推送通知并且花费了这么多时间,并且由于此功能不会发送成功响应Event has been sent successfully
。
Function AddEvent(){
//Other Code.....
// For sending notification to more than 3000 users
$user = "SELECT ud.`ud_device_type`,ud.`ud_token` FROM `user` AS us LEFT JOIN `user_detail` AS ud ON us.`us_id`=ud.`us_id` WHERE ud.`ud_notification` =1 and us.`us_status`= 1 AND us.`is_enable`= 1 AND ud.`ud_device_type` = 'ios' OR ud.`ud_device_type` = 'android' ";
$selectSalt = mysqli_query($this->connection,$user);
if(mysqli_num_rows($selectSalt) > 0){
while($UserRow = mysqli_fetch_assoc($selectSalt)){
$msg = 'There is New Event, tap to view.';
if($UserRow['ud_device_type']=='ios'){
$this->notify_ios($UserRow['ud_token'],$msg);
}
if($UserRow['ud_device_type']=='android'){
$this->notifyAndroid($UserRow['ud_token'],$msg);
}
}
}
// Event add response for CMS
$response['success'] = 'EvenRecord added successfully.';
$output = array(
'response' => $response,
);
echo json_encode($response, JSON_PRETTY_PRINT);
}
所以任何人都可以指导我如何调整这种功能,一切都会顺利进行。如果有人指导我,我很感激。谢谢