FIRMessaging.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * @related FIRMessaging
  20. *
  21. * The completion handler invoked when the registration token returns.
  22. * If the call fails we return the appropriate `error code`, described by
  23. * `FIRMessagingError`.
  24. *
  25. * @param FCMToken The valid registration token returned by FCM.
  26. * @param error The error describing why a token request failed. The error code
  27. * will match a value from the FIRMessagingError enumeration.
  28. */
  29. typedef void (^FIRMessagingFCMTokenFetchCompletion)(NSString *_Nullable FCMToken,
  30. NSError *_Nullable error)
  31. NS_SWIFT_NAME(MessagingFCMTokenFetchCompletion);
  32. /**
  33. * @related FIRMessaging
  34. *
  35. * The completion handler invoked when the registration token deletion request is
  36. * completed. If the call fails we return the appropriate `error code`, described
  37. * by `FIRMessagingError`.
  38. *
  39. * @param error The error describing why a token deletion failed. The error code
  40. * will match a value from the FIRMessagingError enumeration.
  41. */
  42. typedef void (^FIRMessagingDeleteFCMTokenCompletion)(NSError *_Nullable error)
  43. NS_SWIFT_NAME(MessagingDeleteFCMTokenCompletion);
  44. /**
  45. * Callback to invoke once the HTTP call to FIRMessaging backend for updating
  46. * subscription finishes.
  47. *
  48. * @param error The error which occurred while updating the subscription topic
  49. * on the FIRMessaging server. This will be nil in case the operation
  50. * was successful, or if the operation was cancelled.
  51. */
  52. typedef void (^FIRMessagingTopicOperationCompletion)(NSError *_Nullable error);
  53. #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
  54. /**
  55. * Notification sent when the upstream message has been delivered
  56. * successfully to the server. The notification object will be the messageID
  57. * of the successfully delivered message.
  58. */
  59. FOUNDATION_EXPORT const NSNotificationName FIRMessagingSendSuccessNotification
  60. NS_SWIFT_NAME(MessagingSendSuccess) DEPRECATED_ATTRIBUTE;
  61. /**
  62. * Notification sent when the upstream message was failed to be sent to the
  63. * server. The notification object will be the messageID of the failed
  64. * message. The userInfo dictionary will contain the relevant error
  65. * information for the failure.
  66. */
  67. FOUNDATION_EXPORT const NSNotificationName FIRMessagingSendErrorNotification
  68. NS_SWIFT_NAME(MessagingSendError) DEPRECATED_ATTRIBUTE;
  69. /**
  70. * Notification sent when the Firebase messaging server deletes pending
  71. * messages due to exceeded storage limits. This may occur, for example, when
  72. * the device cannot be reached for an extended period of time.
  73. *
  74. * It is recommended to retrieve any missing messages directly from the
  75. * server.
  76. */
  77. FOUNDATION_EXPORT const NSNotificationName FIRMessagingMessagesDeletedNotification
  78. NS_SWIFT_NAME(MessagingMessagesDeleted) DEPRECATED_ATTRIBUTE;
  79. /**
  80. * Notification sent when Firebase Messaging establishes or disconnects from
  81. * an FCM socket connection. You can query the connection state in this
  82. * notification by checking the `isDirectChannelEstablished` property of FIRMessaging.
  83. */
  84. FOUNDATION_EXPORT const NSNotificationName FIRMessagingConnectionStateChangedNotification
  85. NS_SWIFT_NAME(MessagingConnectionStateChanged) DEPRECATED_ATTRIBUTE;
  86. /**
  87. * Notification sent when the FCM registration token has been refreshed. Please use the
  88. * FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and
  89. * updated tokens.
  90. */
  91. FOUNDATION_EXPORT const NSNotificationName FIRMessagingRegistrationTokenRefreshedNotification
  92. NS_SWIFT_NAME(MessagingRegistrationTokenRefreshed);
  93. #else
  94. /**
  95. * Notification sent when the upstream message has been delivered
  96. * successfully to the server. The notification object will be the messageID
  97. * of the successfully delivered message.
  98. */
  99. FOUNDATION_EXPORT NSString *const FIRMessagingSendSuccessNotification
  100. NS_SWIFT_NAME(MessagingSendSuccessNotification) DEPRECATED_ATTRIBUTE;
  101. /**
  102. * Notification sent when the upstream message was failed to be sent to the
  103. * server. The notification object will be the messageID of the failed
  104. * message. The userInfo dictionary will contain the relevant error
  105. * information for the failure.
  106. */
  107. FOUNDATION_EXPORT NSString *const FIRMessagingSendErrorNotification
  108. NS_SWIFT_NAME(MessagingSendErrorNotification) DEPRECATED_ATTRIBUTE;
  109. /**
  110. * Notification sent when the Firebase messaging server deletes pending
  111. * messages due to exceeded storage limits. This may occur, for example, when
  112. * the device cannot be reached for an extended period of time.
  113. *
  114. * It is recommended to retrieve any missing messages directly from the
  115. * server.
  116. */
  117. FOUNDATION_EXPORT NSString *const FIRMessagingMessagesDeletedNotification
  118. NS_SWIFT_NAME(MessagingMessagesDeletedNotification) DEPRECATED_ATTRIBUTE;
  119. /**
  120. * Notification sent when Firebase Messaging establishes or disconnects from
  121. * an FCM socket connection. You can query the connection state in this
  122. * notification by checking the `isDirectChannelEstablished` property of FIRMessaging.
  123. */
  124. FOUNDATION_EXPORT NSString *const FIRMessagingConnectionStateChangedNotification
  125. NS_SWIFT_NAME(MessagingConnectionStateChangedNotification) DEPRECATED_ATTRIBUTE;
  126. /**
  127. * Notification sent when the FCM registration token has been refreshed. Please use the
  128. * FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and
  129. * updated tokens.
  130. */
  131. FOUNDATION_EXPORT NSString *const FIRMessagingRegistrationTokenRefreshedNotification
  132. NS_SWIFT_NAME(MessagingRegistrationTokenRefreshedNotification);
  133. #endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
  134. /**
  135. * @enum FIRMessagingError
  136. */
  137. typedef NS_ENUM(NSUInteger, FIRMessagingError) {
  138. /// Unknown error.
  139. FIRMessagingErrorUnknown = 0,
  140. /// FIRMessaging couldn't validate request from this client.
  141. FIRMessagingErrorAuthentication = 1,
  142. /// InstanceID service cannot be accessed.
  143. FIRMessagingErrorNoAccess = 2,
  144. /// Request to InstanceID backend timed out.
  145. FIRMessagingErrorTimeout = 3,
  146. /// No network available to reach the servers.
  147. FIRMessagingErrorNetwork = 4,
  148. /// Another similar operation in progress, bailing this one.
  149. FIRMessagingErrorOperationInProgress = 5,
  150. /// Some parameters of the request were invalid.
  151. FIRMessagingErrorInvalidRequest = 7,
  152. /// Topic name is invalid for subscription/unsubscription.
  153. FIRMessagingErrorInvalidTopicName = 8,
  154. } NS_SWIFT_NAME(MessagingError);
  155. /// Status for the downstream message received by the app.
  156. typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) {
  157. /// Unknown status.
  158. FIRMessagingMessageStatusUnknown,
  159. /// New downstream message received by the app.
  160. FIRMessagingMessageStatusNew,
  161. } NS_SWIFT_NAME(MessagingMessageStatus);
  162. /**
  163. * The APNs token type for the app. If the token type is set to `UNKNOWN`
  164. * Firebase Messaging will implicitly try to figure out what the actual token type
  165. * is from the provisioning profile.
  166. * Unless you really need to specify the type, you should use the `APNSToken`
  167. * property instead.
  168. */
  169. typedef NS_ENUM(NSInteger, FIRMessagingAPNSTokenType) {
  170. /// Unknown token type.
  171. FIRMessagingAPNSTokenTypeUnknown,
  172. /// Sandbox token type.
  173. FIRMessagingAPNSTokenTypeSandbox,
  174. /// Production token type.
  175. FIRMessagingAPNSTokenTypeProd,
  176. } NS_SWIFT_NAME(MessagingAPNSTokenType);
  177. /// Information about a downstream message received by the app.
  178. NS_SWIFT_NAME(MessagingMessageInfo)
  179. @interface FIRMessagingMessageInfo : NSObject
  180. /// The status of the downstream message
  181. @property(nonatomic, readonly, assign) FIRMessagingMessageStatus status;
  182. @end
  183. /**
  184. * A remote data message received by the app via FCM (not just the APNs interface).
  185. *
  186. * This is only for devices running iOS 10 or above. To support devices running iOS 9 or below, use
  187. * the local and remote notifications handlers defined in UIApplicationDelegate protocol.
  188. */
  189. NS_SWIFT_NAME(MessagingRemoteMessage)
  190. __deprecated_msg(
  191. "FCM direct channel is deprecated, please use APNs for downstream message handling.")
  192. @interface FIRMessagingRemoteMessage : NSObject
  193. /// The message ID of downstream message.
  194. @property(nonatomic, readonly, copy) NSString *messageID DEPRECATED_ATTRIBUTE;
  195. /// The downstream message received by the application.
  196. @property(nonatomic, readonly, strong) NSDictionary *appData DEPRECATED_ATTRIBUTE;
  197. @end
  198. @class FIRMessaging;
  199. @class FIRMessagingExtensionHelper;
  200. /**
  201. * A protocol to handle token update or data message delivery from FCM.
  202. *
  203. */
  204. NS_SWIFT_NAME(MessagingDelegate)
  205. @protocol FIRMessagingDelegate <NSObject>
  206. @optional
  207. /// This method will be called once a token is available, or has been refreshed. Typically it
  208. /// will be called once per app start, but may be called more often, if token is invalidated or
  209. /// updated. In this method, you should perform operations such as:
  210. ///
  211. /// * Uploading the FCM token to your application server, so targeted notifications can be sent.
  212. ///
  213. /// * Subscribing to any topics.
  214. - (void)messaging:(FIRMessaging *)messaging
  215. didReceiveRegistrationToken:(NSString *)fcmToken
  216. NS_SWIFT_NAME(messaging(_:didReceiveRegistrationToken:));
  217. /// Handle data messages received via FCM direct channel (not via APNs).
  218. - (void)messaging:(FIRMessaging *)messaging
  219. didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage
  220. NS_SWIFT_NAME(messaging(_:didReceive:))__deprecated_msg(
  221. "FCM direct channel is deprecated, please use APNs for downstream message handling.");
  222. @end
  223. /**
  224. * Firebase Messaging lets you reliably deliver messages at no cost.
  225. *
  226. * To send or receive messages, the app must get a
  227. * registration token from FIRInstanceID. This token authorizes an
  228. * app server to send messages to an app instance.
  229. *
  230. * In order to receive FIRMessaging messages, declare
  231. * `application:didReceiveRemoteNotification::fetchCompletionHandler:`.
  232. */
  233. NS_SWIFT_NAME(Messaging)
  234. @interface FIRMessaging : NSObject
  235. /**
  236. * Delegate to handle FCM token refreshes, and remote data messages received via FCM direct channel.
  237. */
  238. @property(nonatomic, weak, nullable) id<FIRMessagingDelegate> delegate;
  239. /**
  240. * When set to `YES`, Firebase Messaging will automatically establish a socket-based, direct
  241. * channel to the FCM server. Enable this only if you are sending upstream messages or
  242. * receiving non-APNs, data-only messages in foregrounded apps.
  243. * Default is `NO`.
  244. */
  245. @property(nonatomic) BOOL shouldEstablishDirectChannel DEPRECATED_MSG_ATTRIBUTE(
  246. "FCM direct channel is deprecated, please use APNs channel for downstream message delivery.");
  247. /**
  248. * Returns `YES` if the direct channel to the FCM server is active, and `NO` otherwise.
  249. */
  250. @property(nonatomic, readonly) BOOL isDirectChannelEstablished DEPRECATED_MSG_ATTRIBUTE(
  251. "FCM direct channel is deprecated, please use APNs channel for downstream message delivery.");
  252. /**
  253. * FIRMessaging
  254. *
  255. * @return An instance of FIRMessaging.
  256. */
  257. + (instancetype)messaging NS_SWIFT_NAME(messaging());
  258. /**
  259. * FIRMessagingExtensionHelper
  260. *
  261. * Use FIRMessagingExtensionHelper to populate rich UI contents for your notifications.
  262. * e.g. If an image URL is set in your notification payload or on the console, call
  263. * FIRMessagingExtensionHelper API to render it on your notification.
  264. *
  265. * @return An instance of FIRMessagingExtensionHelper that handles the extensions API.
  266. */
  267. + (FIRMessagingExtensionHelper *)extensionHelper NS_SWIFT_NAME(serviceExtension())
  268. NS_AVAILABLE(10.14, 10.0);
  269. /**
  270. * Unavailable. Use +messaging instead.
  271. */
  272. - (instancetype)init __attribute__((unavailable("Use +messaging instead.")));
  273. #pragma mark - APNs
  274. /**
  275. * This property is used to set the APNs Token received by the application delegate.
  276. *
  277. * FIRMessaging uses method swizzling to ensure that the APNs token is set
  278. * automatically. However, if you have disabled swizzling by setting
  279. * `FirebaseAppDelegateProxyEnabled` to `NO` in your app's
  280. * Info.plist, you should manually set the APNs token in your application
  281. * delegate's `-application:didRegisterForRemoteNotificationsWithDeviceToken:`
  282. * method.
  283. *
  284. * If you would like to set the type of the APNs token, rather than relying on
  285. * automatic detection, see: `-setAPNSToken:type:`.
  286. */
  287. @property(nonatomic, copy, nullable) NSData *APNSToken NS_SWIFT_NAME(apnsToken);
  288. /**
  289. * Set APNs token for the application. This APNs token will be used to register
  290. * with Firebase Messaging using `FCMToken` or
  291. * `tokenWithAuthorizedEntity:scope:options:handler`.
  292. *
  293. * @param apnsToken The APNs token for the application.
  294. * @param type The type of APNs token. Debug builds should use
  295. * FIRMessagingAPNSTokenTypeSandbox. Alternatively, you can supply
  296. * FIRMessagingAPNSTokenTypeUnknown to have the type automatically
  297. * detected based on your provisioning profile.
  298. */
  299. - (void)setAPNSToken:(NSData *)apnsToken type:(FIRMessagingAPNSTokenType)type;
  300. #pragma mark - FCM Tokens
  301. /**
  302. * Is Firebase Messaging token auto generation enabled? If this flag is disabled, Firebase
  303. * Messaging will not generate token automatically for message delivery.
  304. *
  305. * If this flag is disabled, Firebase Messaging does not generate new tokens automatically for
  306. * message delivery. If this flag is enabled, FCM generates a registration token on application
  307. * start when there is no existing valid token and periodically refreshes the token and sends
  308. * data to Firebase backend.
  309. *
  310. * This setting is persisted, and is applied on future invocations of your application. Once
  311. * explicitly set, it overrides any settings in your Info.plist.
  312. *
  313. * By default, FCM automatic initialization is enabled. If you need to change the
  314. * default (for example, because you want to prompt the user before getting token)
  315. * set FirebaseMessagingAutoInitEnabled to false in your application's Info.plist.
  316. */
  317. @property(nonatomic, assign, getter=isAutoInitEnabled) BOOL autoInitEnabled;
  318. /**
  319. * The FCM registration token is used to identify this device so that FCM can send notifications to
  320. * it. It is associated with your APNs token when the APNs token is supplied, so messages sent to
  321. * the FCM token will be delivered over APNs.
  322. *
  323. * The FCM registration token is sometimes refreshed automatically. In your FIRMessaging delegate,
  324. * the delegate method `messaging:didReceiveRegistrationToken:` will be called once a token is
  325. * available, or has been refreshed. Typically it should be called once per app start, but
  326. * may be called more often if the token is invalidated or updated.
  327. *
  328. * Once you have an FCM registration token, you should send it to your application server, so it can
  329. * use the FCM token to send notifications to your device.
  330. */
  331. @property(nonatomic, readonly, nullable) NSString *FCMToken NS_SWIFT_NAME(fcmToken);
  332. /**
  333. * Asynchronously gets the default FCM registration token.
  334. *
  335. * This creates a Firebase Installations ID, if one does not exist, and sends information about the
  336. * application and the device to the Firebase backend. A network connection is required for the
  337. * method to succeed. To stop this, see `Messaging.isAutoInitEnabled`,
  338. * `Messaging.delete(completion:)` and `Installations.delete(completion:)`.
  339. *
  340. * @param completion The completion handler to handle the token request.
  341. */
  342. - (void)tokenWithCompletion:(void (^)(NSString *__nullable token,
  343. NSError *__nullable error))completion;
  344. /**
  345. * Asynchronously deletes the default FCM registration token.
  346. *
  347. * This does not delete all tokens for non-default sender IDs, See `Messaging.delete(completion:)`
  348. * for deleting all of them. To prevent token auto generation, see `Messaging.isAutoInitEnabled`.
  349. *
  350. * @param completion The completion handler to handle the token deletion.
  351. */
  352. - (void)deleteTokenWithCompletion:(void (^)(NSError *__nullable error))completion;
  353. /**
  354. * Retrieves an FCM registration token for a particular Sender ID. This can be used to allow
  355. * multiple senders to send notifications to the same device. By providing a different Sender
  356. * ID than your default when fetching a token, you can create a new FCM token which you can
  357. * give to a different sender. Both tokens will deliver notifications to your device, and you
  358. * can revoke a token when you need to.
  359. *
  360. * This registration token is not cached by FIRMessaging. FIRMessaging should have an APNs
  361. * token set before calling this to ensure that notifications can be delivered via APNs using
  362. * this FCM token. You may re-retrieve the FCM token once you have the APNs token set, to
  363. * associate it with the FCM token. The default FCM token is automatically associated with
  364. * the APNs token, if the APNs token data is available.
  365. *
  366. * This creates a Firebase Installations ID, if one does not exist, and sends information
  367. * about the application and the device to the Firebase backend.
  368. *
  369. * @param senderID The Sender ID for a particular Firebase project.
  370. * @param completion The completion handler to handle the token request.
  371. */
  372. - (void)retrieveFCMTokenForSenderID:(NSString *)senderID
  373. completion:(void (^)(NSString *_Nullable FCMToken,
  374. NSError *_Nullable error))completion
  375. NS_SWIFT_NAME(retrieveFCMToken(forSenderID:completion:));
  376. /**
  377. * Invalidates an FCM token for a particular Sender ID. That Sender ID cannot no longer send
  378. * notifications to that FCM token. This does not delete the Firebase Installations ID that may have
  379. * been created when generating the token. See `Installations.delete(completion:)`.
  380. *
  381. * @param senderID The senderID for a particular Firebase project.
  382. * @param completion The completion handler to handle the token deletion.
  383. */
  384. - (void)deleteFCMTokenForSenderID:(NSString *)senderID
  385. completion:(void (^)(NSError *_Nullable error))completion
  386. NS_SWIFT_NAME(deleteFCMToken(forSenderID:completion:));
  387. #pragma mark - Topics
  388. /**
  389. * Asynchronously subscribes to a topic. This uses the default FCM registration token to identify
  390. * the app instance and periodically sends data to the Firebase backend. To stop this, see
  391. * `Messaging.delete(completion:)` and `Installations.delete(completion:)`.
  392. *
  393. * @param topic The name of the topic, for example, @"sports".
  394. */
  395. - (void)subscribeToTopic:(NSString *)topic NS_SWIFT_NAME(subscribe(toTopic:));
  396. /**
  397. * Asynchronously subscribe to the provided topic, retrying on failure. This uses the default FCM
  398. * registration token to identify the app instance and periodically sends data to the Firebase
  399. * backend. To stop this, see `Messaging.delete(completion:)` and
  400. * `Installations.delete(completion:)`.
  401. *
  402. * @param topic The topic name to subscribe to, for example, @"sports".
  403. * @param completion The completion that is invoked once the subscribe call ends.
  404. * In case of success, nil error is returned. Otherwise, an
  405. * appropriate error object is returned.
  406. */
  407. - (void)subscribeToTopic:(nonnull NSString *)topic
  408. completion:(void (^_Nullable)(NSError *_Nullable error))completion;
  409. /**
  410. * Asynchronously unsubscribe from a topic. This uses a FCM Token
  411. * to identify the app instance and periodically sends data to the Firebase backend. To stop this,
  412. * see `Messaging.delete(completion:)` and `Installations.delete(completion:)`.
  413. *
  414. * @param topic The name of the topic, for example @"sports".
  415. */
  416. - (void)unsubscribeFromTopic:(NSString *)topic NS_SWIFT_NAME(unsubscribe(fromTopic:));
  417. /**
  418. * Asynchronously unsubscribe from the provided topic, retrying on failure. This uses a FCM Token
  419. * to identify the app instance and periodically sends data to the Firebase backend. To stop this,
  420. * see `Messaging.delete(completion:)` and `Installations.delete(completion:)`.
  421. *
  422. * @param topic The topic name to unsubscribe from, for example @"sports".
  423. * @param completion The completion that is invoked once the unsubscribe call ends.
  424. * In case of success, nil error is returned. Otherwise, an
  425. * appropriate error object is returned.
  426. */
  427. - (void)unsubscribeFromTopic:(nonnull NSString *)topic
  428. completion:(void (^_Nullable)(NSError *_Nullable error))completion;
  429. #pragma mark - Upstream
  430. /**
  431. * Sends an upstream ("device to cloud") message.
  432. *
  433. * The message is queued if we don't have an active connection.
  434. * You can only use the upstream feature if your FCM implementation
  435. * uses the XMPP server protocol.
  436. *
  437. * @param message Key/Value pairs to be sent. Values must be String, any
  438. * other type will be ignored.
  439. * @param receiver A string identifying the receiver of the message. For FCM
  440. * project IDs the value is `SENDER_ID@gcm.googleapis.com`.
  441. * @param messageID The ID of the message. This is generated by the application. It
  442. * must be unique for each message generated by this application.
  443. * It allows error callbacks and debugging, to uniquely identify
  444. * each message.
  445. * @param ttl The time to live for the message. In case we aren't able to
  446. * send the message before the TTL expires we will send you a
  447. * callback. If 0, we'll attempt to send immediately and return
  448. * an error if we're not connected. Otherwise, the message will
  449. * be queued. As for server-side messages, we don't return an error
  450. * if the message has been dropped because of TTL; this can happen
  451. * on the server side, and it would require extra communication.
  452. */
  453. - (void)sendMessage:(NSDictionary *)message
  454. to:(NSString *)receiver
  455. withMessageID:(NSString *)messageID
  456. timeToLive:(int64_t)ttl
  457. __deprecated_msg("Upstream messaging through direct channel is deprecated. For realtime "
  458. "updates, use Cloud Firestore, Realtime Database, or other services. ");
  459. #pragma mark - Analytics
  460. /**
  461. * Use this to track message delivery and analytics for messages, typically
  462. * when you receive a notification in `application:didReceiveRemoteNotification:`.
  463. * However, you only need to call this if you set the `FirebaseAppDelegateProxyEnabled`
  464. * flag to `NO` in your Info.plist. If `FirebaseAppDelegateProxyEnabled` is either missing
  465. * or set to `YES` in your Info.plist, the library will call this automatically.
  466. *
  467. * @param message The downstream message received by the application.
  468. *
  469. * @return Information about the downstream message.
  470. */
  471. - (FIRMessagingMessageInfo *)appDidReceiveMessage:(NSDictionary *)message;
  472. #pragma mark - GDPR
  473. /**
  474. * Deletes all the tokens and checkin data of the Firebase project and related data on the server
  475. * side. A network connection is required for the method to succeed.
  476. *
  477. * This does not delete the Firebase Installations ID. See `Installations.delete(completion:)`.
  478. * To prevent token auto generation, see `Messaging.isAutoInitEnabled`.
  479. *
  480. * @param completion A completion handler which is invoked when the operation completes. `error ==
  481. * nil` indicates success.
  482. */
  483. - (void)deleteDataWithCompletion:(void (^)(NSError *__nullable error))completion;
  484. @end
  485. NS_ASSUME_NONNULL_END