flush() public method

Flush notifications. Triggers the requests.
public flush ( ) : array | boolean
return array | boolean If there are no errors, return true. If there were no notifications in the queue, return false. Else return an array of information for each notification sent (success, statusCode, headers, content)
Exemplo n.º 1
0
        $webPush = new WebPush(array('GCM' => $push_api));
        $endpoints = get_endpoints("Voting_End30");
        // send multiple notifications
        foreach ($endpoints as $endpoint) {
            $webPush->sendNotification($endpoint['Endpoint']);
        }
        $webPush->flush();
    }
    if (in_array("Voting_End", get_event(3600))) {
        $to = get_emails("Voting_End60");
        $message = '
    <html>
    <body>
    <p>Dear HiveMember,</p>
    <p>You are yet to vote for this weeks film night. Voting closes in an hour.
    <p>Please <a href="https://films.jakestockwin.co.uk/voting.php">click here</a> to vote</p>
    <br>
    <p>Best wishes,<br>The HiveBot&trade;</p>
    </body>
    </html>
    ';
        mail($to, "Film Night Voting", $message, "Content-type:text/html");
        $webPush = new WebPush(array('GCM' => $push_api));
        $endpoints = get_endpoints("Voting_End60");
        // send multiple notifications
        foreach ($endpoints as $endpoint) {
            $webPush->sendNotification($endpoint['Endpoint']);
        }
        $webPush->flush();
    }
}