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 |
FOUNDATION_EXPORT const NSTimeInterval kFIRMessagingDefaultCheckinInterval;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* The preferences InstanceID loads from checkin server. The deviceID and secret that checkin
|
|
|
23 |
* provides is used to authenticate all future requests to the server. Besides the deviceID
|
|
|
24 |
* and secret the other information that checkin provides is stored in a plist on the device.
|
|
|
25 |
* The deviceID and secret are persisted in the device keychain.
|
|
|
26 |
*/
|
|
|
27 |
@interface FIRMessagingCheckinPreferences : NSObject
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* DeviceID and secretToken are the checkin auth credentials and are stored in the Keychain.
|
|
|
31 |
*/
|
|
|
32 |
@property(nonatomic, readonly, copy) NSString *deviceID;
|
|
|
33 |
@property(nonatomic, readonly, copy) NSString *secretToken;
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* All the other checkin preferences other than deviceID and secret are stored in a plist.
|
|
|
37 |
*/
|
|
|
38 |
@property(nonatomic, readonly, copy) NSString *deviceDataVersion;
|
|
|
39 |
@property(nonatomic, readonly, copy) NSString *digest;
|
|
|
40 |
@property(nonatomic, readonly, copy) NSString *versionInfo;
|
|
|
41 |
@property(nonatomic, readonly, assign) int64_t lastCheckinTimestampMillis;
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* The content retrieved from checkin server that should be persisted in a plist. This
|
|
|
45 |
* doesn't contain the deviceID and secret which are stored in the Keychain since they
|
|
|
46 |
* should be more private.
|
|
|
47 |
*
|
|
|
48 |
* @return The checkin preferences that should be persisted in a plist.
|
|
|
49 |
*/
|
|
|
50 |
- (NSDictionary *)checkinPlistContents;
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* Return whether checkin info exists, valid or not.
|
|
|
54 |
*/
|
|
|
55 |
- (BOOL)hasCheckinInfo;
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* Verify if checkin preferences are valid or not.
|
|
|
59 |
*
|
|
|
60 |
* @return YES if valid checkin preferences else NO.
|
|
|
61 |
*/
|
|
|
62 |
- (BOOL)hasValidCheckinInfo;
|
|
|
63 |
|
|
|
64 |
- (BOOL)hasPreCachedAuthCredentials;
|
|
|
65 |
- (void)setHasPreCachedAuthCredentials:(BOOL)hasPreCachedAuthCredentials;
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Parse the checkin auth credentials saved in the Keychain to initialize checkin
|
|
|
69 |
* preferences.
|
|
|
70 |
*
|
|
|
71 |
* @param keychainContent The checkin auth credentials saved in the Keychain.
|
|
|
72 |
*
|
|
|
73 |
* @return A valid checkin preferences object if the checkin auth credentials in the
|
|
|
74 |
* keychain can be parsed successfully else nil.
|
|
|
75 |
*/
|
|
|
76 |
+ (FIRMessagingCheckinPreferences *)preferencesFromKeychainContents:(NSString *)keychainContent;
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* Default initializer for InstanceID checkin preferences.
|
|
|
80 |
*
|
|
|
81 |
* @param deviceID The deviceID for the app.
|
|
|
82 |
* @param secretToken The secret token the app uses to authenticate with the server.
|
|
|
83 |
*
|
|
|
84 |
* @return A checkin preferences object with given deviceID and secretToken.
|
|
|
85 |
*/
|
|
|
86 |
- (instancetype)initWithDeviceID:(NSString *)deviceID secretToken:(NSString *)secretToken;
|
|
|
87 |
|
|
|
88 |
/**
|
|
|
89 |
* Update checkin preferences from the preferences dict persisted as a plist. The dict contains
|
|
|
90 |
* all the checkin preferences retrieved from the server except the deviceID and secret which
|
|
|
91 |
* are stored in the Keychain.
|
|
|
92 |
*
|
|
|
93 |
* @param checkinPlistContent The checkin preferences saved in a plist on the disk.
|
|
|
94 |
*/
|
|
|
95 |
- (void)updateWithCheckinPlistContents:(NSDictionary *)checkinPlistContent;
|
|
|
96 |
|
|
|
97 |
/**
|
|
|
98 |
* Reset the current checkin preferences object.
|
|
|
99 |
*/
|
|
|
100 |
- (void)reset;
|
|
|
101 |
|
|
|
102 |
/**
|
|
|
103 |
* The string that contains the checkin auth credentials i.e. deviceID and secret. This
|
|
|
104 |
* needs to be stored in the Keychain.
|
|
|
105 |
*
|
|
|
106 |
* @return The checkin auth credential string containing the deviceID and secret.
|
|
|
107 |
*/
|
|
|
108 |
- (NSString *)checkinKeychainContent;
|
|
|
109 |
|
|
|
110 |
@end
|