3737#import " AppCheck/Interop/GACAppCheckInterop.h"
3838#import " AppCheck/Interop/GACAppCheckTokenResultInterop.h"
3939
40- #import " FirebaseCore/Extension/FirebaseCoreInternal.h"
41-
4240NS_ASSUME_NONNULL_BEGIN
4341
4442// / A notification with the specified name is sent to the default notification center
5149// / `userInfo` key for the `AppCheckToken` in `appCheckTokenRefreshNotification`.
5250NSString *const kGACAppCheckTokenNotificationKey = @" GACAppCheckTokenNotificationKey" ;
5351
54- // / `userInfo` key for the `FirebaseApp. name` in `appCheckTokenRefreshNotification`.
55- NSString *const kGACAppCheckAppNameNotificationKey = @" GACAppCheckAppNameNotificationKey " ;
52+ // / `userInfo` key for the instance name in `appCheckTokenRefreshNotification`.
53+ NSString *const kGACAppCheckInstanceNameNotificationKey = @" GACAppCheckInstanceNameNotificationKey " ;
5654
5755// TODO(andrewheard): Remove from generic App Check SDK.
5856// FIREBASE_APP_CHECK_ONLY_BEGIN
6866
6967@interface GACAppCheck ()
7068
71- @property (nonatomic , readonly ) NSString *appName ;
69+ @property (nonatomic , readonly ) NSString *instanceName ;
7270@property (nonatomic , readonly ) id <GACAppCheckProvider> appCheckProvider;
7371@property (nonatomic , readonly ) id <GACAppCheckStorageProtocol> storage;
7472@property (nonatomic , readonly ) NSNotificationCenter *notificationCenter;
@@ -84,15 +82,15 @@ @implementation GACAppCheck
8482
8583#pragma mark - Internal
8684
87- - (instancetype )initWithAppName : (NSString *)appName
88- appCheckProvider : (id <GACAppCheckProvider>)appCheckProvider
89- storage : (id <GACAppCheckStorageProtocol>)storage
90- tokenRefresher : (id <GACAppCheckTokenRefresherProtocol>)tokenRefresher
91- notificationCenter : (NSNotificationCenter *)notificationCenter
92- settings : (id <GACAppCheckSettingsProtocol>)settings {
85+ - (instancetype )initWithInstanceName : (NSString *)instanceName
86+ appCheckProvider : (id <GACAppCheckProvider>)appCheckProvider
87+ storage : (id <GACAppCheckStorageProtocol>)storage
88+ tokenRefresher : (id <GACAppCheckTokenRefresherProtocol>)tokenRefresher
89+ notificationCenter : (NSNotificationCenter *)notificationCenter
90+ settings : (id <GACAppCheckSettingsProtocol>)settings {
9391 self = [super init ];
9492 if (self) {
95- _appName = appName ;
93+ _instanceName = instanceName ;
9694 _appCheckProvider = appCheckProvider;
9795 _storage = storage;
9896 _tokenRefresher = tokenRefresher;
@@ -110,28 +108,27 @@ - (instancetype)initWithAppName:(NSString *)appName
110108
111109#pragma mark - Public
112110
113- - (instancetype )initWithApp : (FIRApp *)app
114- appCheckProvider : (id <GACAppCheckProvider>)appCheckProvider
115- settings : (id <GACAppCheckSettingsProtocol>)settings {
111+ - (instancetype )initWithInstanceName : (NSString *)instanceName
112+ appCheckProvider : (id <GACAppCheckProvider>)appCheckProvider
113+ settings : (id <GACAppCheckSettingsProtocol>)settings
114+ resourceName : (NSString *)resourceName
115+ keychainAccessGroup : (nullable NSString *)accessGroup {
116116 GACAppCheckTokenRefreshResult *refreshResult =
117117 [[GACAppCheckTokenRefreshResult alloc ] initWithStatusNever ];
118118 GACAppCheckTokenRefresher *tokenRefresher =
119119 [[GACAppCheckTokenRefresher alloc ] initWithRefreshResult: refreshResult settings: settings];
120120
121- // TODO(andrewheard): Remove from generic App Check SDK.
122- // FIREBASE_APP_CHECK_ONLY_BEGIN
123121 NSString *tokenKey =
124- [NSString stringWithFormat: @" app_check_token.%@ .%@ " , app.name, app.options.googleAppID];
125- // FIREBASE_APP_CHECK_ONLY_END
126- GACAppCheckStorage *storage =
127- [[GACAppCheckStorage alloc ] initWithTokenKey: tokenKey accessGroup: app.options.appGroupID];
128-
129- return [self initWithAppName: app.name
130- appCheckProvider: appCheckProvider
131- storage: storage
132- tokenRefresher: tokenRefresher
133- notificationCenter: NSNotificationCenter .defaultCenter
134- settings: settings];
122+ [NSString stringWithFormat: @" app_check_token.%@ .%@ " , instanceName, resourceName];
123+ GACAppCheckStorage *storage = [[GACAppCheckStorage alloc ] initWithTokenKey: tokenKey
124+ accessGroup: accessGroup];
125+
126+ return [self initWithInstanceName: instanceName
127+ appCheckProvider: appCheckProvider
128+ storage: storage
129+ tokenRefresher: tokenRefresher
130+ notificationCenter: NSNotificationCenter .defaultCenter
131+ settings: settings];
135132}
136133
137134- (void )tokenForcingRefresh : (BOOL )forcingRefresh
@@ -204,8 +201,8 @@ - (nonnull NSString *)tokenDidChangeNotificationName {
204201 return GACAppCheckAppCheckTokenDidChangeNotification;
205202}
206203
207- - (nonnull NSString *)notificationAppNameKey {
208- return kGACAppCheckAppNameNotificationKey ;
204+ - (nonnull NSString *)notificationInstanceNameKey {
205+ return kGACAppCheckInstanceNameNotificationKey ;
209206}
210207
211208- (nonnull NSString *)notificationTokenKey {
@@ -320,7 +317,7 @@ - (void)postTokenUpdateNotificationWithToken:(GACAppCheckToken *)token {
320317 object: self
321318 userInfo: @{
322319 kGACAppCheckTokenNotificationKey : token.token ,
323- kGACAppCheckAppNameNotificationKey : self.appName
320+ kGACAppCheckInstanceNameNotificationKey : self.instanceName
324321 }];
325322}
326323
0 commit comments