Skip to content

Commit 57261d9

Browse files
authored
ForceContentUpdate with boolean flag (#460)
1 parent 1d723c1 commit 57261d9

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,12 +2350,21 @@ + (void)forceContentUpdate
23502350
}
23512351

23522352
+ (void)forceContentUpdate:(LeanplumVariablesChangedBlock)block
2353+
{
2354+
[Leanplum forceContentUpdateWithBlock:^(BOOL success) {
2355+
if (block) {
2356+
block();
2357+
}
2358+
}];
2359+
}
2360+
2361+
+ (void)forceContentUpdateWithBlock:(LeanplumForceContentUpdateBlock)updateBlock
23532362
{
23542363
[[LPCountAggregator sharedAggregator] incrementCount:@"force_content_update"];
23552364

23562365
if (IS_NOOP) {
2357-
if (block) {
2358-
block();
2366+
if (updateBlock) {
2367+
updateBlock(NO);
23592368
}
23602369
return;
23612370
}
@@ -2405,13 +2414,13 @@ + (void)forceContentUpdate:(LeanplumVariablesChangedBlock)block
24052414
[[self inbox] triggerInboxSyncedWithStatus:YES withCompletionHandler:nil];
24062415
}
24072416
LP_END_TRY
2408-
if (block) {
2409-
block();
2417+
if (updateBlock) {
2418+
updateBlock(YES);
24102419
}
24112420
}];
24122421
[request onError:^(NSError *error) {
2413-
if (block) {
2414-
block();
2422+
if (updateBlock) {
2423+
updateBlock(NO);
24152424
}
24162425
[[self inbox] triggerInboxSyncedWithStatus:NO withCompletionHandler:nil];
24172426
}];

LeanplumSDK/LeanplumSDK/Classes/LPVar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
NS_ASSUME_NONNULL_BEGIN
2828

2929
typedef void (^LeanplumVariablesChangedBlock)(void);
30+
typedef void (^LeanplumForceContentUpdateBlock)(BOOL success);
3031

3132
@class LPVar;
3233

LeanplumSDK/LeanplumSDK/Classes/Leanplum.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,15 @@ NS_SWIFT_UNAVAILABLE("use forceContentUpdate(completion:)");
703703
*/
704704
+ (void)forceContentUpdate:(nullable LeanplumVariablesChangedBlock)block;
705705

706+
/**
707+
* Forces content to update from the server. If variables have changed, the
708+
* appropriate callbacks will fire. Use sparingly as if the app is updated,
709+
* you'll have to deal with potentially inconsistent state or user experience.
710+
* The provided callback has a boolean flag whether the update was successful or not. The callback fires regardless
711+
* of whether the variables have changed.
712+
*/
713+
+ (void)forceContentUpdateWithBlock:(LeanplumForceContentUpdateBlock)updateBlock;
714+
706715
/**
707716
* This should be your first statement in a unit test. This prevents
708717
* Leanplum from communicating with the server.

0 commit comments

Comments
 (0)