From 71b78155385577bbe481810cacb2b731cd12ac5e Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Thu, 22 Oct 2020 21:52:11 -0500 Subject: [PATCH] Improve Parse.Push Documentation --- src/CoreManager.js | 2 +- src/Push.js | 32 ++++++++++---------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/CoreManager.js b/src/CoreManager.js index 7a9fed145..d402216dc 100644 --- a/src/CoreManager.js +++ b/src/CoreManager.js @@ -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; diff --git a/src/Push.js b/src/Push.js index 41c7aec3d..af953e881 100644 --- a/src/Push.js +++ b/src/Push.js @@ -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; @@ -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 @@ -43,21 +46,12 @@ export type PushData = { *
  • expiration_interval - The seconds from now to expire the push.
  • *
  • where - A Parse.Query over Parse.Installation that is used to match * a set of installations to push to.
  • - *
  • data - The data to send as part of the push
  • + *
  • data - The data to send as part of the push.
  • *
      - * @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; } @@ -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; } }