File tree Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Expand file tree Collapse file tree 2 files changed +51
-3
lines changed Original file line number Diff line number Diff line change @@ -213,15 +213,18 @@ Push:
213
213
``` php
214
214
$data = array("alert" => "Hi!");
215
215
216
- // Parse Server requires the master key for sending push. Pass true as the second parameter.
217
- ParsePush::send($data, true);
216
+ // Parse Server has a few requirements:
217
+ // - The master key is required for sending pushes, pass true as the second parameter
218
+ // - You must set your recipients by using 'channels' or 'where', but you must not pass both
219
+
218
220
219
221
// Push to Channels
220
222
ParsePush::send(array(
221
223
"channels" => ["PHPFans"],
222
224
"data" => $data
223
225
), true);
224
226
227
+
225
228
// Push to Query
226
229
$query = ParseInstallation::query();
227
230
$query->equalTo("design", "rad");
@@ -231,8 +234,13 @@ ParsePush::send(array(
231
234
"data" => $data
232
235
), true);
233
236
237
+
234
238
// Get Push Status
235
- $response = ParsePush::send($data, true);
239
+ $response = ParsePush::send(array(
240
+ "channels" => ["StatusFans"],
241
+ "data" => $data
242
+ ), true);
243
+
236
244
if(ParsePush::hasStatus($response)) {
237
245
238
246
// Retrieve PushStatus object
Original file line number Diff line number Diff line change @@ -41,6 +41,46 @@ public function testBasicPush()
41
41
, true );
42
42
}
43
43
44
+ /**
45
+ * @group parse-push
46
+ */
47
+ public function testMissingWhereAndChannels ()
48
+ {
49
+ $ this ->setExpectedException (ParseException::class,
50
+ "Sending a push requires either \"channels \" or a \"where \" query. " );
51
+
52
+ ParsePush::send ([
53
+ 'data ' => [
54
+ 'alert ' => 'are we missing something? '
55
+ ]
56
+ ], true );
57
+
58
+ }
59
+
60
+ /**
61
+ * @group parse-push
62
+ */
63
+ public function testWhereAndChannels ()
64
+ {
65
+ $ this ->setExpectedException (ParseException::class,
66
+ "Channels and query can not be set at the same time. " );
67
+
68
+ $ query = ParseInstallation::query ();
69
+ $ query ->equalTo ('key ' , 'value ' );
70
+
71
+ ParsePush::send ([
72
+ 'data ' => [
73
+ 'alert ' => 'too many limits '
74
+ ],
75
+ 'channels ' => [
76
+ 'PushFans ' ,
77
+ 'PHPFans '
78
+ ],
79
+ 'where ' => $ query
80
+ ], true );
81
+
82
+ }
83
+
44
84
public function testPushToQuery ()
45
85
{
46
86
$ query = ParseInstallation::query ();
You can’t perform that action at this time.
0 commit comments