{"id":20696011,"url":"https://github.com/laravel-notification-channels/onesignal","last_synced_at":"2025-05-14T10:06:20.257Z","repository":{"id":38552703,"uuid":"65480774","full_name":"laravel-notification-channels/onesignal","owner":"laravel-notification-channels","description":"OneSignal notifications channel for Laravel","archived":false,"fork":false,"pushed_at":"2025-04-01T00:31:31.000Z","size":130,"stargazers_count":287,"open_issues_count":23,"forks_count":128,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-14T01:49:16.933Z","etag":null,"topics":["hacktoberfest","laravel","onesignal"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laravel-notification-channels.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-08-11T15:32:32.000Z","updated_at":"2025-04-07T22:53:51.000Z","dependencies_parsed_at":"2024-04-01T05:25:18.864Z","dependency_job_id":"afe57b1f-b26d-46a5-9390-1c6ca77c0203","html_url":"https://github.com/laravel-notification-channels/onesignal","commit_stats":{"total_commits":94,"total_committers":27,"mean_commits":"3.4814814814814814","dds":0.7872340425531915,"last_synced_commit":"13a7b7dae6be35681d432250264a29bf7aefb853"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-notification-channels%2Fonesignal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-notification-channels%2Fonesignal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-notification-channels%2Fonesignal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-notification-channels%2Fonesignal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laravel-notification-channels","download_url":"https://codeload.github.com/laravel-notification-channels/onesignal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254119471,"owners_count":22017951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","laravel","onesignal"],"created_at":"2024-11-17T00:12:13.974Z","updated_at":"2025-05-14T10:06:20.190Z","avatar_url":"https://github.com/laravel-notification-channels.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OneSignal notifications channel for Laravel 5.3+\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/onesignal.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/onesignal)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/laravel-notification-channels/onesignal/master.svg?style=flat-square)](https://travis-ci.org/laravel-notification-channels/onesignal)\n[![StyleCI](https://styleci.io/repos/65379321/shield)](https://styleci.io/repos/65379321)\n[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/9015691f-130d-4fca-8710-72a010abc684.svg?style=flat-square)](https://insight.sensiolabs.com/projects/9015691f-130d-4fca-8710-72a010abc684)\n[![Quality Score](https://img.shields.io/scrutinizer/g/laravel-notification-channels/onesignal.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/onesignal)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/onesignal/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/onesignal/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/onesignal.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/onesignal)\n\nThis package makes it easy to send [OneSignal notifications](https://documentation.onesignal.com/docs) with Laravel 5.3+.\n\n## Contents\n\n- [Installation](#installation)\n\t- [Setting up your OneSignal account](#setting-up-your-onesignal-account)\n- [Usage](#usage)\n\t- [Available Message methods](#all-available-methods)\n\t- [Button usage](#button-usage)\n\t- [WebButton usage](#webbutton-usage)\n- [Changelog](#changelog)\n- [Testing](#testing)\n- [Security](#security)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\n$ composer require laravel-notification-channels/onesignal\n```\n\nIf you're installing the package in Laravel 5.4 or lower, you must import the service provider:\n\n```php\n// config/app.php\n'providers' =\u003e [\n    ...\n    NotificationChannels\\OneSignal\\OneSignalServiceProvider::class,\n],\n```\n\n### Setting up your OneSignal account\n\nAdd your OneSignal App ID and REST API Key to your `config/services.php`:\n\n```php\n// config/services.php\n...\n'onesignal' =\u003e [\n    'app_id' =\u003e env('ONESIGNAL_APP_ID'),\n    'rest_api_url' =\u003e env('ONESIGNAL_REST_API_URL', 'https://api.onesignal.com'),\n    'rest_api_key' =\u003e env('ONESIGNAL_REST_API_KEY'),\n    'guzzle_client_timeout' =\u003e env('ONESIGNAL_GUZZLE_CLIENT_TIMEOUT', 0),\n],\n...\n```\n\n\n## Usage\n\nNow you can use the channel in your `via()` method inside the notification:\n\n``` php\nuse NotificationChannels\\OneSignal\\OneSignalChannel;\nuse NotificationChannels\\OneSignal\\OneSignalMessage;\nuse NotificationChannels\\OneSignal\\OneSignalWebButton;\nuse Illuminate\\Notifications\\Notification;\n\nclass AccountApproved extends Notification\n{\n    public function via($notifiable)\n    {\n        return [OneSignalChannel::class];\n    }\n\n    public function toOneSignal($notifiable)\n    {\n        return OneSignalMessage::create()\n            -\u003esetSubject(\"Your {$notifiable-\u003eservice} account was approved!\")\n            -\u003esetBody(\"Click here to see details.\")\n            -\u003esetUrl('http://onesignal.com')\n            -\u003ewebButton(\n                OneSignalWebButton::create('link-1')\n                    -\u003etext('Click here')\n                    -\u003eicon('https://upload.wikimedia.org/wikipedia/commons/4/4f/Laravel_logo.png')\n                    -\u003eurl('http://laravel.com')\n            );\n    }\n}\n```\n\nIn order to let your Notification know which OneSignal user(s) you are targeting, add the `routeNotificationForOneSignal` method to your Notifiable model.\n\nYou can either return a single player-id, or if you want to notify multiple player IDs just return an array containing all IDs.\n\n```php\npublic function routeNotificationForOneSignal()\n{\n    return 'ONE_SIGNAL_PLAYER_ID';\n}\n```\n\nIf 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.**\n\n```php\npublic function routeNotificationForOneSignal()\n{\n    return ['email' =\u003e 'example@example.com'];\n}\n```\n\nIf you want to send the notification based on the OneSignal \"Tags\" feature just return an array with the index \"tags\".\n\n```php\npublic function routeNotificationForOneSignal()\n{\n    return ['tags' =\u003e ['key' =\u003e 'device_uuid', 'relation' =\u003e '=', 'value' =\u003e '1234567890-abcdefgh-1234567']];\n}\n```\n\nIf 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.\n\n```php\npublic function routeNotificationForOneSignal()\n{\n    return ['include_external_user_ids' =\u003e $this-\u003eid];\n}\n```\n\n### All available methods\n\n- `setSubject('')`: Accepts a string value for the title.\n- `setBody('')`: Accepts a string value for the notification body.\n- `setIcon('')`: Accepts an url for the icon.\n- `setUrl('')`: Accepts an url for the notification click event.\n- `webButton(OneSignalWebButton $button)`: Allows you to add action buttons to the notification (Chrome 48+ (web push) only).\n- `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).\n- `setData($key, $value)`: Allows you to set additional data for the message payload. For more information check the [OneSignal documentation](https://documentation.onesignal.com/reference).\n- `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](https://documentation.onesignal.com/reference).\n- `setImageAttachments($imageUrl)`: Allows you to set one Image to all possible Attachments [OneSignal Attachment documentation](https://documentation.onesignal.com/reference#section-attachments).\n\n### Button usage\n\n```php\nOneSignalMessage::create()\n    -\u003ebutton(\n        OneSignalButton::create('id')\n            -\u003etext('button text')\n            -\u003eicon('button icon')\n    );\n```\n\n### WebButton usage\n\n```php\nOneSignalMessage::create()\n    -\u003ewebButton(\n        OneSignalWebButton::create('id')\n            -\u003etext('button text')\n            -\u003eicon('button icon')\n            -\u003eurl('button url')\n    );\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n```bash\n$ composer test\n```\n\n## Security\n\nIf you discover any security related issues, please email m.pociot@gmail.com instead of using the issue tracker.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Marcel Pociot](https://github.com/mpociot)\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [Lukas Kämmerling](https://github.com/LKDevelopment)\n- [David Llop](https://github.com/Lloople)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravel-notification-channels%2Fonesignal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaravel-notification-channels%2Fonesignal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravel-notification-channels%2Fonesignal/lists"}