【问题标题】:Parse.com Receiving push notifications even after Logout -AndroidParse.com 即使在注销后也收到推送通知 -Android
【发布时间】:2016-01-13 05:02:59
【问题描述】:

我制作了一个应用程序,当用户登录到他的帐户时,它使用 Parse 向其他设备发送推送通知。问题是用户即使在退出后仍然会收到推送。 解决这个问题的方法会很棒。 这是我用来注册设备的代码。

public void registerPushNotification() {
    ParseInstallation installation = ParseInstallation.getCurrentInstallation();
    installation.put("user", mCurrentUser);
    installation.saveInBackground();
}

提前致谢!

【问题讨论】:

    标签: android session parse-platform


    【解决方案1】:

    试试这个(代码在 Swift 中,但我认为是一样的)

    PFUser.logOut()
    PFInstallation.currentInstallation().removeObjectForKey("user")
    PFInstallation.currentInstallation().saveInBackground()
    

    【讨论】:

      【解决方案2】:

      尝试在注销时拨打ParseInstallation.getCurrentInstallation().deleteInBackground()

      【讨论】:

      • 不,仍在接收。
      • 我也一样,有什么想法吗??
      • 不允许从客户端删除 _Installation 对象等数据。您应该提供一个 Cloud Code 函数来执行此任务,但是恕我直言,这不是解决此问题的正确方法。
      【解决方案3】:

      我建议使用通道,通过通道可以对推送等进行某种控制。

      方法签名是这样的

      ParsePush.subscribeInBackground("Name of my channel", SaveCallback cb);
      

      当用户登录时尝试使用这个:

      ParsePush.subscribeInBackground("my_channel", new SaveCallback() {
                          @Override
                          public void done(ParseException e) {
                              if (e == null) {
                                  // Great
                              } else {
                                  // Something wrong happened...
                              }
                          }
                      });
      

      当用户退出时使用这个:

      ParsePush.unsubscribeInBackground("my_channel");
      

      为所有(仍然)订阅"my_channel"频道的用户发送推送查询时:

      ParsePush push = new ParsePush();
      push.setChannel("my_channel");
      push.setMessage("Message to the subscribers of the channel!");
      push.sendInBackground();
      

      请务必查看Parse guidedocs。 干杯!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-03-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-30
        • 2014-12-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多