laravel-notification-channels / onesignal

OneSignal notifications channel for Laravel
MIT License
283 stars 119 forks source link

action button is not working #20

Closed cquezpro closed 6 years ago

cquezpro commented 7 years ago

Hello, I tried to add action button, but that is not working. Thanks OneSignalMessage::create() ->button( OneSignalButton::create('id') ->text('button text') ->icon('button icon') );

emilas44 commented 7 years ago

Did you import the class at the top. Can you check the /storage/logs/laravel.log file

as a matter a fact I also have problem with this. In laravel.log i get this error

[2017-05-17 11:04:27] local.ERROR: GuzzleHttp\Exception\ClientException: Client error: `POST https://onesignal.com/api/v1/notifications` resulted in a `400 Bad Request` response: {"errors":["Notification headings must not be null for any languages."]} in /var/www/html/laravel-projects/4youplatform/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111

cquezpro commented 7 years ago

actually I try below code. This will not fire error. but action button is not appearing, OneSignalMessage::create() ->subject($this->titleMessage) ->body(str_replace('{ID}', $this->carriageRequest->id, $this->bodyMessage)) ->button( OneSignalButton::create('id') ->text('Accept') );

emilas44 commented 7 years ago

Same by me. It also doesn't fire any errors and i am using this code...I want to get an icon and it doesn't work

      return OneSignalMessage::create()
            ->subject('Event "' . $this->event->title . '"')
            ->button(
                OneSignalButton::create('id')
                    ->text('button text')
                    ->icon('http://www.hultcenter.org/sitecm/i/facebook-icon.png')
         );
emilas44 commented 7 years ago

even when i use the default code from the package:

return OneSignalMessage::create()
    ->subject("Your {$notifiable->service} account was approved!")
    ->body("Click here to see details.")
    ->url('http://onesignal.com')
    ->webButton(
        OneSignalWebButton::create('link-1')
            ->text('Click here')
            ->icon('https://upload.wikimedia.org/wikipedia/commons/4/4f/Laravel_logo.png')
            ->url('http://laravel.com')
 );

It doesn't work. I get this error:

[2017-05-17 12:46:18] local.ERROR: GuzzleHttp\Exception\ClientException: Client error: `POST https://onesignal.com/api/v1/notifications` resulted in a `400 Bad Request` response: {"errors":["Message Notifications must have English language content"]} in /var/www/html/laravel-projects/4youplatform/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111

LKaemmerling commented 6 years ago

@emilas44 @sirius2013 You need to specifiy a messsage. That is a requirment from the one signal API, sorry.