@@ -3626,24 +3626,38 @@ - (void)runActionNamed:(NSString *)name
36263626 // Chain to existing message.
36273627 NSString *messageId = args[LP_VALUE_CHAIN_MESSAGE_ARG];
36283628 NSString *actionType = args[LP_VALUE_ACTION_ARG];
3629+
3630+ void (^executeChainedMessage)(void ) = ^void (void ) {
3631+ LPActionContext *chainedActionContext =
3632+ [Leanplum createActionContextForMessageId: messageId];
3633+ chainedActionContext.contextualValues = self.contextualValues ;
3634+ chainedActionContext->_preventRealtimeUpdating = _preventRealtimeUpdating;
3635+ chainedActionContext->_isRooted = _isRooted;
3636+ dispatch_async (dispatch_get_main_queue (), ^{
3637+ [Leanplum triggerAction: chainedActionContext handledBlock: ^(BOOL success) {
3638+ if (success) {
3639+ // Track when the chain message is viewed.
3640+ [[LPInternalState sharedState ].actionManager
3641+ recordMessageImpression: [chainedActionContext messageId ]];
3642+ }
3643+ }];
3644+ });
3645+ };
3646+
36293647 if (messageId && [actionType isEqualToString: LP_VALUE_CHAIN_MESSAGE_ACTION_NAME]) {
36303648 NSDictionary *message = [LPVarCache messages ][messageId];
36313649 if (message) {
3632- LPActionContext *chainedActionContext =
3633- [Leanplum createActionContextForMessageId: messageId];
3634- chainedActionContext.contextualValues = self.contextualValues ;
3635- chainedActionContext->_preventRealtimeUpdating = _preventRealtimeUpdating;
3636- chainedActionContext->_isRooted = _isRooted;
3637- dispatch_async (dispatch_get_main_queue (), ^{
3638- [Leanplum triggerAction: chainedActionContext handledBlock: ^(BOOL success) {
3639- if (success) {
3640- // Track when the chain message is viewed.
3641- [[LPInternalState sharedState ].actionManager
3642- recordMessageImpression: [chainedActionContext messageId ]];
3643- }
3644- }];
3645- });
3650+ executeChainedMessage ();
36463651 return ;
3652+ } else {
3653+ // Message doesn't seem to be on the device,
3654+ // so let's forceContentUpdate and retry showing it.
3655+ [Leanplum forceContentUpdate: ^(void ) {
3656+ NSDictionary *message = [LPVarCache messages ][messageId];
3657+ if (message) {
3658+ executeChainedMessage ();
3659+ }
3660+ }];
36473661 }
36483662 }
36493663
0 commit comments