2 * Copyright 2017 Google
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #import <Foundation/Foundation.h>
19 @class GtalkDataMessageStanza;
21 @class FIRMessagingClient;
22 @class FIRMessagingConnection;
23 @class FIRMessagingReceiver;
24 @class FIRMessagingRmqManager;
25 @class FIRMessagingSyncMessageManager;
27 @protocol FIRMessagingDataMessageManagerDelegate <NSObject>
29 #pragma mark - Downstream Callbacks
32 * Invoked when FIRMessaging receives a downstream message via the MCS connection.
33 * Let's the user know that they have received a new message by invoking the
34 * App's remoteNotification callback.
36 * @param message The downstream message received by the MCS connection.
38 - (void)didReceiveMessage:(nonnull NSDictionary *)message
39 withIdentifier:(nullable NSString *)messageID;
41 #pragma mark - Upstream Callbacks
44 * Notify the app that FIRMessaging will soon be sending the upstream message requested by the app.
46 * @param messageID The messageId passed in by the app to track this particular message.
47 * @param error The error in case FIRMessaging cannot send the message upstream.
49 - (void)willSendDataMessageWithID:(nullable NSString *)messageID error:(nullable NSError *)error;
52 * Notify the app that FIRMessaging did successfully send it's message via the MCS
53 * connection and the message was successfully delivered.
55 * @param messageId The messageId passed in by the app to track this particular
58 - (void)didSendDataMessageWithID:(nonnull NSString *)messageId;
60 #pragma mark - Server Callbacks
63 * Notify the app that FIRMessaging server deleted some messages which exceeded storage limits. This
64 * indicates the "deleted_messages" message type we received from the server.
66 - (void)didDeleteMessagesOnServer;
71 * This manages all of the data messages being sent by the client and also the messages that
72 * were received from the server.
74 @interface FIRMessagingDataMessageManager : NSObject
76 NS_ASSUME_NONNULL_BEGIN
78 - (instancetype)initWithDelegate:(id<FIRMessagingDataMessageManagerDelegate>)delegate
79 client:(FIRMessagingClient *)client
80 rmq2Manager:(FIRMessagingRmqManager *)rmq2Manager
81 syncMessageManager:(FIRMessagingSyncMessageManager *)syncMessageManager;
83 - (void)setDeviceAuthID:(NSString *)deviceAuthID secretToken:(NSString *)secretToken;
85 - (void)refreshDelayedMessages;
87 #pragma mark - Receive
89 - (nullable NSDictionary *)processPacket:(GtalkDataMessageStanza *)packet;
90 - (void)didReceiveParsedMessage:(NSDictionary *)message;
94 - (void)sendDataMessageStanza:(NSMutableDictionary *)dataMessage;
95 - (void)didSendDataMessageStanza:(GtalkDataMessageStanza *)message;
97 - (void)resendMessagesWithConnection:(FIRMessagingConnection *)connection;