Skip to content

Commit 65555fb

Browse files
committed
Readme
1 parent 4822d82 commit 65555fb

File tree

2 files changed

+122
-36
lines changed

2 files changed

+122
-36
lines changed

README.md

Lines changed: 113 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
# Laravel package for simpliefied integration with Pishmix web push notification service.
1+
## Pishmix Web Push Notifications Service for Laravel
22

33
## About
44

5-
This package integrates Pushmix service with Laravel applications allowing inclusion of web notification opt in prompt to any template and sending notification messages using API from Controller.
5+
This package integrates Pushmix service with Laravel applications providing following features:
66

7+
* Subscription opt in prompt in your templates
8+
* Send push notification messages from Laravel application
79

8-
## Installation
10+
## Requirements
11+
* [PHP cURL](http://php.net/manual/en/curl.installation.php)
12+
* [Pushmix](https://www.pushmix.co.uk) Subscriber Id
13+
* Website must use HTTPS protocol
914

10-
The preferred method of installation is via Composer. Run the following command to install the package to your project's `composer.json`:
15+
## Installation
1116

17+
Create subscription at [Pushmix](https://www.pushmix.co.uk), copy your `subscription_id` and paste into `.env` file.
1218
```bash
13-
composer require pushmix/laravel-web-notification:dev-master
19+
PUSHMIX_SUBSCRIPTION_ID=MY_SUBSCRIPTION_ID
1420
```
1521

16-
Create subscription at [Pushmix](https://www.pushmix.co.uk), copy your `subscription_id` and paste into `.env` file.
22+
The preferred method of installation is via Composer. Run the following command to install the package to your project's `composer.json`:
23+
1724
```bash
18-
PUSHMIX_SUBSCRIPTION_ID=MY_SUBSCRIPTION_ID
25+
composer require pushmix/laravel-web-notification
1926
```
2027

2128
Publish package assets and you good to go.
@@ -24,28 +31,60 @@ php artisan vendor:publish --provider="Pushmix\WebNotification\PushmixServicePro
2431
```
2532

2633
## Display Opt In Prompt
27-
Display opt in prompt to your website visitor by including few lines of JavaScript into your view.
34+
35+
Display opt in prompt to your website visitor by including it into your template. Alternatively you can manually copy and paste content of `vendor.pushmix.optin` into template. Preview in the web browser to ensure that opt in prompt is trigegred. Please note that web browser must be compatible with Push API, otherwise opt in prompt will not be displayed.
36+
2837
```bash
38+
<body>
39+
...
40+
41+
<div class="content">
42+
<div class="title m-b-md">
43+
Laravel
44+
</div>
45+
</div>
46+
47+
<!-- Including Opt In Prompt in Blade template-->
48+
49+
@include('vendor.pushmix.optin')
50+
51+
</body>
52+
...
2953
```
3054

31-
## Retrieving Topics
3255

33-
Response from `Pushmix::getTopics()` or an empty array
56+
57+
## Sending Message
58+
Sending message to your subscribers is simple. First add reference to Pushmix class, than create an array with four requiried parameters.
59+
60+
* `topic` - defines audience you would like to target, see bellow Retrieving Topics
61+
* `title` - notification title, keep it short
62+
* `body` - notification body content, keep it short
63+
* `default_url` - valid URL, will used when user click on the notification
64+
65+
Other parameters are optional.
66+
67+
To push notiication out to your subscribers use push method passing an array of notification parameters
68+
```php
69+
Pushmix::push( $msg_data )
70+
```
71+
Success Response
3472

3573
```bash
36-
array:2 [
37-
0 => {
38-
"id": 17
39-
"topic_name": "Service Updates"
40-
}
41-
1 => {
42-
"id": 18
43-
"topic_name": "Pushmix News"
44-
}
45-
]
74+
{
75+
"succes": true
76+
}
4677
```
4778

48-
## Sending Message
79+
Error Response
80+
81+
```bash
82+
{
83+
"error": "Error message"
84+
}
85+
```
86+
87+
Full example of push method with all available parameters.
4988

5089
```php
5190
<?php
@@ -102,30 +141,71 @@ class PushmixController extends Controller
102141

103142
Pushmix::push( $msg_data);
104143

105-
return view('tnankyou');
144+
return view('thankyou');
106145

107146

108147
}
109148
/***/
110149
}
111150
```
112151

152+
## Subscription Topics
113153

154+
If you haven't specified additional topics in your subscription in the Pushmix dashboard than you don't need to read this.
114155

115-
Responses from `Pushmix::push( $msg_data )`
156+
Please note: you can always edit your subscription and add/or remove topics. If you have added new topics to your subscription you will need to call this method in order to obtain your topics id's.
116157

117-
Success Response
158+
Ability to send messages to all subscribers is great, but sometimes you only need to target those users who have expressed thier interest by opting in one of your topics. Audience segmentation is the solution.
118159

119-
```bash
120-
{
121-
"succes": true
122-
}
123-
```
160+
To push message to a topic subscribers first you will need to obtain topic id by calling `Pushmix::getTopics()`
161+
This call will return an array of topic names and id's or an empty array in case if you haven't created any topics.
124162

125-
Error Response
163+
```php
164+
<?php
126165

127-
```bash
166+
namespace App\Http\Controllers;
167+
168+
use Illuminate\Http\Request;
169+
use Pushmix;
170+
171+
class PushmixController extends Controller
128172
{
129-
"error": "Error message"
173+
174+
public function index()
175+
{
176+
177+
// retrive your subscription topics
178+
$my_topics = Pushmix::getTopics();
179+
180+
/**
181+
content of $my_topics
182+
183+
array:2 [
184+
0 => {
185+
"id": 17
186+
"topic_name": "Service Updates"
187+
}
188+
1 => {
189+
"id": 18
190+
"topic_name": "Pushmix News"
191+
}
192+
]
193+
**/
194+
195+
$msg_data = [
196+
// Required Parameters
197+
'topic' => '17', // subscribers of Service Updates topic only
198+
'title' => 'New Feature',
199+
'body' => 'Use Pushmix wihin your Laravel application, see details',
200+
'default_url' => 'https://www.pushmix.co.uk/features',
201+
];
202+
203+
Pushmix::push( $msg_data);
204+
205+
return view('thankyou');
206+
207+
208+
}
209+
/***/
130210
}
131-
```
211+
```

composer.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
{
22
"name": "pushmix/laravel-web-notification",
33
"type": "library",
4-
"description": "Pushmix Web Notifications Laravel Package",
4+
"description": "Pushmix Web Push Notifications Service for Laravel",
55
"keywords": ["web notifications","notifications", "pushmix"],
66
"homepage": "https://github.com/pushmix/laravel-web-notification",
7+
"support": {
8+
"issues": "https://github.com/pushmix/laravel-web-notification/issues",
9+
"source": "https://github.com/pushmix/laravel-web-notification"
10+
},
711
"license": "MIT",
812
"authors": [
913
{
10-
"name": "Alexander",
11-
"email": "[email protected]"
14+
"name": "Alexander Pechkarev",
15+
"email": "[email protected]",
16+
"homepage": "https://www.pushmix.co.uk"
1217
}
1318
],
19+
"minimum-stability": "dev",
1420
"require": {
1521
"laravel/framework": ">=5.5"
1622
},

0 commit comments

Comments
 (0)