Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing redisplaying for dynamic trigger IAMs #745

Merged
merged 6 commits into from Sep 30, 2020

Conversation

emawby
Copy link
Contributor

@emawby emawby commented Sep 19, 2020

This PR allows IAMs with only dynamic triggers to be redisplayed by setting message.isTriggerChanged = YES; when the trigger fires. Additionally evaluateMessages now evaluates message triggers before setting redisplay data

This change is Reviewable

@emawby emawby force-pushed the fix/redisplay_session_duration branch from ad8af10 to b34e530 Compare September 19, 2020 00:46
#pragma mark OSTriggerControllerDelegate Methods
- (void)triggerConditionChanged:(NSString *)triggerId {
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"trigger condition changed for triggerId: %@", triggerId]];
[self makeRedisplayMessagesAvailableWithTriggers:@[triggerId]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this line needed? on Android, we are only depending on dynamicTriggerCompleted, on the case the dynamic trigger is scheduled then ti will call triggerConditionChanged and dynamicTriggerCompleted, dynamicTriggerCompleted will override triggerConditionChanged changes

Copy link
Contributor Author

@emawby emawby Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this delegate method but I needed to add redisplayEnabled to the initWithCoder methods. Otherwise it hthinks redisplayEnabled is false

[self makeRedisplayMessagesAvailableWithTriggers:@[triggerId]];
}

- (void)makeRedisplayMessagesAvailableWithTriggers:(NSArray<NSString *> *)triggerIds {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic is deferring a bit from Android, do we want to come with a common logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After working on it I think that not duplicating the state in the redisplayedMessages might be better what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that can be confusing having 2 different lists, although I see that having the redisplay messages separated can optimize the iteration. Because on worst case redisplay list will be the same length as the iam list, but in the best case redisplay iams will be empty. But is also true that there are not huge lists, or they shouldn't be, so there is not that much impact on the performance. So if you see that is more readable to only iterate iams list then I'm ok with removing the redisplay iteration for trigger change check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right I think having it more readable and not trying to synchronize the state is the better approach here. Sorry for making you implement it in the first place!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok agree then, will make the change under major release branch

iOS_SDK/OneSignalSDK/Source/OneSignal.m Show resolved Hide resolved
@jkasten2
Copy link
Member

There is a bug on master this PR also happens to address

  1. IAM with one custom trigger
  2. "Every time trigger conditions are satisfied" select
  3. IAM shown the first time with addTrigger
  4. And again if addTrigger is called again with the same key and value as expected
  5. Background the app then foreground the app
  6. Call addTrigger again but issues is it won't display again.

@emawby emawby merged commit e0d98fc into master Sep 30, 2020
@jkasten2 jkasten2 mentioned this pull request Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants