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:
213213``` php
214214$data = array("alert" => "Hi!");
215215
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+
218220
219221// Push to Channels
220222ParsePush::send(array(
221223 "channels" => ["PHPFans"],
222224 "data" => $data
223225), true);
224226
227+
225228// Push to Query
226229$query = ParseInstallation::query();
227230$query->equalTo("design", "rad");
@@ -231,8 +234,13 @@ ParsePush::send(array(
231234 "data" => $data
232235), true);
233236
237+
234238// Get Push Status
235- $response = ParsePush::send($data, true);
239+ $response = ParsePush::send(array(
240+ "channels" => ["StatusFans"],
241+ "data" => $data
242+ ), true);
243+
236244if(ParsePush::hasStatus($response)) {
237245
238246 // Retrieve PushStatus object
Original file line number Diff line number Diff line change @@ -41,6 +41,46 @@ public function testBasicPush()
4141 , true );
4242 }
4343
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+
4484 public function testPushToQuery ()
4585 {
4686 $ query = ParseInstallation::query ();
You can’t perform that action at this time.
0 commit comments