FIRMessagingClient.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 <FirebaseMessaging/FIRMessaging.h>
  17. @class FIRMessagingRmqManager;
  18. @protocol FIRMessagingClientDelegate <NSObject>
  19. @end
  20. /**
  21. * The client handles the subscribe/unsubscribe for an unregistered senderID
  22. * and device. It also manages the FIRMessaging data connection, the exponential backoff
  23. * algorithm in case of registration failures, sign in failures and unregister
  24. * failures. It also handles the reconnect logic if the FIRMessaging connection is
  25. * broken off by some error during an active session.
  26. */
  27. @interface FIRMessagingClient : NSObject
  28. // Designated initializer
  29. - (instancetype)initWithDelegate:(id<FIRMessagingClientDelegate>)delegate;
  30. - (void)teardown;
  31. - (void)cancelAllRequests;
  32. #pragma mark - FIRMessaging subscribe
  33. /**
  34. * Update the subscription associated with the given token and topic.
  35. *
  36. * For a to-be-created subscription we check if the client is already
  37. * subscribed to the topic or not. If subscribed we should have the
  38. * subscriptionID in the cache and we return from there itself, else we call
  39. * the FIRMessaging backend to create a new subscription for the topic for this client.
  40. *
  41. * For delete subscription requests we delete the stored subscription in the
  42. * client and then invoke the FIRMessaging backend to delete the existing subscription
  43. * completely.
  44. *
  45. * @param token The token associated with the device.
  46. * @param topic The topic for which the subscription should be updated.
  47. * @param options The options to be passed in to the subscription request.
  48. * @param shouldDelete If YES this would delete the subscription from the cache
  49. * and also let the FIRMessaging backend know that we need to delete
  50. * the subscriptionID associated with this topic.
  51. * If NO we try to create a new subscription for the given
  52. * token and topic.
  53. * @param handler The handler to invoke once the subscription request
  54. * finishes.
  55. */
  56. - (void)updateSubscriptionWithToken:(NSString *)token
  57. topic:(NSString *)topic
  58. options:(NSDictionary *)options
  59. shouldDelete:(BOOL)shouldDelete
  60. handler:(FIRMessagingTopicOperationCompletion)handler;
  61. @end