Parse.com:正在从设备发送推送通知?
Parse.com : Sending Push notification from device?
我已成功将 Parse.com
集成到 android
应用程序,当我尝试从数据浏览器发送通知时,推送通知工作正常。
现在,当我尝试实现从设备发送通知时,它没有发送任何内容,甚至在 Parse Data 浏览器的推送通知部分也没有日志。
此外,我在设置中启用了启用客户端推送。
这是我的代码:
public class ParseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ParseCrashReporting.enable(this);
Parse.enableLocalDatastore(this);
Parse.initialize(this, "xxx", "xxx");
ParsePush.subscribeInBackground("",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);
}
}
});
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush parsePush = new ParsePush();
parsePush.setChannel("Everyone");
parsePush.setMessage("Helloooooo :)");
parsePush.sendInBackground(new SendCallback() {
@Override
public void done(ParseException e) {
Log.d("parse push","Parse push sent");
}
});
}
}
在logcat
,我收到了成功发送的推送通知,但没有收到。我在哪里犯了错误?
好的。我找到了解决办法。我认为最好在答案部分 post 以便将来的搜索者轻松找到解决方案。
诀窍是,我删除了这一行
parsePush.setChannel("Everyone");
现在一切正常。
最初,我虽然 everyone
是一些特殊的关键字,它会向所有用户发送通知,因为我在 post 中看到用户有这条线以便向所有用户发送广播通知所有注册用户。但是,上面的行认为有一个频道 everyone
并且它只适用于订阅此 channel
的用户(不是所有用户)。
我已成功将 Parse.com
集成到 android
应用程序,当我尝试从数据浏览器发送通知时,推送通知工作正常。
现在,当我尝试实现从设备发送通知时,它没有发送任何内容,甚至在 Parse Data 浏览器的推送通知部分也没有日志。
此外,我在设置中启用了启用客户端推送。
这是我的代码:
public class ParseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ParseCrashReporting.enable(this);
Parse.enableLocalDatastore(this);
Parse.initialize(this, "xxx", "xxx");
ParsePush.subscribeInBackground("",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);
}
}
});
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush parsePush = new ParsePush();
parsePush.setChannel("Everyone");
parsePush.setMessage("Helloooooo :)");
parsePush.sendInBackground(new SendCallback() {
@Override
public void done(ParseException e) {
Log.d("parse push","Parse push sent");
}
});
}
}
在logcat
,我收到了成功发送的推送通知,但没有收到。我在哪里犯了错误?
好的。我找到了解决办法。我认为最好在答案部分 post 以便将来的搜索者轻松找到解决方案。
诀窍是,我删除了这一行
parsePush.setChannel("Everyone");
现在一切正常。
最初,我虽然 everyone
是一些特殊的关键字,它会向所有用户发送通知,因为我在 post 中看到用户有这条线以便向所有用户发送广播通知所有注册用户。但是,上面的行认为有一个频道 everyone
并且它只适用于订阅此 channel
的用户(不是所有用户)。