Breaking Down Push Notifications to an Array of Users in Parse Server

When passing a "message" of type String and "User" of type [String](), this code is used:

Parse.Cloud.define("invite", function(request,response) {

    var message = request.params.message;
    var pushQuery = new Parse.Query(Parse.Installation);
    pushQuery.containedIn("user",request.params.User);  

    Parse.Push.send({
      where: pushQuery,
      data : { 
        alert: message,
        "badge": 1,
      }
    }, {
    success: function(result) {
    console.log(JSON.stringify(result));
    response.success(result);
    },
    error: function(error) {
    console.error(JSON.stringify(error));
    response.error(error.message)
    },
    useMasterKey: true
    });
});

An error occurs when trying to run the code, resulting in the following log message:

_PushStatus Qwd8rDJKLu: error while sending push code=107, message=bad $in value

Answer №1

When using Parse.Query.containedIn, it is important that the second parameter be an array. The error message mentioning bad $in value only occurs when the second parameter is not undefined and not an array.

To resolve this issue, make sure that the value of request.params.User is indeed an array. You can verify this by using

console.log(typeof request.params.User)
.

If you are passing the type [String](), keep in mind that it may end up being converted to a string with brackets included.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript ECMAScript 6 - WARNING: "Decorators can only be applied to a class when exporting"

In ECMAScript 6, I am attempting to export a function so that I can import it and utilize it in other files for the sake of writing DRY code. However, an error message is appearing: You can only use decorators on an export when exporting a class (16:0) ...

Load a PHP page using AJAX that triggers a JavaScript function

My goal is to enhance a progress bar (using Bootstrap) while a PHP page processes data from an AJAX GET request. Currently, the progress bar only updates once the AJAX request is fully completed. Although there is more content on the pages than what' ...

Passing a variable between pages in PHP: a simple guide

In my *book_order* page, I allow users to input orders into a table called *order_management*. The order_id is auto-incremented in this table. After submitting the page, I need to pass the order_id to another page named *book_order2* where products can be ...

A dynamic input field will appear on the page following the closing </form> tag

I encountered an unusual situation where upon clicking a button with the id #fusk, dynamic elements are added. Here is the code snippet: $('#imgc').append( "<div class='divi'>" + "<input type='hidden' name=' ...

Encountered an issue with the property 'push' not being defined

Here's the schema for my mongoose model in JavaScript: const mongoose = require('mongoose'); const Schema = mongoose.Schema; const CartSchema = new Schema({ userID: String, items: [{ itemID: String, quantity: Number }] }); modul ...

Utilize A-frame image resources within JavaScript code

Currently, I am utilizing an image as a texture in multiple instances. Once through the material component and another time within a custom component where I am using THREE.TextureLoader(), resulting in the application loading the image two times. I believ ...

How to arrange elements at the same level in Node.js using sequelize-hierarchy?

Is there a way to change the order of items on the same level in sequelize-hierarchy for creating a menu? I've noticed that currently, the items are ordered by their sequence of insertion. But what if I want to manually set the order? Here is an exam ...

Utilizing a font URL imported through a script

I am currently working on incorporating the pdfmake package into my application. In order to load fonts, a list of URLs is required during initialization. However, the fonts I am using are managed by npm and Vite, so they do not have fixed URLs. Here' ...

Refreshing data on the go with NSFetchedResultsController and live updates

Despite numerous inquiries on this topic, I am unable to find a solution to my issue. When reordering cells with core data, I encounter duplicate cells during editing and scrolling. Although the reorder function works correctly, reloading the view after ed ...

Extracting information from the identifier of an option within a dropdown menu <select>

I'm currently working on fetching data from a based on the choice made by the user. The data is coming from the OpenDota API. Upon inspecting the element, I can see that the option tag is being populated correctly. However, I believe I might be handl ...

How to loop through nested objects in JavaScript without using jQuery

Currently attempting to loop through a nested object. array=[ { id: 2, items: [ { id: 12 }, { id: 13 }, { id: 14 } ] }, { id: 3, items: [ { id: 15 } ...

Integrate actual Angular $timeout service implementation into a unit test using Karma and Jasmine

I have a small Angular service that implements asynchronous rate-limiting for other functions, similar to this sample. Given that the core purpose of this class is to manage asynchronous behaviors, I need to test it in an asynchronous manner - purely synch ...

Verifying the existence of a file within the package

Is there a way to verify the existence of a file within the external bundle loaded in the app before attempting to fetch it? ...

Is it possible to define a data type from an external package using TypeScript and Node.js?

I'm currently in the process of reorganizing some code to utilize a list of signals and connect `.once` handlers to each one individually. const terminationSignals = ["SIGINT", "SIGUSR2", "SIGTERM"]; terminationSignals.f ...

What is causing the ID value to be consistently set to black without any manual input?

I'm currently working on building an "Order form" and my objective is to have a message displayed when the user selects "black" from the dropdown menu. The issue I'm facing is that the value is automatically set to black, causing the statement to ...

Ensure the detection of 404 error status using jQuery

My current approach involves using this code snippet to retrieve data from Twitter through its API: $.ajax({ url : apiUrl, cache : false, crossDomain: true, dataType: "jsonp", success : f ...

Jquery trigger causing href links to malfunction

Here is a JavaScript example: var sampleFunction = function(){ return { initialize : function(data) { this.sendRequest({ action : 'login' }); }, loginAction : function() { ...

Transferring JSON information from JavaScript to PHP with Ajax

Below is the JavaScript code I am working with: window.onload = function() { 'use strict'; var ajax = getXMLHttpRequestObject(); ajax.onreadystatechange = function() { if ( ajax.readyState == 4 ) { if ( (ajax.status >= 200 && ...

Constructing an array in an asynchronous manner while simultaneously iterating through other arrays

In my attempt to create a comprehensive keyword list from the existing keywords, I successfully retrieved them all and displayed them in the debug console. However, I am facing confusion regarding the appropriate time and method to call resolve(taxonomyKe ...

Error with the project link for Djinni's fast implementation

[Exploring Your First Cross-Platform Djinni App: Part 2 on iOS][1] After following the given guideline, everything seemed to work smoothly when creating a new project using Object-C. However, I decided to opt for a Swift project instead and encountered so ...