You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.3 KiB

6 years ago
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class GtalkDataMessageStanza;
  18. @class FIRMessagingClient;
  19. @class FIRMessagingConnection;
  20. @class FIRMessagingReceiver;
  21. @class FIRMessagingRmqManager;
  22. @class FIRMessagingSyncMessageManager;
  23. @protocol FIRMessagingDataMessageManagerDelegate <NSObject>
  24. #pragma mark - Downstream Callbacks
  25. /**
  26. * Invoked when FIRMessaging receives a downstream message via the MCS connection.
  27. * Let's the user know that they have received a new message by invoking the
  28. * App's remoteNotification callback.
  29. *
  30. * @param message The downstream message received by the MCS connection.
  31. */
  32. - (void)didReceiveMessage:(nonnull NSDictionary *)message
  33. withIdentifier:(nullable NSString *)messageID;
  34. #pragma mark - Upstream Callbacks
  35. /**
  36. * Notify the app that FIRMessaging will soon be sending the upstream message requested by the app.
  37. *
  38. * @param messageID The messageId passed in by the app to track this particular message.
  39. * @param error The error in case FIRMessaging cannot send the message upstream.
  40. */
  41. - (void)willSendDataMessageWithID:(nonnull NSString *)messageID error:(nullable NSError *)error;
  42. /**
  43. * Notify the app that FIRMessaging did successfully send it's message via the MCS
  44. * connection and the message was successfully delivered.
  45. *
  46. * @param messageId The messageId passed in by the app to track this particular
  47. * message.
  48. */
  49. - (void)didSendDataMessageWithID:(nonnull NSString *)messageId;
  50. #pragma mark - Server Callbacks
  51. /**
  52. * Notify the app that FIRMessaging server deleted some messages which exceeded storage limits. This
  53. * indicates the "deleted_messages" message type we received from the server.
  54. */
  55. - (void)didDeleteMessagesOnServer;
  56. @end
  57. /**
  58. * This manages all of the data messages being sent by the client and also the messages that
  59. * were received from the server.
  60. */
  61. @interface FIRMessagingDataMessageManager : NSObject
  62. NS_ASSUME_NONNULL_BEGIN
  63. - (instancetype)initWithDelegate:(id<FIRMessagingDataMessageManagerDelegate>)delegate
  64. client:(FIRMessagingClient *)client
  65. rmq2Manager:(FIRMessagingRmqManager *)rmq2Manager
  66. syncMessageManager:(FIRMessagingSyncMessageManager *)syncMessageManager;
  67. - (void)setDeviceAuthID:(NSString *)deviceAuthID secretToken:(NSString *)secretToken;
  68. - (void)refreshDelayedMessages;
  69. #pragma mark - Receive
  70. - (NSDictionary *)processPacket:(GtalkDataMessageStanza *)packet;
  71. - (void)didReceiveParsedMessage:(NSDictionary *)message;
  72. #pragma mark - Send
  73. - (void)sendDataMessageStanza:(NSMutableDictionary *)dataMessage;
  74. - (void)didSendDataMessageStanza:(GtalkDataMessageStanza *)message;
  75. - (void)resendMessagesWithConnection:(FIRMessagingConnection *)connection;
  76. NS_ASSUME_NONNULL_END
  77. @end