Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
dependencies {
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "io.qonversion:sandwich:7.11.0"
implementation "io.qonversion:sandwich:7.12.0"
}

if (isNewArchitectureEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ class QonversionModule(reactContext: ReactApplicationContext) : NativeQonversion
)
}

@ReactMethod
override fun invalidateRemoteConfigsCache() {
qonversionSandwich.invalidateRemoteConfigsCache()
}

@ReactMethod
override fun attachUserToExperiment(experimentId: String, groupId: String, promise: Promise) {
qonversionSandwich.attachUserToExperiment(experimentId, groupId, getResultListener(promise))
Expand Down
8 changes: 8 additions & 0 deletions ios/RNQonversion.mm
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ - (void)remoteConfigListForContextKeys:(NSArray<NSString *> *)contextKeys includ
}
}

- (void)invalidateRemoteConfigsCache {
@try {
[self.impl invalidateRemoteConfigsCache];
} @catch (NSException *exception) {
QNR_LOG_EXCEPTION("invalidateRemoteConfigsCache", exception);
}
}

- (void)attachUserToExperiment:(NSString *)experimentId groupId:(NSString *)groupId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
@try {
[self.impl attachUserToExperiment:experimentId groupId:groupId resolve:resolve reject:reject];
Expand Down
5 changes: 5 additions & 0 deletions ios/RNQonversionImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ public class RNQonversionImpl: NSObject {
}
}

@objc
public func invalidateRemoteConfigsCache() {
qonversionSandwich?.invalidateRemoteConfigsCache()
}

@objc
public func attachUserToExperiment(_ experimentId: String, groupId: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
qonversionSandwich?.attachUserToExperiment(with: experimentId, groupId: groupId) { result, error in
Expand Down
2 changes: 1 addition & 1 deletion qonversion-react-native-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
s.private_header_files = "ios/**/*.h"

s.dependency "QonversionSandwich", "7.11.0"
s.dependency "QonversionSandwich", "7.12.0"
install_modules_dependencies(s)
end
25 changes: 25 additions & 0 deletions src/QonversionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,31 @@ export interface QonversionApi {
*/
remoteConfigListForContextKeys(contextKeys: string[], includeEmptyContextKey: boolean): Promise<RemoteConfigList>

/**
* Invalidates the cache of remote configs so the next {@link remoteConfig} or
* {@link remoteConfigList} call fetches a fresh targeting evaluation from the
* server instead of returning the cached copy.
*
* This method performs no network request itself — it only marks the cached
* values as stale. An in-flight remoteConfig load is re-issued once so its
* waiting calls receive a fresh evaluation; an in-flight remoteConfigList
* completes with the evaluation it started with.
*
* Call it when the targeting inputs changed and you need the change reflected
* immediately, for example after setting a batch of user properties your
* remote config targeting depends on. You do NOT need to call it after
* {@link identify} — the SDK invalidates the cache on identity changes
* automatically.
*
* If the re-issued load fails, the previously received evaluation is
* delivered instead of an error — the call never degrades below the
* pre-invalidation result.
*
* Call it after {@link Qonversion.initialize}: calling before initialization
* throws on Android and does nothing on iOS.
*/
invalidateRemoteConfigsCache(): void;

/**
* This function should be used for the test purposes only. Do not forget to delete the usage of this function before the release.
* Use this function to attach the user to the experiment.
Expand Down
4 changes: 4 additions & 0 deletions src/internal/QonversionInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ export default class QonversionInternal implements QonversionApi {
return mappedRemoteConfigList;
}

invalidateRemoteConfigsCache() {
RNQonversion.invalidateRemoteConfigsCache();
}

async attachUserToExperiment(experimentId: string, groupId: string): Promise<void> {
await RNQonversion.attachUserToExperiment(experimentId, groupId);
return;
Expand Down
11 changes: 11 additions & 0 deletions src/internal/__tests__/QonversionInternal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jest.mock('../specs/NativeQonversionModule', () => ({
}),
onPromoPurchaseReceived: jest.fn(),
purchaseWithResult: jest.fn(),
invalidateRemoteConfigsCache: jest.fn(),
},
}));

Expand Down Expand Up @@ -252,3 +253,13 @@ describe('QonversionInternal - setDeferredPurchasesListener replaces wrapped ent
expect(RNQonversion.onDeferredPurchaseCompleted).toHaveBeenCalledTimes(1);
});
});

describe('invalidateRemoteConfigsCache', () => {
it('passes the call straight through to the native module', () => {
const instance = new QonversionInternal(createConfig());

instance.invalidateRemoteConfigsCache();

expect(RNQonversion.invalidateRemoteConfigsCache).toHaveBeenCalledTimes(1);
});
});
1 change: 1 addition & 0 deletions src/internal/specs/NativeQonversionModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface Spec extends TurboModule {
remoteConfig(contextKey: string | undefined): Promise<QRemoteConfig>;
remoteConfigList(): Promise<QRemoteConfigList>;
remoteConfigListForContextKeys(contextKeys: string[], includeEmptyContextKey: boolean): Promise<QRemoteConfigList>;
invalidateRemoteConfigsCache(): void;
attachUserToExperiment(experimentId: string, groupId: string): Promise<void>;
detachUserFromExperiment(experimentId: string): Promise<void>;
attachUserToRemoteConfiguration(remoteConfigurationId: string): Promise<void>;
Expand Down
Loading