android - com.parse.ParseException : Clients aren't allowed to perform the find operation on the installation collection

标签 android parse-platform

我是解析新手,我能够将数据存储到数据库中,但是每当我尝试从数据库中检索一些信息(例如对象 ID)时,我通常会收到上述错误。我用来检索对象的查询-与给定的 Friend-id 对应的 id。

ParseQuery<ParseObject> query = ParseQuery.getQuery("_Installation");
		query.whereEqualTo("FriendId", FrndTextString);
		
		query.findInBackground(new FindCallback<ParseObject>() {
			public void done(List<ParseObject> results, ParseException e) {
				if (e == null) {
					
					for (ParseObject x : results) {
						String Objectid = x.getString("objectId");
						
						objectidEditText.setText(Objectid);
					}
				} else {
					Toast.makeText(getApplicationContext(),
							"Error in retreving Data", Toast.LENGTH_LONG)
							.show();
				}
			}
		});

请帮助我解决这个问题,因为我用谷歌搜索了很多,但没有找到任何好的解决方案。任何帮助将不胜感激。

谢谢。

最佳答案

_Installation 类是 Parse 的内部类。发生异常的原因是您尝试访问受特定用户使用特定 ParseACL 保护的数据。

来自 Parse 的文档:

Every Parse application installed on a device registered for push notifications has an associated Installation object. The Installation object is where you store all the data needed to target push notifications. For example, in a baseball app, you could store the teams a user is interested in to send updates about their performance. Saving the Installation object is also required for tracking push-related app open events.

In Android, Installation objects are available through the ParseInstallation class, a subclass of ParseObject. It uses the same API for storing and retrieving data. To access the current Installation object from your Android app, use the ParseInstallation.getCurrentInstallation() method. The first time you save a ParseInstallation, Parse will add it to your Installation class and it will be available for targeting push notifications.

尝试使用其他类,例如“Ranking”。例如:

ParseQuery<ParseObject> query = ParseQuery.getQuery("Ranking");
query.whereEqualTo("FriendId", FrndTextString);

query.findInBackground(new FindCallback<ParseObject>() {
    public void done(List<ParseObject> results, ParseException e) {
        if (e == null) {
            
            for (ParseObject x : results) {
                String Objectid = x.getString("objectId");
                
                objectidEditText.setText(Objectid);
            }
        } else {
            Toast.makeText(getApplicationContext(),
                    "Error in retreving Data", Toast.LENGTH_LONG)
                    .show();
        }
    }
});

如果你想查找其他用户的公共(public)信息,你必须注意为每个用户和类别正确设置ParseACL。至少,所有用户都必须“公开读取”您想要的数据。

在 Parse 中保存任何数据之前,您必须设置环境 with this tutorial 。之后,您必须创建 ParseUser 并使用它登录。 Parse 有一种自动创建用户的方法,只需调用:

ParseUser.enableAutomaticUser();
ParseUser.getCurrentUser().increment("RunCount");
ParseUser.getCurrentUser().saveInBackground();

要在 Parse 中保存任何数据,您可以使用:

ParseObject gameScore = new ParseObject("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.saveInBackground();

如果新类“GameScore”不存在,Parse Server 将自动创建。并会创建所有列,如“score”、“playerNAme”和“cheatMode”(如果不存在)。

要使用 Parse,请read API Doc ,太有帮助了。

关于android - com.parse.ParseException : Clients aren't allowed to perform the find operation on the installation collection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29628530/

相关文章:

android - 为什么 PlusClient.loadPeople 会因 HTTP 403 错误而失败?

java - 使用 Zxing 库进行串行扫描 - android

swift - Parse.com 错误 : invalid type for key '' , 需要数组,但得到字符串(代码 : 111, 版本 : 1. 8.3)

javascript - 云代码功能不保存数据

Android 在 Activity 中调用异步任务

android - genymotion power_supply 出错

android - 正确地将 fragment 插入和删除到 viewpager

iOS 解析 GeoPoints 和 MapBox 形状

rest - 如何使用 REST API 通过指针查询对象?

ios - 使用 Swift 在 Parse 中覆盖 UITableView