Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CoreManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type ObjectStateController = {
duplicateState: (source: any, dest: any) => void;
};
type PushController = {
send: (data: PushData, options: RequestOptions) => Promise;
send: (data: PushData) => Promise;
};
type QueryController = {
find: (className: string, params: QueryJSON, options: RequestOptions) => Promise;
Expand Down
32 changes: 10 additions & 22 deletions src/Push.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import CoreManager from './CoreManager';
import ParseQuery from './ParseQuery';

import type { WhereClause } from './ParseQuery';
import type { RequestOptions } from './RESTController';

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

/**
* Sends a push notification.
* **Available in Cloud Code only.**
*
* See {@link https://docs.parseplatform.org/js/guide/#push-notifications Push Notification Guide}
*
* @method send
* @name Parse.Push.send
* @param {Object} data - The data of the push notification. Valid fields
Expand All @@ -43,21 +46,12 @@ export type PushData = {
* <li>expiration_interval - The seconds from now to expire the push.</li>
* <li>where - A Parse.Query over Parse.Installation that is used to match
* a set of installations to push to.</li>
* <li>data - The data to send as part of the push</li>
* <li>data - The data to send as part of the push.</li>
* <ol>
* @param {Object} options An object that has an optional success function,
* that takes no arguments and will be called on a successful push, and
* an error function that takes a Parse.Error and will be called if the push
* failed.
* @return {Promise} A promise that is fulfilled when the push request
* completes.
*/
export function send(
data: PushData,
options?: { useMasterKey?: boolean, success?: any, error?: any }
): Promise {
options = options || {};

export function send(data: PushData): Promise {
if (data.where && data.where instanceof ParseQuery) {
data.where = data.where.toJSON().where;
}
Expand All @@ -76,23 +70,17 @@ export function send(
);
}

return CoreManager.getPushController().send(data, {
useMasterKey: options.useMasterKey
});
return CoreManager.getPushController().send(data);
}

const DefaultController = {
send(data: PushData, options: RequestOptions) {
const RESTController = CoreManager.getRESTController();

const request = RESTController.request(
send(data: PushData) {
return CoreManager.getRESTController().request(
'POST',
'push',
data,
{ useMasterKey: !!options.useMasterKey }
{ useMasterKey: true }
);

return request;
}
}

Expand Down