I have made an app which uses Parse.com push notifications. I have a settings page in which you can enable/disable push notifications. The settings page works well, it changes the preference used, but the push notifications won't stop.

Here is my code in which I subscribe/unsubscribe:

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);
                        }
                    }
                });

            }

If "pushNotificationsPreference" is false, it calls method "ParsePush.unsubscribeInBackground("Android", new SaveCallback()", but it won't subscribe, i am still receiving them.

I went on Parse.com, and i'm only registered at "Android" channel.

Am i missing anything?

Related posts

Recent Viewed