Giter Site home page Giter Site logo

onesignal's Introduction

OneSignal notifications channel for Laravel 5.3+

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send OneSignal notifications with Laravel 5.3+.

Contents

Installation

You can install the package via composer:

$ composer require laravel-notification-channels/onesignal

If you're installing the package in Laravel 5.4 or lower, you must import the service provider:

// config/app.php
'providers' => [
    ...
    NotificationChannels\OneSignal\OneSignalServiceProvider::class,
],

Setting up your OneSignal account

Add your OneSignal App ID and REST API Key to your config/services.php:

// config/services.php
...
'onesignal' => [
    'app_id' => env('ONESIGNAL_APP_ID'),
    'rest_api_key' => env('ONESIGNAL_REST_API_KEY'),
    'guzzle_client_timeout' => env('ONESIGNAL_GUZZLE_CLIENT_TIMEOUT', 0),
],
...

Usage

Now you can use the channel in your via() method inside the notification:

use NotificationChannels\OneSignal\OneSignalChannel;
use NotificationChannels\OneSignal\OneSignalMessage;
use NotificationChannels\OneSignal\OneSignalWebButton;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [OneSignalChannel::class];
    }

    public function toOneSignal($notifiable)
    {
        return OneSignalMessage::create()
            ->setSubject("Your {$notifiable->service} account was approved!")
            ->setBody("Click here to see details.")
            ->setUrl('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')
            );
    }
}

In order to let your Notification know which OneSignal user(s) you are targeting, add the routeNotificationForOneSignal method to your Notifiable model.

You can either return a single player-id, or if you want to notify multiple player IDs just return an array containing all IDs.

public function routeNotificationForOneSignal()
{
    return 'ONE_SIGNAL_PLAYER_ID';
}

If you want to send the notification based on the OneSignal "syncHashedEmail" feature just return an array with the index "email". It isn't possible to use multiple E-Mails on one filter because of a limitation of the OneSignal API.

public function routeNotificationForOneSignal()
{
    return ['email' => '[email protected]'];
}

If you want to send the notification based on the OneSignal "Tags" feature just return an array with the index "tags".

public function routeNotificationForOneSignal()
{
    return ['tags' => ['key' => 'device_uuid', 'relation' => '=', 'value' => '1234567890-abcdefgh-1234567']];
}

If you want to send the notification based on an external user id you set using the setExternalUserId feature. This makes it really easy to target users based on their Laravel User Ids.

public function routeNotificationForOneSignal()
{
    return ['include_external_user_ids' => $this->id];
}

All available methods

  • setSubject(''): Accepts a string value for the title.
  • setBody(''): Accepts a string value for the notification body.
  • setIcon(''): Accepts an url for the icon.
  • setUrl(''): Accepts an url for the notification click event.
  • webButton(OneSignalWebButton $button): Allows you to add action buttons to the notification (Chrome 48+ (web push) only).
  • button(OneSignalButton $button): Allows you to add buttons to the notification (Supported by iOS 8.0 and Android 4.1+ devices. Icon only works for Android).
  • setData($key, $value): Allows you to set additional data for the message payload. For more information check the OneSignal documentation.
  • setParameter($key, $value): Allows you to set additional parameters for the message payload that are available for the REST API. For more information check the OneSignal documentation.
  • setImageAttachments($imageUrl): Allows you to set one Image to all possible Attachments OneSignal Attachment documentation.

Button usage

OneSignalMessage::create()
    ->button(
        OneSignalButton::create('id')
            ->text('button text')
            ->icon('button icon')
    );

WebButton usage

OneSignalMessage::create()
    ->webButton(
        OneSignalWebButton::create('id')
            ->text('button text')
            ->icon('button icon')
            ->url('button url')
    );

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

onesignal's People

Contributors

abhimanyu003 avatar abr4xas avatar ajayfroiden avatar ashpowell avatar atymic avatar casperboone avatar daraul avatar freekmurze avatar jaybizzle avatar jeffreyhyer avatar jt501 avatar laravel-shift avatar lkaemmerling avatar lloople avatar mattpawley avatar mbardelmeijer avatar mpociot avatar norgul avatar oyed avatar pavoltanuska avatar pedro-santiago avatar sml995 avatar studnitz avatar thecaliskan avatar themsaid avatar timacdonald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onesignal's Issues

App\User::routeNotificationForOneSignal must return a relationship instance

I have a table that stores the player_id of all my users. The relationship for my User model has a function that returns all the instances on the database for said user.

public function pushNotificationDevices() {
        return $this->hasMany('App\PushNotificationDevice');
    }

In the documentation it said to return either a single string of player_id or an array. Which you can see at the bottom of how I am returning the player_id. For some reason I get the following error whenever I try to return the array of player_ids App\User::routeNotificationForOneSignal must return a relationship instance. When returning an instance of PushNotificationDevice I get an internal error whenever the OneSignal notification is fired, which I suspect because I am returning a whole instance of PushNotificationDevice and not just an array of strings. Any ideas?

public function routeNotificationForOneSignal()
    {
        return $this->pushNotificationDevices()->pluck('player_id')->toArray();
    }

[Composer\Downloader\TransportException]

Error trying to install

The "http://packagist.org/p/symfony/polyfill-php70%244546075da4e1484628161afae5f1d4c964c7923d6ca8748a34cce8503299f80f.json" file could not be downloaded (HTTP/1.1 404 Not Found)

Laravel 5.5
composer data
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"mpociot/laravel-apidoc-generator": "^2.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0",
"symfony/thanks": "^1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r "file_exists('.env') || copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}

How to register device on onesignal ?

Hello dear !
Is there a way to register device on one-signal because one-signal only sends notification to those devices which are registered.
One signal api provides endpoint to do this but this package does not contain any info about it.
May be this package is only focused on web not mobile devices.

Can we make a notification with a link inside the app?

This is actually not a bug or an issue, it's more like a feature.

I have an app with In-App web browser. and I was just wondering if this is possible? So when a user opens the notification that it opens the app and through the In-App web browser opens the link?

Now the link from notification makes the phone default internet browser to open the link.

Connections remain after doing job

After sending some notifications, the connections will remain on CLOSE_WAIT state. The count of connections is equal to count of queue workers. It makes the server slow and sometimes it consumes a lot of bandwidth and make the whole application slow.
netstat -n -p :

tcp       32      0 88.99.00.00:42268      104.16.204.165:443      CLOSE_WAIT  12828/php

tcp       32      0 88.99.00.00:50298      104.16.205.165:443      CLOSE_WAIT  12832/php

tcp       32      0 88.99.00.00:44554      104.16.204.165:443      CLOSE_WAIT  12824/php

These ( ips: 104.16.20*.165 ) are for onesignal servers. Sometimes I should block all of them from iptables and kill -9 all php processes to restore the server speed.

Maybe it's because of not closing the request? Because Laravel doesn't destroy the queue scripts and they should flush manually. Please help to get out of this.

Looking for a new maintainer

Both @mpociot and myself don't have time to maintain this package anymore. We are looking for a maintainer for this package.

Ideally it's someone who already uses this package on multiple projects and has a good understanding of Laravel and knows (or whats to learn) package development.

Who's up for this?

Chrome Big Picture not work

Hi,

I need to set an large image as attachment for my notifications, but it doesn't work. This is my sample code:

public function toOneSignal($notifiable)
{
    return OneSignalMessage::create()
        ->setIcon($this->site_logo)
        ->setImageAttachments($this->post->featured_image)
        ->setSubject($this->post->title)
        ->setBody($this->post->getExcerpt(120))
        ->setUrl($this->post->canonical_link)
        ->setButton(
            OneSignalButton::create('id') ->text('Download')
        );
}

Please help me solve this. Any help would be appreciated! Thanks

How can I retrieve the OneSignal notification ID?

I am implementing a feature to track if user opened the notifications. So I will need to save the UDID of each OneSignal notification to database.

However, the UDID in notifications table can't be matched with notification UDIDs in OneSignal dashboard.

Any ideas to resolve this :)

Additional API parameters

I'm wondering if it would be possible (and within the scope of this plugin) to add functionality for setting ios badge information and/or other additional API parameters (content_available, subtitle, attachments) when sending a notification. Maybe through a setParameter/addParameter function (or a __call fluent syntax where ->ios_badgeType sets the badge parameter)...

Is it possible to send a notification using a template_id?

Hey guys. I've been trying to use this channel to send push notifications, but I really don't want to specify the headings of all my notifications, since I have all this setup on the Onesignal dashboard, with templates. I would like to send the notifications using the templates, like this:

return OneSignalMessage::create()
            ->setParameter('template_id', 'hash')
            ->setParameter('include_player_ids', 'push_userid')
            ->url(AutoLoginService::generateUrl($push_url, $notifiable->id));

When I try to run this, I always get the same error:

 Client error: `POST https://onesignal.com/api/v1/notifications` resulted in a `400 Bad Request` resp  
  onse:                                                                                                 
  {"errors":["Notification headings must not be null for any languages."]}    

It seems that this error is related with me not filling the subject of each notification. Is there a way for me to send the notifications using the templates?

Regards!

Issue while sending Same Push Notification to Multiple User : 400 Bad Request (Platforms You may only send to one delivery channel at a time. Make sure you are only including push platfor (truncated...))

In order to send same push notification to multiple users (for eg. all user following another user in a social networking app) while Referring to the documentation (http://laravel-notification-channels.com/onesignal/), it is mentioned to pass an array with multiple player ID from One Signal.

public function routeNotificationForOneSignal()
{
    return ["ONE_SIGNAL_PLAYER_ID_1","ONE_SIGNAL_PLAYER_ID_2","ONE_SIGNAL_PLAYER_ID_3"];
}

While we try to send push notification for above setup, it throws an error whose stack trace is as below.

{
    "message": "Client error: `POST https://onesignal.com/api/v1/notifications` resulted in a `400 Bad Request` response:\n{\"errors\":[\"Platforms You may only send to one delivery channel at a time. Make sure you are only including push platfor (truncated...)\n",
    "exception": "GuzzleHttp\\Exception\\ClientException",
    "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\guzzle\\src\\Exception\\RequestException.php",
    "line": 113,
    "trace": [
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\guzzle\\src\\Middleware.php",
            "line": 66,
            "function": "create",
            "class": "GuzzleHttp\\Exception\\RequestException",
            "type": "::"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
            "line": 203,
            "function": "GuzzleHttp\\{closure}",
            "class": "GuzzleHttp\\Middleware",
            "type": "::"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
            "line": 156,
            "function": "callHandler",
            "class": "GuzzleHttp\\Promise\\Promise",
            "type": "::"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\TaskQueue.php",
            "line": 47,
            "function": "GuzzleHttp\\Promise\\{closure}",
            "class": "GuzzleHttp\\Promise\\Promise",
            "type": "::"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
            "line": 246,
            "function": "run",
            "class": "GuzzleHttp\\Promise\\TaskQueue",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
            "line": 223,
            "function": "invokeWaitFn",
            "class": "GuzzleHttp\\Promise\\Promise",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
            "line": 267,
            "function": "waitIfPending",
            "class": "GuzzleHttp\\Promise\\Promise",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
            "line": 225,
            "function": "invokeWaitList",
            "class": "GuzzleHttp\\Promise\\Promise",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
            "line": 62,
            "function": "waitIfPending",
            "class": "GuzzleHttp\\Promise\\Promise",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\guzzle\\src\\Client.php",
            "line": 131,
            "function": "wait",
            "class": "GuzzleHttp\\Promise\\Promise",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\guzzlehttp\\guzzle\\src\\Client.php",
            "line": 89,
            "function": "request",
            "class": "GuzzleHttp\\Client",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\berkayk\\onesignal-laravel\\src\\OneSignalClient.php",
            "line": 292,
            "function": "__call",
            "class": "GuzzleHttp\\Client",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\berkayk\\onesignal-laravel\\src\\OneSignalClient.php",
            "line": 240,
            "function": "post",
            "class": "Berkayk\\OneSignal\\OneSignalClient",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel-notification-channels\\onesignal\\src\\OneSignalChannel.php",
            "line": 37,
            "function": "sendNotificationCustom",
            "class": "Berkayk\\OneSignal\\OneSignalClient",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php",
            "line": 144,
            "function": "send",
            "class": "NotificationChannels\\OneSignal\\OneSignalChannel",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php",
            "line": 103,
            "function": "sendToNotifiable",
            "class": "Illuminate\\Notifications\\NotificationSender",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Traits\\Localizable.php",
            "line": 19,
            "function": "Illuminate\\Notifications\\{closure}",
            "class": "Illuminate\\Notifications\\NotificationSender",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php",
            "line": 105,
            "function": "withLocale",
            "class": "Illuminate\\Notifications\\NotificationSender",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\ChannelManager.php",
            "line": 54,
            "function": "sendNow",
            "class": "Illuminate\\Notifications\\NotificationSender",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\SendQueuedNotifications.php",
            "line": 73,
            "function": "sendNow",
            "class": "Illuminate\\Notifications\\ChannelManager",
            "type": "->"
        },
        {
            "function": "handle",
            "class": "Illuminate\\Notifications\\SendQueuedNotifications",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php",
            "line": 29,
            "function": "call_user_func_array"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php",
            "line": 87,
            "function": "Illuminate\\Container\\{closure}",
            "class": "Illuminate\\Container\\BoundMethod",
            "type": "::"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php",
            "line": 31,
            "function": "callBoundMethod",
            "class": "Illuminate\\Container\\BoundMethod",
            "type": "::"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php",
            "line": 572,
            "function": "call",
            "class": "Illuminate\\Container\\BoundMethod",
            "type": "::"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php",
            "line": 94,
            "function": "call",
            "class": "Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 116,
            "function": "Illuminate\\Bus\\{closure}",
            "class": "Illuminate\\Bus\\Dispatcher",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 104,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php",
            "line": 98,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\CallQueuedHandler.php",
            "line": 49,
            "function": "dispatchNow",
            "class": "Illuminate\\Bus\\Dispatcher",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Jobs\\Job.php",
            "line": 83,
            "function": "call",
            "class": "Illuminate\\Queue\\CallQueuedHandler",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\SyncQueue.php",
            "line": 42,
            "function": "fire",
            "class": "Illuminate\\Queue\\Jobs\\Job",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php",
            "line": 184,
            "function": "push",
            "class": "Illuminate\\Queue\\SyncQueue",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php",
            "line": 160,
            "function": "pushCommandToQueue",
            "class": "Illuminate\\Bus\\Dispatcher",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Bus\\Dispatcher.php",
            "line": 73,
            "function": "dispatchToQueue",
            "class": "Illuminate\\Bus\\Dispatcher",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php",
            "line": 195,
            "function": "dispatch",
            "class": "Illuminate\\Bus\\Dispatcher",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\NotificationSender.php",
            "line": 74,
            "function": "queueNotification",
            "class": "Illuminate\\Notifications\\NotificationSender",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\ChannelManager.php",
            "line": 39,
            "function": "send",
            "class": "Illuminate\\Notifications\\NotificationSender",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Notifications\\RoutesNotifications.php",
            "line": 18,
            "function": "send",
            "class": "Illuminate\\Notifications\\ChannelManager",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\app\\Http\\Controllers\\Api\\GameController.php",
            "line": 219,
            "function": "notify",
            "class": "App\\Notification",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\app\\Http\\Controllers\\Api\\GameController.php",
            "line": 153,
            "function": "sendPushNotification",
            "class": "App\\Http\\Controllers\\Api\\GameController",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\app\\Http\\Controllers\\Api\\GameController.php",
            "line": 38,
            "function": "savePushNotification",
            "class": "App\\Http\\Controllers\\Api\\GameController",
            "type": "->"
        },
        {
            "function": "createGame",
            "class": "App\\Http\\Controllers\\Api\\GameController",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php",
            "line": 54,
            "function": "call_user_func_array"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php",
            "line": 45,
            "function": "callAction",
            "class": "Illuminate\\Routing\\Controller",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
            "line": 219,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\ControllerDispatcher",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
            "line": 176,
            "function": "runController",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 682,
            "function": "run",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 30,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\app\\Http\\Middleware\\JwtMiddleware.php",
            "line": 33,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "App\\Http\\Middleware\\JwtMiddleware",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php",
            "line": 41,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\ThrottleRequests.php",
            "line": 58,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 104,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 684,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 659,
            "function": "runRouteWithinStack",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 625,
            "function": "runRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 614,
            "function": "dispatchToRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
            "line": 176,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 30,
            "function": "Illuminate\\Foundation\\Http\\{closure}",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\nova\\src\\Http\\Middleware\\ServeNova.php",
            "line": 26,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Laravel\\Nova\\Http\\Middleware\\ServeNova",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\fideloper\\proxy\\src\\TrustProxies.php",
            "line": 57,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Fideloper\\Proxy\\TrustProxies",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
            "line": 31,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
            "line": 31,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php",
            "line": 27,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php",
            "line": 62,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 151,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 104,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
            "line": 151,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
            "line": 116,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\public\\index.php",
            "line": 55,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "D:\\repo\\socialnetworkingapp\\server.php",
            "line": 21,
            "function": "require_once"
        }
    ]
}

Subdomain

how can I use this library with multiple subdomains , because as I understand OneSignal not supporting multiple subdomains with same origin ?

Player ids limit?

How much can I choose a ONE_SIGNAL_PLAYER_IDS go at a time?
2000 its Maximum?

If messages are queued with implements ShouldQueue they are not sent

If queue driver in .env file is set to ('redis') the messages are not sent.
I have an email notification and all is working fine with redis queue, but sending onesignal notifications is not working

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\OneSignal\OneSignalChannel;
use NotificationChannels\OneSignal\OneSignalMessage;
use NotificationChannels\OneSignal\OneSignalWebButton;

class EventCommented extends Notification implements ShouldQueue
{
    use Queueable;

    public function via($notifiable)
    {
        return [OneSignalChannel::class];
    }

    public function toOneSignal($notifiable)
    {
        
        return OneSignalMessage::create()
            ->subject("Sack Zement")
            ->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')
            );
    }
}

Only if i delete "implements ShouldQueue" at the end of class naming then it works

Multiple include_player_ids

Hello,

i'm looking at using your package. I need to implement a function to be able to send push to an array of "include_player_ids".

Can this be done with your package?
Best regards,

Morgan

action button is not working

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')
);

Getting undefined index: app_id

Hi! Thanks for the great package.

Well im getting this error when sending pushes:
captura de tela 2017-09-26 as 11 48 08

My .env is ok with the ONESIGNAL_APP_ID and ONESIGNAL_REST_API_KEY;
MY config/services.php was updated too.
I did $ php artisan config:clear, cache:clear...

`
public function via($notifiable)
{
return [OneSignalChannel::class];
}

public function toOneSignal($notifiable)
{
    return OneSignalMessage::create()
        ->subject("Your account was approved!")
        ->body("Click here to see details.")
        ->url('http://onesignal.com');
}`

Any ideas?

Thank you!

How to send groupKey and largeIcon?

At the moment, I am sending the push notification messages from my Laravel 5.3 backend to OneSignal like this:

public function toOneSignal($notifiable)
    {
        return OneSignalMessage::create()
                               ->subject($this->subjectMsg)
                               ->body($this->notificationBody)
                               ->url($this->actionUrl);
    }

How can I also send a groupKey and largeIcon?

Thanks for your help.

Future of this Package

Hello everybody,

since @Lloople and i maintained this project now, we should discuss where we see the future of this package, what ToDos we have and so on.

First of all should we fix the open issues and review the open PRs.

Send notifications to different app_id

Currently the app_id to send notifications to is hardcoded through the settings in services.php.

I'm developing a backend serving several apps. Is there a way to provide the app_id inside the message?

composer install not working

Please,

Anyone could help me with this? Regards

Problem 1
- Installation request for laravel-notification-channels/onesignal ^1.0 -> satisfiable by laravel-notification-channels/onesignal[1.0.0].
- laravel-notification-channels/onesignal 1.0.0 requires berkayk/onesignal-laravel ^0.9.3 -> satisfiable by berkayk/onesignal-laravel[v0.9.3, v0.9.4, v0.9.5].
- berkayk/onesignal-laravel v0.9.3 requires symfony/psr-http-message-bridge ^0.2.0 -> satisfiable by symfony/psr-http-message-bridge[v0.2].
- berkayk/onesignal-laravel v0.9.4 requires symfony/psr-http-message-bridge ^0.2.0 -> satisfiable by symfony/psr-http-message-bridge[v0.2].
- berkayk/onesignal-laravel v0.9.5 requires symfony/psr-http-message-bridge ^0.2.0 -> satisfiable by symfony/psr-http-message-bridge[v0.2].
- Conclusion: don't install symfony/psr-http-message-bridge v0.2

An unexpected TLS packet was received

Hello i get this error while sending Notification

gnutls_handshake() failed: An unexpected TLS packet was received. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) {"exception":"[object] (GuzzleHttp\Exception\ConnectException(code: 0): cURL error 35: gnutls_handshake() failed: An unexpected TLS packet was received. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) at /home/runcloud/webapps/cloint/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:186)

Min Php Version

The title of the package is "...for Laravel 5.3+", but the min PHP version is 7.0 since the package's version 1.1.0. I have seen that in changelog after hours looking for why it does not work.

Laravel 5.3, and 5.4 don't require PHP 7, so I think you could indicate that requirement in the readme.

Send a notification to all users

Hi, is it possible to send a notification to all users in OneSignal? Without specifying player IDs in routeNotificationForOneSignal.
Thanks

only able to send by player ids

need to be able to add "filters" or payload in OneSignalChannel, to before send to Berkayk's

sendNotificationCustom($payload);

This package made impossible to send notification by filters.

Laravel 5.6.26 - Channel not supported

InvalidArgumentException: Driver [NotificationChannels\OneSignal\OneSignalChannel] not supported. in /var/www/html/myapp/vendor/laravel/framework/src/Illuminate/Support/Manager.php:97

Get Report

How can we get report from onesignal?

Dynamic Configuration

Hi guys! Any idea how can I dynamic set app_id and rest_api_key based on my $notifiable?

Sending notification to tags(notification no show)

My notification class like this:
Laravel 5.8 : App\User model class

1: I have set the app_id,rest_api_key in config/services.php file

2:I have passed value like this.(User model)
public function routeNotificationForOneSignal() {
return ['tags' => ['field' => 'user_id', 'relation' => '=', 'value' => 5]];
}

3: My notification class like this:(App\Notifications\InvoicePaid class)

use NotificationChannels\OneSignal\OneSignalChannel;
use NotificationChannels\OneSignal\OneSignalMessage;
use NotificationChannels\OneSignal\OneSignalWebButton;
use Illuminate\Notifications\Notification;

public function via($notifiable)
{   
    return [OneSignalChannel::class];
}     

public function toOneSignal($notifiable)
{
return OneSignalMessage::create()
->subject("Your Notifications")
->body("Click here to Notifications.");
->url('http://127.0.0.1:8000/home')
->webButton(
OneSignalWebButton::create('http://127.0.0.1:8000/home')
->text('button text')
->icon('button icon')
->url('http://127.0.0.1:8000/home')
);

I have not found any error but still Push notification not show . Please help me.

Not Support with Laravel 6.0.3

i have got this error after run composer command
"composer require laravel-notification-channels/onesignal"

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install laravel-notification-channels/onesignal 1.2.0
- Conclusion: remove laravel/framework v6.0.3
- Installation request for laravel-notification-channels/onesignal ^1.2 -> satisfiable by laravel-notification-channels/onesignal[1.2.0, v1.2.0-rc.1].
- Conclusion: don't install laravel/framework v6.0.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.