1
1
#import < Foundation/Foundation.h>
2
2
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ @class FIRInstanceIDResult;
3
6
/* *
4
7
* @memberof FIRInstanceID
5
8
*
6
9
* The scope to be used when fetching/deleting a token for Firebase Messaging.
7
10
*/
8
- FOUNDATION_EXPORT NSString *__nonnull const kFIRInstanceIDScopeFirebaseMessaging
11
+ FOUNDATION_EXPORT NSString *const kFIRInstanceIDScopeFirebaseMessaging
9
12
NS_SWIFT_NAME (InstanceIDScopeFirebaseMessaging);
10
13
11
14
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
@@ -17,7 +20,7 @@ FOUNDATION_EXPORT NSString *__nonnull const kFIRInstanceIDScopeFirebaseMessaging
17
20
* Instance ID service will throttle the refresh event across all devices
18
21
* to control the rate of token updates on application servers.
19
22
*/
20
- FOUNDATION_EXPORT const NSNotificationName __nonnull kFIRInstanceIDTokenRefreshNotification
23
+ FOUNDATION_EXPORT const NSNotificationName kFIRInstanceIDTokenRefreshNotification
21
24
NS_SWIFT_NAME (InstanceIDTokenRefresh);
22
25
#else
23
26
/* *
@@ -28,7 +31,7 @@ FOUNDATION_EXPORT const NSNotificationName __nonnull kFIRInstanceIDTokenRefreshN
28
31
* Instance ID service will throttle the refresh event across all devices
29
32
* to control the rate of token updates on application servers.
30
33
*/
31
- FOUNDATION_EXPORT NSString *__nonnull const kFIRInstanceIDTokenRefreshNotification
34
+ FOUNDATION_EXPORT NSString *const kFIRInstanceIDTokenRefreshNotification
32
35
NS_SWIFT_NAME (InstanceIDTokenRefreshNotification);
33
36
#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
34
37
@@ -56,7 +59,7 @@ typedef void (^FIRInstanceIDTokenHandler)(NSString *__nullable token, NSError *_
56
59
* @param error The error describing why deleting the token failed.
57
60
* See the error codes below for a more detailed description.
58
61
*/
59
- typedef void (^FIRInstanceIDDeleteTokenHandler)(NSError *__nullable error)
62
+ typedef void (^FIRInstanceIDDeleteTokenHandler)(NSError *error)
60
63
NS_SWIFT_NAME(InstanceIDDeleteTokenHandler);
61
64
62
65
/* *
@@ -84,6 +87,20 @@ typedef void (^FIRInstanceIDHandler)(NSString *__nullable identity, NSError *__n
84
87
typedef void (^FIRInstanceIDDeleteHandler)(NSError *__nullable error)
85
88
NS_SWIFT_NAME(InstanceIDDeleteHandler);
86
89
90
+ /* *
91
+ * @related FIRInstanceID
92
+ *
93
+ * The completion handler invoked when the app identity and token are fetched. If the
94
+ * identity wasn't created for some reason we return the appropriate error code.
95
+ *
96
+ * @param result The result containing an identity for the app instance and a valid token,
97
+ * nil if there was an error while creating the result.
98
+ * @param error The error if fetching the identity or token fails else nil.
99
+ */
100
+ typedef void (^FIRInstanceIDResultHandler)(FIRInstanceIDResult *__nullable result,
101
+ NSError *__nullable error)
102
+ NS_SWIFT_NAME(InstanceIDResultHandler);
103
+
87
104
/* *
88
105
* Public errors produced by InstanceID.
89
106
*/
@@ -114,19 +131,22 @@ typedef NS_ENUM(NSUInteger, FIRInstanceIDError) {
114
131
} NS_SWIFT_NAME(InstanceIDError);
115
132
116
133
/* *
117
- * The APNS token type for the app. If the token type is set to `UNKNOWN`
118
- * InstanceID will implicitly try to figure out what the actual token type
119
- * is from the provisioning profile.
134
+ * A class contains the results of InstanceID and token query.
135
+ */
136
+ NS_SWIFT_NAME (InstanceIDResult)
137
+ @interface FIRInstanceIDResult : NSObject <NSCopying>
138
+
139
+ /* *
140
+ * An instanceID uniquely identifies the app instance.
141
+ */
142
+ @property(nonatomic, readonly, copy) NSString *instanceID;
143
+
144
+ /*
145
+ * Returns a Firebase Messaging scoped token for the firebase app.
120
146
*/
121
- typedef NS_ENUM (NSInteger , FIRInstanceIDAPNSTokenType) {
122
- // / Unknown token type.
123
- FIRInstanceIDAPNSTokenTypeUnknown,
124
- // / Sandbox token type.
125
- FIRInstanceIDAPNSTokenTypeSandbox,
126
- // / Production token type.
127
- FIRInstanceIDAPNSTokenTypeProd,
128
- } NS_SWIFT_NAME(InstanceIDAPNSTokenType)
129
- __deprecated_enum_msg (" Use FIRMessaging's APNSToken property instead." );
147
+ @property(nonatomic, readonly, copy) NSString *token;
148
+
149
+ @end
130
150
131
151
/* *
132
152
* Instance ID provides a unique identifier for each app instance and a mechanism
@@ -155,36 +175,30 @@ NS_SWIFT_NAME(InstanceID)
155
175
*
156
176
* @return A shared instance of FIRInstanceID.
157
177
*/
158
- + (nonnull instancetype )instanceID NS_SWIFT_NAME(instanceID());
178
+ + (instancetype )instanceID NS_SWIFT_NAME(instanceID());
159
179
160
180
/* *
161
181
* Unavailable. Use +instanceID instead.
162
182
*/
163
- - (nonnull instancetype )init __attribute__ ((unavailable(" Use +instanceID instead." )));
183
+ - (instancetype )init __attribute__ ((unavailable(" Use +instanceID instead." )));
184
+
185
+ #pragma mark - Tokens
164
186
165
187
/* *
166
- * Set APNS token for the application. This APNS token will be used to register
167
- * with Firebase Messaging using `token` or
168
- * `tokenWithAuthorizedEntity:scope:options:handler`. If the token type is set to
169
- * `FIRInstanceIDAPNSTokenTypeUnknown` InstanceID will read the provisioning profile
170
- * to find out the token type.
171
- *
172
- * @param token The APNS token for the application.
173
- * @param type The APNS token type for the above token.
188
+ * Returns a result of app instance identifier InstanceID and a Firebase Messaging scoped token.
189
+ * param handler The callback handler invoked when an app instanceID and a default token
190
+ * are generated and returned. If instanceID and token fetching fail for some
191
+ * reason the callback is invoked with nil `result` and the appropriate error.
174
192
*/
175
- - (void )setAPNSToken:(nonnull NSData *)token
176
- type:(FIRInstanceIDAPNSTokenType)type
177
- __deprecated_msg (" Use FIRMessaging's APNSToken property instead." );
178
-
179
- #pragma mark - Tokens
193
+ - (void )instanceIDWithHandler:(FIRInstanceIDResultHandler)handler;
180
194
181
195
/* *
182
196
* Returns a Firebase Messaging scoped token for the firebase app.
183
197
*
184
198
* @return Returns the stored token if the device has registered with Firebase Messaging, otherwise
185
199
* returns nil.
186
200
*/
187
- - (nullable NSString *)token;
201
+ - (nullable NSString *)token __deprecated_msg ( " Use instanceIDWithHandler: instead. " ) ;
188
202
189
203
/* *
190
204
* Returns a token that authorizes an Entity (example: cloud service) to perform
@@ -225,10 +239,10 @@ NS_SWIFT_NAME(InstanceID)
225
239
* is nil and a valid `error` is returned. The valid error
226
240
* codes have been documented above.
227
241
*/
228
- - (void )tokenWithAuthorizedEntity:(nonnull NSString *)authorizedEntity
229
- scope:(nonnull NSString *)scope
242
+ - (void )tokenWithAuthorizedEntity:(NSString *)authorizedEntity
243
+ scope:(NSString *)scope
230
244
options:(nullable NSDictionary *)options
231
- handler:(nonnull FIRInstanceIDTokenHandler)handler;
245
+ handler:(FIRInstanceIDTokenHandler)handler;
232
246
233
247
/* *
234
248
* Revokes access to a scope (action) for an entity previously
@@ -249,9 +263,9 @@ NS_SWIFT_NAME(InstanceID)
249
263
* In case of error an appropriate error object is returned
250
264
* else error is nil.
251
265
*/
252
- - (void )deleteTokenWithAuthorizedEntity:(nonnull NSString *)authorizedEntity
253
- scope:(nonnull NSString *)scope
254
- handler:(nonnull FIRInstanceIDDeleteTokenHandler)handler;
266
+ - (void )deleteTokenWithAuthorizedEntity:(NSString *)authorizedEntity
267
+ scope:(NSString *)scope
268
+ handler:(FIRInstanceIDDeleteTokenHandler)handler;
255
269
256
270
#pragma mark - Identity
257
271
@@ -269,7 +283,7 @@ NS_SWIFT_NAME(InstanceID)
269
283
* a valid identifier is returned and a valid identifier for the
270
284
* application instance.
271
285
*/
272
- - (void )getIDWithHandler:(nonnull FIRInstanceIDHandler)handler NS_SWIFT_NAME (getID(handler:));
286
+ - (void )getIDWithHandler:(FIRInstanceIDHandler)handler NS_SWIFT_NAME (getID(handler:));
273
287
274
288
/* *
275
289
* Resets Instance ID and revokes all tokens.
@@ -283,7 +297,8 @@ NS_SWIFT_NAME(InstanceID)
283
297
* (like FCM, RemoteConfig or Analytics) or user explicitly calls Instance ID APIs to get an
284
298
* Instance ID and token again.
285
299
*/
286
- - (void )deleteIDWithHandler:(nonnull FIRInstanceIDDeleteHandler)handler
287
- NS_SWIFT_NAME (deleteID(handler:));
300
+ - (void )deleteIDWithHandler:(FIRInstanceIDDeleteHandler)handler NS_SWIFT_NAME (deleteID(handler:));
288
301
289
302
@end
303
+
304
+ NS_ASSUME_NONNULL_END
0 commit comments