如何在 Android App 中使用 Parse 检索推送通知中的解析用户列表

问题描述:

我们是推送通知概念的新手,我们已将我们的应用程序安装到三个手机中;名称在解析服务器名称中注册,例如 tab、sam、sony.现在我们需要在一个列表中获取三个名称.我们尝试过,但我们没有运气!

We are new to push notification concept,we have installed our App into three mobiles & names are registered in parse server names like tab,sam,sony. Now we need to get three names in one list. we tried but we don't have luck!

JSONObject i1=ParseInstallation.getCurrentInstallation().getJSONObject("user");//user is key in parse
             System.out.println("users "+i1);

另一种方式

 ParseObject pa1=(ParseObject) ParseObject.fetchAll("user");

我们需要在 parse 中注册所有用户.因为我们需要根据来自 UI 的名称单独发送推送通知.

we need all user registred in parse.Because we need to send push notification individually based on name fromUI.

请告诉我是否可能.如果可能,请指导我.....!

Please tell me if it is possible or not. if possible guide me.....!

现在我明白你的问题了.因此,您想要查询 Parse Installation 表并检索用户列值.您可以通过编写一个云函数来实现这一点,您必须在其中使用 Parse.Installation 查询.例如下面的代码查询安装表并检索所有用户列值;

Now I understand your question. So, you want to query the Parse Installation table and retrieve the user column values. You can achieve this via writing a cloud function where you have to user Parse.Installation query. For example below code query the Installation table and retrieve all of user column values;

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

  Parse.Cloud.useMasterKey();
  var query = new Parse.Query(Parse.Installation);
  var usernameList = "";
  query.find({
  success: function(results){
     for (var i = 0; i < results.length; i++) 
     { 
        usernameList += results[i].get('user')+"~";
     }
     response.success(usernameList);
    },
    error: function(error) {
     //error
     console.log("error: " + error);
     response.error(error);
    }
  });
});

您可以将此云函数写入您的 Parse 云,并且您可以从您的 android 应用程序触发此函数.上面的代码将生成以 ~ 分隔的用户名.您可以查看 Parse 教程以深入了解 Cloud 函数以及如何从您的 android 应用程序触发 Cloud 函数.希望这会有所帮助.

You can write this cloud function to your Parse cloud and you can trigger this function from your android application. The above code will produce the users name with ~ separated. You can look the Parse tutorials to dig into Cloud function and how to trigger cloud function from your android application. Hope this helps.

问候.