commit | author | age
|
a6c014
|
1 |
/* |
L |
2 |
* Copyright 2019 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 FIRApp; |
|
20 |
@class FIRInstallationsAuthTokenResult; |
|
21 |
|
|
22 |
NS_ASSUME_NONNULL_BEGIN |
|
23 |
|
|
24 |
/** A notification with this name is sent each time an installation is created or deleted. */ |
454098
|
25 |
FOUNDATION_EXPORT const NSNotificationName FIRInstallationIDDidChangeNotification |
L |
26 |
NS_SWIFT_NAME(InstallationIDDidChange); |
a6c014
|
27 |
/** `userInfo` key for the `FirebaseApp.name` in `FIRInstallationIDDidChangeNotification`. */ |
454098
|
28 |
FOUNDATION_EXPORT NSString *const kFIRInstallationIDDidChangeNotificationAppNameKey |
L |
29 |
NS_SWIFT_NAME(InstallationIDDidChangeAppNameKey); |
a6c014
|
30 |
|
L |
31 |
/** |
|
32 |
* An installation ID handler block. |
|
33 |
* @param identifier The installation ID string if exists or `nil` otherwise. |
|
34 |
* @param error The error when `identifier == nil` or `nil` otherwise. |
|
35 |
*/ |
|
36 |
typedef void (^FIRInstallationsIDHandler)(NSString *__nullable identifier, |
|
37 |
NSError *__nullable error) |
|
38 |
NS_SWIFT_NAME(InstallationsIDHandler); |
|
39 |
|
|
40 |
/** |
|
41 |
* An authorization token handler block. |
|
42 |
* @param tokenResult An instance of `InstallationsAuthTokenResult` in case of success or `nil` |
|
43 |
* otherwise. |
|
44 |
* @param error The error when `tokenResult == nil` or `nil` otherwise. |
|
45 |
*/ |
|
46 |
typedef void (^FIRInstallationsTokenHandler)( |
|
47 |
FIRInstallationsAuthTokenResult *__nullable tokenResult, NSError *__nullable error) |
|
48 |
NS_SWIFT_NAME(InstallationsTokenHandler); |
|
49 |
|
|
50 |
/** |
|
51 |
* The class provides API for Firebase Installations. |
|
52 |
* Each configured `FirebaseApp` has a corresponding single instance of `Installations`. |
|
53 |
* An instance of the class provides access to the installation info for the `FirebaseApp` as well |
|
54 |
* as the ability to delete it. A Firebase Installation is unique by `FirebaseApp.name` and |
|
55 |
* `FirebaseApp.options.googleAppID` . |
|
56 |
*/ |
|
57 |
NS_SWIFT_NAME(Installations) |
|
58 |
@interface FIRInstallations : NSObject |
|
59 |
|
|
60 |
- (instancetype)init NS_UNAVAILABLE; |
|
61 |
|
|
62 |
/** |
|
63 |
* Returns a default instance of `Installations`. |
|
64 |
* @returns An instance of `Installations` for `FirebaseApp.defaultApp(). |
|
65 |
* @throw Throws an exception if the default app is not configured yet or required `FirebaseApp` |
|
66 |
* options are missing. |
|
67 |
*/ |
|
68 |
+ (FIRInstallations *)installations NS_SWIFT_NAME(installations()); |
|
69 |
|
|
70 |
/** |
|
71 |
* Returns an instance of `Installations` for an application. |
|
72 |
* @param application A configured `FirebaseApp` instance. |
|
73 |
* @returns An instance of `Installations` corresponding to the passed application. |
|
74 |
* @throw Throws an exception if required `FirebaseApp` options are missing. |
|
75 |
*/ |
|
76 |
+ (FIRInstallations *)installationsWithApp:(FIRApp *)application NS_SWIFT_NAME(installations(app:)); |
|
77 |
|
|
78 |
/** |
|
79 |
* The method creates or retrieves an installation ID. The installation ID is a stable identifier |
|
80 |
* that uniquely identifies the app instance. NOTE: If the application already has an existing |
|
81 |
* FirebaseInstanceID then the InstanceID identifier will be used. |
|
82 |
* @param completion A completion handler which is invoked when the operation completes. See |
|
83 |
* `InstallationsIDHandler` for additional details. |
|
84 |
*/ |
|
85 |
- (void)installationIDWithCompletion:(FIRInstallationsIDHandler)completion; |
|
86 |
|
|
87 |
/** |
454098
|
88 |
* Retrieves (locally if it exists or from the server) a valid installation auth token. An existing |
L |
89 |
* token may be invalidated or expired, so it is recommended to fetch the installation auth token |
|
90 |
* before each server request. The method does the same as `Installations.authTokenForcingRefresh(:, |
a6c014
|
91 |
* completion:)` with forcing refresh `NO`. |
L |
92 |
* @param completion A completion handler which is invoked when the operation completes. See |
|
93 |
* `InstallationsTokenHandler` for additional details. |
|
94 |
*/ |
|
95 |
- (void)authTokenWithCompletion:(FIRInstallationsTokenHandler)completion; |
|
96 |
|
|
97 |
/** |
454098
|
98 |
* Retrieves (locally or from the server depending on `forceRefresh` value) a valid installation |
L |
99 |
* auth token. An existing token may be invalidated or expire, so it is recommended to fetch the |
|
100 |
* installation auth token before each server request. This method should be used with `forceRefresh |
|
101 |
* == YES` when e.g. a request with the previously fetched installation auth token failed with "Not |
|
102 |
* Authorized" error. |
|
103 |
* @param forceRefresh If `YES` then the locally cached installation auth token will be ignored and |
|
104 |
* a new one will be requested from the server. If `NO`, then the locally cached installation auth |
|
105 |
* token will be returned if exists and has not expired yet. |
a6c014
|
106 |
* @param completion A completion handler which is invoked when the operation completes. See |
L |
107 |
* `InstallationsTokenHandler` for additional details. |
|
108 |
*/ |
|
109 |
- (void)authTokenForcingRefresh:(BOOL)forceRefresh |
|
110 |
completion:(FIRInstallationsTokenHandler)completion; |
|
111 |
|
|
112 |
/** |
|
113 |
* Deletes all the installation data including the unique identifier, auth tokens and |
|
114 |
* all related data on the server side. A network connection is required for the method to |
|
115 |
* succeed. If fails, the existing installation data remains untouched. |
|
116 |
* @param completion A completion handler which is invoked when the operation completes. `error == |
|
117 |
* nil` indicates success. |
|
118 |
*/ |
|
119 |
- (void)deleteWithCompletion:(void (^)(NSError *__nullable error))completion; |
|
120 |
|
|
121 |
@end |
|
122 |
|
|
123 |
NS_ASSUME_NONNULL_END |