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.

87 lines
3.1 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 "FIRMessaging.h"
  17. #import "FIRMessagingCheckinService.h"
  18. @class FIRMessagingCheckinStore;
  19. @class FIRMessagingPubSubRegistrar;
  20. /**
  21. * Handle the registration process for the client. Fetch checkin information from the Checkin
  22. * service if not cached on the device and then try to register the client with FIRMessaging backend.
  23. */
  24. @interface FIRMessagingRegistrar : NSObject
  25. @property(nonatomic, readonly, strong) FIRMessagingPubSubRegistrar *pubsubRegistrar;
  26. @property(nonatomic, readonly, strong) NSString *deviceAuthID;
  27. @property(nonatomic, readonly, strong) NSString *secretToken;
  28. /**
  29. * Initialize a FIRMessaging Registrar.
  30. *
  31. * @return A FIRMessaging Registrar object.
  32. */
  33. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  34. #pragma mark - Checkin
  35. /**
  36. * Try to load checkin info from the disk if not currently loaded into memory.
  37. *
  38. * @return YES if successfully loaded valid checkin info to memory else NO.
  39. */
  40. - (BOOL)tryToLoadValidCheckinInfo;
  41. /**
  42. * Check if we have a valid checkin info in memory.
  43. *
  44. * @return YES if we have valid checkin info in memory else NO.
  45. */
  46. - (BOOL)hasValidCheckinInfo;
  47. #pragma mark - Subscribe/Unsubscribe
  48. /**
  49. * Update the subscription for a given topic for the client.
  50. *
  51. * @param topic The topic for which the subscription should be updated.
  52. * @param token The registration token to be used by the client.
  53. * @param options The extra options if any being passed as part of
  54. * subscription request.
  55. * @param shouldDelete YES if we want to delete an existing subscription else NO
  56. * if we want to create a new subscription.
  57. * @param handler The handler to invoke once the subscription request is
  58. * complete.
  59. */
  60. - (void)updateSubscriptionToTopic:(NSString *)topic
  61. withToken:(NSString *)token
  62. options:(NSDictionary *)options
  63. shouldDelete:(BOOL)shouldDelete
  64. handler:(FIRMessagingTopicOperationCompletion)handler;
  65. /**
  66. * Cancel all subscription requests as well as any requests to checkin. Note if
  67. * there are subscription requests waiting on checkin to complete those requests
  68. * would be marked as stale and be NO-OP's if they happen in the future.
  69. *
  70. * Also note this is a one time operation, you should only call this if you want
  71. * to immediately stop all requests and deallocate the registrar. After calling
  72. * this once you would no longer be able to use this registrar object.
  73. */
  74. - (void)cancelAllRequests;
  75. @end