[英]Parse.com : Sending Push notification from device?
I've successfully integrated Parse.com
to android
app & the push notification was worked perfectly when i tried to send the notification from Data browser. 我已成功将
Parse.com
集成到android
应用程序中,并且当我尝试从数据浏览器发送通知时,推送通知工作得非常好。
Now, when i tried to achieve to send the notification from device, it doesn't send anything & there's no log even in the Push notification section in Parse Data browser. 现在,当我尝试实现从设备发送通知时,它不发送任何信息,即使在“解析数据”浏览器的“推送通知”部分中也没有日志。
Also, i've enabled Client Push enabled in setting. 另外,我已经在设置中启用了客户端推送 。
Here's my code : 这是我的代码:
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");
}
});
}
}
In logcat
, i received push notification sent successfully but it doesn't. 在
logcat
,我收到成功发送的推送通知,但没有成功。 Where i'm making the mistake? 我在哪里犯错?
Ok. 好。 I found a solution.
我找到了解决方案。 I think it's best to post in answer section for future searchers to easily find the solution.
我认为最好在答案部分中发布,以供将来的搜索者轻松找到解决方案。
The trick is, i removed this line 诀窍是,我删除了这一行
parsePush.setChannel("Everyone");
and everything works now. 现在一切正常。
Initially, i though everyone
is some special keyword that would send notification to all users since I've seen in a post where a user had this line in order to send broadcast notification to all registered user. 最初,尽管
everyone
都是一个特殊的关键字,但自从我在帖子中看到某个用户拥有此行以便向所有注册用户发送广播通知后,我便会向所有用户发送通知。 But, the above line considers there's a channel everyone
and it goes to only to that users who had subscribed to this channel
(not all users). 但是,上一行认为
everyone
都有一个频道,并且仅涉及订阅该channel
用户(并非所有用户)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.