Skip to content

Commit 13b47ca

Browse files
authored
Improve Parse.Push Documentation (parse-community#1238)
1 parent ab78dc8 commit 13b47ca

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

src/CoreManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type ObjectStateController = {
7070
duplicateState: (source: any, dest: any) => void;
7171
};
7272
type PushController = {
73-
send: (data: PushData, options: RequestOptions) => Promise;
73+
send: (data: PushData) => Promise;
7474
};
7575
type QueryController = {
7676
find: (className: string, params: QueryJSON, options: RequestOptions) => Promise;

src/Push.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import CoreManager from './CoreManager';
1313
import ParseQuery from './ParseQuery';
1414

1515
import type { WhereClause } from './ParseQuery';
16-
import type { RequestOptions } from './RESTController';
1716

1817
export type PushData = {
1918
where?: WhereClause | ParseQuery;
@@ -31,6 +30,10 @@ export type PushData = {
3130

3231
/**
3332
* Sends a push notification.
33+
* **Available in Cloud Code only.**
34+
*
35+
* See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
36+
*
3437
* @method send
3538
* @name Parse.Push.send
3639
* @param {Object} data - The data of the push notification. Valid fields
@@ -43,21 +46,12 @@ export type PushData = {
4346
* <li>expiration_interval - The seconds from now to expire the push.</li>
4447
* <li>where - A Parse.Query over Parse.Installation that is used to match
4548
* a set of installations to push to.</li>
46-
* <li>data - The data to send as part of the push</li>
49+
* <li>data - The data to send as part of the push.</li>
4750
* <ol>
48-
* @param {Object} options An object that has an optional success function,
49-
* that takes no arguments and will be called on a successful push, and
50-
* an error function that takes a Parse.Error and will be called if the push
51-
* failed.
5251
* @return {Promise} A promise that is fulfilled when the push request
5352
* completes.
5453
*/
55-
export function send(
56-
data: PushData,
57-
options?: { useMasterKey?: boolean, success?: any, error?: any }
58-
): Promise {
59-
options = options || {};
60-
54+
export function send(data: PushData): Promise {
6155
if (data.where && data.where instanceof ParseQuery) {
6256
data.where = data.where.toJSON().where;
6357
}
@@ -76,23 +70,17 @@ export function send(
7670
);
7771
}
7872

79-
return CoreManager.getPushController().send(data, {
80-
useMasterKey: options.useMasterKey
81-
});
73+
return CoreManager.getPushController().send(data);
8274
}
8375

8476
const DefaultController = {
85-
send(data: PushData, options: RequestOptions) {
86-
const RESTController = CoreManager.getRESTController();
87-
88-
const request = RESTController.request(
77+
send(data: PushData) {
78+
return CoreManager.getRESTController().request(
8979
'POST',
9080
'push',
9181
data,
92-
{ useMasterKey: !!options.useMasterKey }
82+
{ useMasterKey: true }
9383
);
94-
95-
return request;
9684
}
9785
}
9886

0 commit comments

Comments
 (0)