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