1 |
efrain |
1 |
/*
|
|
|
2 |
* Copyright 2018 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 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
20 |
|
|
|
21 |
extern NSInteger const kFIRIAMMaxFetchInNewlyInstalledMode;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* At runtime a FIAM SDK client can function in one of the following modes:
|
|
|
25 |
* 1 Regular. This SDK client instance will conform to regular fetch minimal interval time policy.
|
|
|
26 |
* 2 Newly installed. This is a mode a newly installed SDK stays in until the first
|
|
|
27 |
* kFIRIAMMaxFetchInNewlyInstalledMode fetches have finished. In this mode, there is no
|
|
|
28 |
* minimal time interval between fetches: a fetch would be triggered as long as the app goes
|
|
|
29 |
* into foreground state.
|
|
|
30 |
* 3 Testing Instance. This app instance is targeted for test on device feature for fiam. When
|
|
|
31 |
* it's in this mode, no minimal time interval between fetches is applied. SDK turns itself
|
|
|
32 |
* into this mode on seeing test-on-client messages are returned in fetch responses.
|
|
|
33 |
*/
|
|
|
34 |
|
|
|
35 |
typedef NS_ENUM(NSInteger, FIRIAMSDKMode) {
|
|
|
36 |
FIRIAMSDKModeRegular,
|
|
|
37 |
FIRIAMSDKModeTesting,
|
|
|
38 |
FIRIAMSDKModeNewlyInstalled
|
|
|
39 |
};
|
|
|
40 |
|
|
|
41 |
// turn the sdk mode enum integer value into a descriptive string
|
|
|
42 |
NSString *FIRIAMDescriptonStringForSDKMode(FIRIAMSDKMode mode);
|
|
|
43 |
|
|
|
44 |
extern NSString *const kFIRIAMUserDefaultKeyForSDKMode;
|
|
|
45 |
extern NSString *const kFIRIAMUserDefaultKeyForServerFetchCount;
|
|
|
46 |
extern NSInteger const kFIRIAMMaxFetchInNewlyInstalledMode;
|
|
|
47 |
|
|
|
48 |
@protocol FIRIAMTestingModeListener <NSObject>
|
|
|
49 |
// Triggered when the current app switches into testing mode from a using testing mode
|
|
|
50 |
- (void)testingModeSwitchedOn;
|
|
|
51 |
@end
|
|
|
52 |
|
|
|
53 |
// A class for tracking and updating the SDK mode. The tracked mode related info is persisted
|
|
|
54 |
// so that it can be restored beyond app restarts
|
|
|
55 |
@interface FIRIAMSDKModeManager : NSObject
|
|
|
56 |
|
|
|
57 |
- (instancetype)init NS_UNAVAILABLE;
|
|
|
58 |
|
|
|
59 |
// having NSUserDefaults as passed-in to help with unit testing
|
|
|
60 |
- (instancetype)initWithUserDefaults:(NSUserDefaults *)userDefaults
|
|
|
61 |
testingModeListener:(id<FIRIAMTestingModeListener>)testingModeListener;
|
|
|
62 |
|
|
|
63 |
// returns the current SDK mode
|
|
|
64 |
- (FIRIAMSDKMode)currentMode;
|
|
|
65 |
|
|
|
66 |
// turn the current SDK into 'Testing Instance' mode.
|
|
|
67 |
- (void)becomeTestingInstance;
|
|
|
68 |
// inform the manager that one more fetch is done. This is to allow
|
|
|
69 |
// the manager to potentially graduate from the newly installed mode.
|
|
|
70 |
- (void)registerOneMoreFetch;
|
|
|
71 |
|
|
|
72 |
@end
|
|
|
73 |
NS_ASSUME_NONNULL_END
|