Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.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
Parse.com推送通知问题。取消订阅不起作用,仍接收推送通知。(Android)_Android_Notifications_Parse Platform - Fatal编程技术网

Parse.com推送通知问题。取消订阅不起作用,仍接收推送通知。(Android)

Parse.com推送通知问题。取消订阅不起作用,仍接收推送通知。(Android),android,notifications,parse-platform,Android,Notifications,Parse Platform,我制作了一个使用Parse.com推送通知的应用程序。我有一个设置页面,您可以在其中启用/禁用推送通知。设置页面工作正常,它更改了使用的首选项,但推送通知不会停止 以下是我订阅/取消订阅的代码: SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); pushNotificationsPreference = sharedPrefs.getBoolean("P

我制作了一个使用Parse.com推送通知的应用程序。我有一个设置页面,您可以在其中启用/禁用推送通知。设置页面工作正常,它更改了使用的首选项,但推送通知不会停止

以下是我订阅/取消订阅的代码:

SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
            pushNotificationsPreference = sharedPrefs.getBoolean("PUSH_NOTIFICATION_PREFERENCE", true);

            if (pushNotificationsPreference) {
                ParsePush.subscribeInBackground("Android", new SaveCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e != null) {
                            Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
                        } else {
                            Log.e("com.parse.push", "failed to subscribe for push" + e);
                        }
                    }
                });
            } else {
                ParsePush.unsubscribeInBackground("Android", new SaveCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e != null) {
                            Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
                        } else {
                            Log.e("com.parse.push", "failed to unsubscribe for push" + e);
                        }
                    }
                });

            }
如果“PushNotificationsReference”为false,它将调用方法“ParsePush.unsubscribeInBackground”(“Android”,new SaveCallback()”),但它不会订阅,我仍在接收它们

我上了Parse.com,我只在“安卓”频道注册

我遗漏了什么吗?

只需添加

if (e == null) {
    ParseInstallation.getCurrentInstallation().saveInBackground();
}

进入
ParsePush的
done()
中。取消订阅背景(…)

它是否成功取消订阅(在日志中)?还指出,您的IF条件设置为相反。IF(e==null)这意味着没有错误,相反,您的偏好很可能不存在,默认值为“true”。