You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Laravel package for simpliefied integration with Pishmix web push notification service.
1
+
## Pishmix Web Push Notifications Service for Laravel
2
2
3
3
## About
4
4
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:
6
6
7
+
* Subscription opt in prompt in your templates
8
+
* Send push notification messages from Laravel application
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
+
28
37
```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
+
...
29
53
```
30
54
31
-
## Retrieving Topics
32
55
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
34
72
35
73
```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
+
}
46
77
```
47
78
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.
49
88
50
89
```php
51
90
<?php
@@ -102,30 +141,71 @@ class PushmixController extends Controller
102
141
103
142
Pushmix::push( $msg_data);
104
143
105
-
return view('tnankyou');
144
+
return view('thankyou');
106
145
107
146
108
147
}
109
148
/***/
110
149
}
111
150
```
112
151
152
+
## Subscription Topics
113
153
154
+
If you haven't specified additional topics in your subscription in the Pushmix dashboard than you don't need to read this.
114
155
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.
116
157
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.
118
159
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.
124
162
125
-
Error Response
163
+
```php
164
+
<?php
126
165
127
-
```bash
166
+
namespace App\Http\Controllers;
167
+
168
+
use Illuminate\Http\Request;
169
+
use Pushmix;
170
+
171
+
class PushmixController extends Controller
128
172
{
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',
0 commit comments