Parse.com推送通知的问题。退订不工作,仍在接受推送通知。(安卓) [英] Parse.com push notifications issue. unsubscribe not working, still receiving push notifications.(Android)
问题描述
我做了一个应用程序,它使用Parse.com推送通知。我有一个设置页面中,您可以启用/禁用推送通知。该设置页面的效果很好,它变化p $ pference使用$,但推送通知将不会停止。
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.
下面是我的code中,我订阅/退订:
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);
}
}
});
}
如果pushNotifications preference是假的,它调用方法ParsePush.unsubscribeInBackground(机器人,新SaveCallback(),但它不会认购,我仍然接受他们。
If "pushNotificationsPreference" is false, it calls method "ParsePush.unsubscribeInBackground("Android", new SaveCallback()", but it won't subscribe, i am still receiving them.
我去Parse.com,我只在Android的渠道注册。
I went on Parse.com, and i'm only registered at "Android" channel.
我缺少什么?
推荐答案
只需添加
if (e == null) {
ParseInstallation.getCurrentInstallation().saveInBackground();
}
到进行()
ParsePush.unsubscribeInBackground的(...)
这篇关于Parse.com推送通知的问题。退订不工作,仍在接受推送通知。(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!