1 |
efrain |
1 |
/*
|
|
|
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 |
#import "FirebaseInstallations/Source/Library/InstallationsIDController/FIRInstallationsStatus.h"
|
|
|
20 |
|
|
|
21 |
@class FIRInstallationsStoredItem;
|
|
|
22 |
@class FIRInstallationsStoredAuthToken;
|
|
|
23 |
@class FIRInstallationsStoredIIDCheckin;
|
|
|
24 |
|
|
|
25 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* The class represents the required installation ID and auth token data including possible states.
|
|
|
29 |
* The data is stored to Keychain via `FIRInstallationsStoredItem` which has only the storage
|
|
|
30 |
* relevant data and does not contain any logic. `FIRInstallationsItem` must be used on the logic
|
|
|
31 |
* level (not `FIRInstallationsStoredItem`).
|
|
|
32 |
*/
|
|
|
33 |
@interface FIRInstallationsItem : NSObject <NSCopying>
|
|
|
34 |
|
|
|
35 |
/// A `FirebaseApp` identifier.
|
|
|
36 |
@property(nonatomic, readonly) NSString *appID;
|
|
|
37 |
/// A `FirebaseApp` name.
|
|
|
38 |
@property(nonatomic, readonly) NSString *firebaseAppName;
|
|
|
39 |
/// A stable identifier that uniquely identifies the app instance.
|
|
|
40 |
@property(nonatomic, copy, nullable) NSString *firebaseInstallationID;
|
|
|
41 |
/// The `refreshToken` is used to authorize the auth token requests.
|
|
|
42 |
@property(nonatomic, copy, nullable) NSString *refreshToken;
|
|
|
43 |
|
|
|
44 |
@property(nonatomic, nullable) FIRInstallationsStoredAuthToken *authToken;
|
|
|
45 |
@property(nonatomic, assign) FIRInstallationsStatus registrationStatus;
|
|
|
46 |
|
|
|
47 |
/// Instance ID default token imported from IID store as a part of IID migration.
|
|
|
48 |
@property(nonatomic, nullable) NSString *IIDDefaultToken;
|
|
|
49 |
|
|
|
50 |
- (instancetype)initWithAppID:(NSString *)appID firebaseAppName:(NSString *)firebaseAppName;
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* Populates `FIRInstallationsItem` properties with data from `FIRInstallationsStoredItem`.
|
|
|
54 |
* @param item An instance of `FIRInstallationsStoredItem` to get data from.
|
|
|
55 |
*/
|
|
|
56 |
- (void)updateWithStoredItem:(FIRInstallationsStoredItem *)item;
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Creates a stored item with data from the object.
|
|
|
60 |
* @return Returns a `FIRInstallationsStoredItem` instance with the data from the object.
|
|
|
61 |
*/
|
|
|
62 |
- (FIRInstallationsStoredItem *)storedItem;
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* The installation identifier.
|
|
|
66 |
* @return Returns a string uniquely identifying the installation.
|
|
|
67 |
*/
|
|
|
68 |
- (NSString *)identifier;
|
|
|
69 |
|
|
|
70 |
/** Validates if all the required item fields are populated and values don't explicitly conflict
|
|
|
71 |
* with each other.
|
|
|
72 |
* @param outError A reference to be populated with an error containing validation failure details.
|
|
|
73 |
* @return `YES` if the item it valid, `NO` otherwise.
|
|
|
74 |
*/
|
|
|
75 |
- (BOOL)isValid:(NSError *_Nullable *)outError;
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* The installation identifier.
|
|
|
79 |
* @param appID A `FirebaseApp` identifier.
|
|
|
80 |
* @param appName A `FirebaseApp` name.
|
|
|
81 |
* @return Returns a string uniquely identifying the installation.
|
|
|
82 |
*/
|
|
|
83 |
+ (NSString *)identifierWithAppID:(NSString *)appID appName:(NSString *)appName;
|
|
|
84 |
|
|
|
85 |
/**
|
|
|
86 |
* Generate a new Firebase Installation Identifier.
|
|
|
87 |
* @return Returns a 22 characters long globally unique string created based on UUID.
|
|
|
88 |
*/
|
|
|
89 |
+ (NSString *)generateFID;
|
|
|
90 |
|
|
|
91 |
@end
|
|
|
92 |
|
|
|
93 |
NS_ASSUME_NONNULL_END
|