简体   繁体   English

如何管理来自QuickBlox的推送通知的徽章计数器?

[英]How to manage badge counter for push notification from QuickBlox?

I'm using QuickBlox iOS SDK to have chat functionality into my app. 我正在使用QuickBlox iOS SDK将聊天功能集成到我的应用中。 It works great. 效果很好。 Now there's a requirement from client to manage badge counter for each of the push notifications. 现在,客户要求管理每个推送通知的徽章计数器。

There's some scenarios which may help you to suggest me the flow to handle badge counter: 在某些情况下,可能会帮助您建议我处理徽章计数器的流程:

  1. Currently, a user will get a push when a new 1-1 chat dialog created. 当前,当创建新的1-1聊天对话框时,用户将获得推送。
  2. When the users of dialog will do chat to each other they will get push if they're offline. 当对话框的用户彼此聊天时,如果他们处于脱机状态,他们将得到推动。
  3. If any of the user will delete a dialog then other user will get to know about this. 如果任何用户将删除对话框,则其他用户将对此有所了解。 And may also delete if he wants and that notification will be send to other user as well. 并且,如果他愿意,也可以删除,并且该通知也将发送给其他用户。
  4. If user read particular dialog message then it should decrease 1 from badge. 如果用户阅读了特定的对话框消息,则应从徽章中减少1。
  5. If I send a notification from code then how I can know which number to pass in badge key? 如果我通过代码发送通知,那么我如何知道要在徽章密钥中传递哪个数字?

So in 1st and 3rd cases, push notifications will send from the code it self. 因此,在第一种和第三种情况下,推送通知将从其自身的代码发送。 And 2nd approach will get done by the QuickBlox server for the user who's currently offline. 第二种方法将由QuickBlox服务器为当前离线的用户完成。 How to handle 4th and 5th cases too. 如何处理第四和第五种情况。

Please let me suggest the correct approach to handle badge counting for these cases. 请让我建议针对这些情况处理徽章计数的正确方法。

At the moment in order to know all unread messages number you need to request dialogs 目前,为了知道所有未读消息的数量,您需要请求对话框

+ (QBRequest *)dialogsForPage:(QBResponsePage *)page extendedRequest:(NSDictionary *)extendedRequest
                 successBlock:(void(^)(QBResponse *response, NSArray *dialogObjects, NSSet *dialogsUsersIDs, QBResponsePage *page))successBlock
                   errorBlock:(QBRequestErrorBlock)errorBlock

And for all dialogs count unread_messages_count 对于所有对话框,计数为unread_messages_count

In future releases we are planing to add a method such as 在将来的版本中,我们计划添加一种方法,例如

[QBRequest unreadMessagesCount:successBlock:errorBlock]

Will it be suitable for your purposes? 是否适合您的目的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM