[英]Parse.com push notifications issue. unsubscribe not working, still receiving push notifications.(Android)
I have made an app which uses Parse.com push notifications. 我创建了一个使用Parse.com推送通知的应用程序。 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. 如果“pushNotificationsPreference”为false,则调用方法“ParsePush.unsubscribeInBackground(”Android“,new SaveCallback()”,但它不会订阅,我仍然会收到它们。
I went on Parse.com, and i'm only registered at "Android" channel. 我去了Parse.com,我只在“Android”频道注册。
Am i missing anything? 我错过了什么吗?
Just add 只需添加
if (e == null) {
ParseInstallation.getCurrentInstallation().saveInBackground();
}
into done()
of ParsePush.unsubscribeInBackground(...)
成done()
的ParsePush.unsubscribeInBackground(...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.