@@ -72,6 +72,7 @@ - (BOOL)setStoredUserAccessGroup:(NSString *_Nullable)accessGroup
72
72
#pragma mark - User for Access Group
73
73
74
74
- (FIRUser *)getStoredUserForAccessGroup : (NSString *)accessGroup
75
+ shareAuthStateAcrossDevices : (BOOL )shareAuthStateAcrossDevices
75
76
projectIdentifier : (NSString *)projectIdentifier
76
77
error : (NSError *_Nullable *_Nullable)outError {
77
78
NSMutableDictionary *query = [[NSMutableDictionary alloc ] init ];
@@ -80,6 +81,9 @@ - (FIRUser *)getStoredUserForAccessGroup:(NSString *)accessGroup
80
81
query[(__bridge id )kSecAttrAccessGroup ] = accessGroup;
81
82
query[(__bridge id )kSecAttrService ] = projectIdentifier;
82
83
query[(__bridge id )kSecAttrAccount ] = kSharedKeychainAccountValue ;
84
+ if (shareAuthStateAcrossDevices) {
85
+ query[(__bridge id )kSecAttrSynchronizable ] = (__bridge id )kCFBooleanTrue ;
86
+ }
83
87
84
88
NSData *data = [self .keychainServices getItemWithQuery: query error: outError];
85
89
// If there's an outError parameter and it's populated, or there's no data, return.
@@ -105,17 +109,25 @@ - (FIRUser *)getStoredUserForAccessGroup:(NSString *)accessGroup
105
109
}
106
110
107
111
- (BOOL )setStoredUser : (FIRUser *)user
108
- forAccessGroup : (NSString *)accessGroup
109
- projectIdentifier : (NSString *)projectIdentifier
110
- error : (NSError *_Nullable *_Nullable)outError {
112
+ forAccessGroup : (NSString *)accessGroup
113
+ shareAuthStateAcrossDevices : (BOOL )shareAuthStateAcrossDevices
114
+ projectIdentifier : (NSString *)projectIdentifier
115
+ error : (NSError *_Nullable *_Nullable)outError {
111
116
NSMutableDictionary *query = [[NSMutableDictionary alloc ] init ];
112
117
query[(__bridge id )kSecClass ] = (__bridge id )kSecClassGenericPassword ;
113
- query[(__bridge id )kSecAttrAccessible ] =
114
- (__bridge id )kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly ;
118
+ if (shareAuthStateAcrossDevices) {
119
+ query[(__bridge id )kSecAttrAccessible ] = (__bridge id )kSecAttrAccessibleAfterFirstUnlock ;
120
+ } else {
121
+ query[(__bridge id )kSecAttrAccessible ] =
122
+ (__bridge id )kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly ;
123
+ }
115
124
116
125
query[(__bridge id )kSecAttrAccessGroup ] = accessGroup;
117
126
query[(__bridge id )kSecAttrService ] = projectIdentifier;
118
127
query[(__bridge id )kSecAttrAccount ] = kSharedKeychainAccountValue ;
128
+ if (shareAuthStateAcrossDevices) {
129
+ query[(__bridge id )kSecAttrSynchronizable ] = (__bridge id )kCFBooleanTrue ;
130
+ }
119
131
120
132
#if TARGET_OS_WATCH
121
133
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc ] initRequiringSecureCoding: false ];
@@ -138,12 +150,20 @@ - (BOOL)setStoredUser:(FIRUser *)user
138
150
}
139
151
140
152
- (BOOL )removeStoredUserForAccessGroup : (NSString *)accessGroup
153
+ shareAuthStateAcrossDevices : (BOOL )shareAuthStateAcrossDevices
141
154
projectIdentifier : (NSString *)projectIdentifier
142
155
error : (NSError *_Nullable *_Nullable)outError {
143
156
NSMutableDictionary *query = [[NSMutableDictionary alloc ] init ];
144
157
query[(__bridge id )kSecClass ] = (__bridge id )kSecClassGenericPassword ;
145
- query[(__bridge id )kSecAttrAccessible ] =
146
- (__bridge id )kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly ;
158
+ if (shareAuthStateAcrossDevices) {
159
+ query[(__bridge id )kSecAttrAccessible ] = (__bridge id )kSecAttrAccessibleAfterFirstUnlock ;
160
+ } else {
161
+ query[(__bridge id )kSecAttrAccessible ] =
162
+ (__bridge id )kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly ;
163
+ }
164
+ if (shareAuthStateAcrossDevices) {
165
+ query[(__bridge id )kSecAttrSynchronizable ] = (__bridge id )kCFBooleanTrue ;
166
+ }
147
167
148
168
query[(__bridge id )kSecAttrAccessGroup ] = accessGroup;
149
169
query[(__bridge id )kSecAttrService ] = projectIdentifier;
0 commit comments