paulb
May 16, 2016, 11:39pm
1
Hi all,
I have a problem, everytime I send a Invoice by email I get this nice ;( errror
Whoops, looks like something went wrong
I get e notification that the invoce is send but i’m not sure if this is correct.
I try to use smtp, send mail but both give me the same error. Can anybode help me ?
hillel
May 16, 2016, 11:42pm
2
There should be more details about the error in the logs in storage/logs/
paulb
May 16, 2016, 11:59pm
3
Hi Hillen,
There is a lot of info in the logfiles.
There are three files error, info and warnings. Can i clear the files and run a test, see if there is a error that i can understand.
hillel
May 17, 2016, 12:02am
4
That’s a good plan, the relevant info should be in the error file.
paulb
May 17, 2016, 12:35am
5
BTW, the email is send and attachment is oke but the link is not working.
From the error it looks like it’s related to the iOS notifications.
I’ve reached out to our iOS developer for more info.
Can you try adding return false; at the top of the sendNotification function in app/Services/PushService.php
paulb
May 17, 2016, 3:28am
8
Don’t Know where you meen,
// start paul
<?php
namespace App\Services;
use Illuminate\Http\Request;
use App\Ninja\Notifications\PushFactory;
/**
Class PushService
@package App\Ninja\Notifications
*/
/**
$account->devices Definition
@param string token (push notification device token)
@param string email (user email address - required for use as key)
@param string device (ios, gcm etc etc)
@param bool notify_sent
@param bool notify_paid
@param bool notify_approved
@param bool notify_viewed
*/
class PushService
{
protected $pushFactory;
/**
* @param PushFactory $pushFactory
*/
public function __construct(PushFactory $pushFactory)
{
$this->pushFactory = $pushFactory;
}
/**
* @param $invoice - Invoice object
* @param $type - Type of notification, ie. Quote APPROVED, Invoice PAID, Invoice/Quote SENT, Invoice/Quote VIEWED
*/
public function sendNotification($invoice, $type)
{
//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);
}
}
/**
* pushMessage function
*
* method to dispatch iOS notifications
*
* @param $invoice
* @param $token
* @param $type
*/
private function pushMessage($invoice, $token, $type)
{
$this->pushFactory->message($token, $this->messageType($invoice, $type));
}
/**
* checkDeviceExists function
*
* Returns a boolean if this account has devices registered for PUSH notifications
*
* @param $account
* @return bool
*/
private function checkDeviceExists($account)
{
$devices = json_decode($account->devices, TRUE);
if(count($devices) >= 1)
return TRUE;
else
return FALSE;
}
/**
* messageType function
*
* method which formats an appropriate message depending on message type
*
* @param $invoice
* @param $type
* @return string
*/
private function messageType($invoice, $type)
{
switch($type)
{
case 'sent':
return $this->entitySentMessage($invoice);
break;
case 'paid':
return $this->invoicePaidMessage($invoice);
break;
case 'approved':
return $this->quoteApprovedMessage($invoice);
break;
case 'viewed':
return $this->entityViewedMessage($invoice);
break;
}
}
/**
* @param $invoice
* @return string
*/
private function entitySentMessage($invoice)
{
if($invoice->is_quote)
return trans("texts.notification_quote_sent_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
else
return trans("texts.notification_invoice_sent_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
}
/**
* @param $invoice
* @return string
*/
private function invoicePaidMessage($invoice)
{
return trans("texts.notification_invoice_paid_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
}
/**
* @param $invoice
* @return string
*/
private function quoteApprovedMessage($invoice)
{
return trans("texts.notification_quote_approved_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
}
/**
* @param $invoice
* @return string
*/
private function entityViewedMessage($invoice)
{
if($invoice->is_quote)
return trans("texts.notification_quote_viewed_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
else
return trans("texts.notification_invoice_viewed_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
}
}
//end paul
paulb
May 17, 2016, 3:30am
9
BTW can you delete reply #2916 this post is become monster long :))
hillel
May 17, 2016, 3:51am
10
Try changing
public function sendNotification($invoice, $type)
{
//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);
}
}
To
public function sendNotification($invoice, $type)
{
return false;
//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);
}
}
paulb
May 17, 2016, 4:07am
11
yeyeeeeeaaahee, that did the trick, Your great Hillel thx
hillel
May 17, 2016, 4:08am
12
Thanks for letting us know, we’ll include this fix with our next release.
paulb
May 17, 2016, 4:09am
13
I have one last quetion,
[2016-05-17 10:24:29] production.WARNING: Entity not set in client repo save [] []
What is this?
hillel
May 17, 2016, 4:11am
14
It can be ignored. We’re working to refactor some code and are using these warnings to help ensure we don’t miss any code paths.