Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解析Android:订阅/取消订阅与在线服务不一致_Android_Parse Platform - Fatal编程技术网

解析Android:订阅/取消订阅与在线服务不一致

解析Android:订阅/取消订阅与在线服务不一致,android,parse-platform,Android,Parse Platform,我们正在为android客户端使用解析,但缓存有问题 每个设备都有其注册的唯一通道。如果我上网删除数据浏览器中的频道,设备仍然认为它已经注册了。如果我调用subscribe for the channel,似乎没有进行此调用,我猜它会检查本地缓存,因为这表示它已经注册,所以它将进行此调用 如果我调用这个方法PushService.getSubscriptions,它会给我一个与在线内容不一致的频道列表。某个地方说PushService.getSubscriptions缓存在本地,这真的很奇怪吗

我们正在为android客户端使用解析,但缓存有问题

每个设备都有其注册的唯一通道。如果我上网删除数据浏览器中的频道,设备仍然认为它已经注册了。如果我调用subscribe for the channel,似乎没有进行此调用,我猜它会检查本地缓存,因为这表示它已经注册,所以它将进行此调用

如果我调用这个方法PushService.getSubscriptions,它会给我一个与在线内容不一致的频道列表。某个地方说PushService.getSubscriptions缓存在本地,这真的很奇怪吗

因此,我尝试这样做,以确保其始终更新到最新版本:

    PushService.setDefaultPushCallback(this, null);
    Set<String> channels = PushService.getSubscriptions(_context);
    for(String channel : channels){
        PushService.unsubscribe(this, channel);
    }
    PushService.setDefaultPushCallback(this, RD4MainV4Activity.class);
    PushService.subscribe(this, licenseKeyValue, RD4MainV4Activity.class);
我的梦想senario将是我可以获得该设备的在线版本。然后检查它是否正确,如果通道丢失或设备注册了错误的通道,则修复此问题


我能以任何方式检查一下吗?

我遇到过类似的问题,但通过一点技巧就解决了

对于当前版本的Parse(本文撰写时为1.9.2),订阅频道的方式是使用ParsePush.subscribeInBackground(channelname)。此方法自动将字符串“channelname”添加到用户安装对象中名为“channels”的字符串数组中,但无论如何,对我来说,抛出了上面给出的相同错误:

java.lang.RuntimeException: java.lang.IllegalArgumentException: Operation is invalid after previous operation.
我解决这个问题的方法是编写我自己版本的subscribeInBackground,它类似于:

ParseInstallation.getCurrentInstallation().put("channels",
                Arrays.asList(new String[]{
                        "channelname"
                }));
ParseInstallation.getCurrentInstallation().saveInBackground();
要取消订阅,只需执行反向操作:

ParseInstallation.getCurrentInstallation().put("channels",
                Arrays.asList(new String[]{})); //Put the empty list to unsubcribe!
        ParseInstallation.getCurrentInstallation().saveInBackground();

这依赖于您来管理通道阵列,但不会莫名其妙地崩溃。

我现在已经尝试了很多方法,比如ParseInstallation.getCurrentInstallation().refresh();和ParseInstallation.getCurrentInstallation().fetch();我可以看到他们下载了列表,但他们没有删除错误的频道。“取消注册”也只是删除联机的内容。所以,如果我的本地列表中有更多的人,但他们不在线,那么它可以工作,但如果他们在线,则无法删除他们。你设法解决了这个问题吗?我也有类似的问题。。。
ParseInstallation.getCurrentInstallation().put("channels",
                Arrays.asList(new String[]{})); //Put the empty list to unsubcribe!
        ParseInstallation.getCurrentInstallation().saveInBackground();