| 94 | } |
| 95 | } |
| 96 | export class RemoteConfig implements IRemoteConfig { |
| 97 | _native: FIRRemoteConfig; |
| 98 | _app: FirebaseApp; |
| 99 | constructor(app?: FirebaseApp) { |
| 100 | if (app?.native) { |
| 101 | this._native = FIRRemoteConfig.remoteConfigWithApp(app.native); |
| 102 | } else { |
| 103 | if (defaultRemoteConfig) { |
| 104 | return defaultRemoteConfig; |
| 105 | } |
| 106 | defaultRemoteConfig = this; |
| 107 | this._native = FIRRemoteConfig.remoteConfig(); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | get native() { |
| 112 | return this._native; |
| 113 | } |
| 114 | get ios() { |
| 115 | return this.native; |
| 116 | } |
| 117 | |
| 118 | get app(): FirebaseApp { |
| 119 | if (!this._app) { |
| 120 | // @ts-ignore |
| 121 | this._app = FirebaseApp.fromNative(this.native.app); |
| 122 | } |
| 123 | return this._app; |
| 124 | } |
| 125 | |
| 126 | get fetchTimeMillis(): number { |
| 127 | return this.native.lastFetchTime?.getTime?.(); |
| 128 | } |
| 129 | get lastFetchStatus(): 'success' | 'failure' | 'no_fetch_yet' | 'throttled' { |
| 130 | switch (this.native.lastFetchStatus) { |
| 131 | case FIRRemoteConfigFetchStatus.Failure: |
| 132 | return 'failure'; |
| 133 | case FIRRemoteConfigFetchStatus.Success: |
| 134 | return 'success'; |
| 135 | case FIRRemoteConfigFetchStatus.NoFetchYet: |
| 136 | return 'no_fetch_yet'; |
| 137 | case FIRRemoteConfigFetchStatus.Throttled: |
| 138 | return 'throttled'; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | get settings() { |
| 143 | return ConfigSettings.fromNative(this.native.configSettings); |
| 144 | } |
| 145 | |
| 146 | set settings(value: ConfigSettings) { |
| 147 | this.native.configSettings = value.native; |
| 148 | } |
| 149 | |
| 150 | activate(): Promise<boolean> { |
| 151 | return new Promise((resolve, reject) => { |
| 152 | this.native.activateWithCompletion((done, error) => { |
| 153 | if (error) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…