+1, 'alert' => array( 'title'=>$message['title'], 'body' =>$message['message'], ), 'sound' => 'default' ); $payload = json_encode($body); // Build the binary notification foreach ($devices as $device) { // Build the binary notification $msg = chr(0) . pack('n', 32) . pack('H*', $device) . pack('n', strlen($payload)) . $payload; //Send it to the server $results[] = fwrite($fp, $msg, strlen($msg)); //Insert msgs into pushnotification log table global $wpdb; $blogtime = current_time( 'mysql' ); $all_pushnotification_logs = $wpdb->prefix . 'all_pushnotification_logs'; $wpdb->insert($all_pushnotification_logs,array('push_title' => $message['title'],'push_message' => $message['message'],'push_sent' => 1,'push_send_date' => $blogtime,'devicetoken_id' =>$device),array('%s','%s','%d','%s','%s')); } if (empty($results)){ //return ; } else { return $results; } // Close the connection to the server fclose($fp); return $error; } } ?>