added iOS source code
[wl-app.git] / iOS / Pods / FirebaseMessaging / Firebase / Messaging / FIRMessagingDataMessageManager.h
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
17 #import <Foundation/Foundation.h>
18
19 @class GtalkDataMessageStanza;
20
21 @class FIRMessagingClient;
22 @class FIRMessagingConnection;
23 @class FIRMessagingReceiver;
24 @class FIRMessagingRmqManager;
25 @class FIRMessagingSyncMessageManager;
26
27 @protocol FIRMessagingDataMessageManagerDelegate <NSObject>
28
29 #pragma mark - Downstream Callbacks
30
31 /**
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.
35  *
36  *  @param message The downstream message received by the MCS connection.
37  */
38 - (void)didReceiveMessage:(nonnull NSDictionary *)message
39            withIdentifier:(nullable NSString *)messageID;
40
41 #pragma mark - Upstream Callbacks
42
43 /**
44  *  Notify the app that FIRMessaging will soon be sending the upstream message requested by the app.
45  *
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.
48  */
49 - (void)willSendDataMessageWithID:(nullable NSString *)messageID error:(nullable NSError *)error;
50
51 /**
52  *  Notify the app that FIRMessaging did successfully send it's message via the MCS
53  *  connection and the message was successfully delivered.
54  *
55  *  @param messageId The messageId passed in by the app to track this particular
56  *                   message.
57  */
58 - (void)didSendDataMessageWithID:(nonnull NSString *)messageId;
59
60 #pragma mark - Server Callbacks
61
62 /**
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.
65  */
66 - (void)didDeleteMessagesOnServer;
67
68 @end
69
70 /**
71  * This manages all of the data messages being sent by the client and also the messages that
72  * were received from the server.
73  */
74 @interface FIRMessagingDataMessageManager : NSObject
75
76 NS_ASSUME_NONNULL_BEGIN
77
78 - (instancetype)initWithDelegate:(id<FIRMessagingDataMessageManagerDelegate>)delegate
79                           client:(FIRMessagingClient *)client
80                      rmq2Manager:(FIRMessagingRmqManager *)rmq2Manager
81               syncMessageManager:(FIRMessagingSyncMessageManager *)syncMessageManager;
82
83 - (void)setDeviceAuthID:(NSString *)deviceAuthID secretToken:(NSString *)secretToken;
84
85 - (void)refreshDelayedMessages;
86
87 #pragma mark - Receive
88
89 - (nullable NSDictionary *)processPacket:(GtalkDataMessageStanza *)packet;
90 - (void)didReceiveParsedMessage:(NSDictionary *)message;
91
92 #pragma mark - Send
93
94 - (void)sendDataMessageStanza:(NSMutableDictionary *)dataMessage;
95 - (void)didSendDataMessageStanza:(GtalkDataMessageStanza *)message;
96
97 - (void)resendMessagesWithConnection:(FIRMessagingConnection *)connection;
98
99 NS_ASSUME_NONNULL_END
100
101 @end