public function sendNotification(Invoice $invoice, $type)
{
if (!IOS_PUSH_CERTIFICATE) {
return;
}
//check user has registered for push notifications
if (!$this->checkDeviceExists($invoice->account)) {
return;
}
//Harvest an array of devices that are registered for this notification type
$devices = json_decode($invoice->account->devices, TRUE);
foreach ($devices as $device) {
if ($device["notify_{$type}"] == TRUE && $device['device'] == 'ios') {
$this->pushMessage($invoice, $device['token'], $type);
}
}
}