用于android的解析仪表板中的“推送发送0”

我正在尝试从parse发送推送通知到android。 从浏览器发送时,设备的计算正在正确显示。 但是“推送发送0”正在浏览器中显示。

我在Application类中注册通知

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

我还在我的android项目中创建了Receiver

 public class PushMessageBroadcast extends ParsePushBroadcastReceiver { @Override public void onPushOpen(Context context, Intent intent) { Log.d("The push","open"); } @Override protected Notification getNotification(Context context, Intent intent) { // TODO Auto-generated method stub return super.getNotification(context, intent); } @Override protected void onPushDismiss(Context context, Intent intent) { // TODO Auto-generated method stub super.onPushDismiss(context, intent); } @Override protected void onPushReceive(Context context, Intent intent) { //here You can handle push before appearing into status eg if you want to stop it. super.onPushReceive(context, intent); } } 

我还完成了清单中的更改:

        

我是否需要更改解析中的任何设置? 提前致谢。

编辑回答

在@ lochana-tejas发表评论后,我意识到我的答案不正确,因为我在Google Developer Console“Cloud Messaging for Android”中再次禁用了该设备,我的设备仍然收到了通知。

所以你需要控制的第一件事是在Parse Dashboard中你有类Installation ,这个类有一个或多个注册的设备。 如果您没有此类或为空,则“推送已发送”将为0。

在此处输入图像描述

我在这里复制我的代码,以便您进行比较

  public static void registerParse(Context context) { Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE); Parse.initialize(context, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY); ParseInstallation.getCurrentInstallation().saveInBackground(); ParsePush.subscribeInBackground(PARSE_CHANNEL, new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { Log.d("com.parse.push", "Successfully subscribed to Parse!"); } else { Log.e("com.parse.push", "failed to subscribe for push", e); } } }); } //This is the user that will be inserted in "Installation class" public static void subscribeWithUser(String user) { ParseInstallation installation = ParseInstallation.getCurrentInstallation(); installation.put("user", user); installation.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { Log.e("subscribeWithUser", "User subscribed successfully!!", e); } else { e.printStackTrace(); Log.e("subscribeWithUser", "Error to save user", e); } } }); } 

我的表现就是这个