appcues / appcues-ios-sdk

The Appcues iOS SDK
https://www.appcues.com/mobile
MIT License
8 stars 2 forks source link

Fix AppcuesExperienceDelegate for embeds #507

Closed mmaatttt closed 6 months ago

mmaatttt commented 6 months ago

Only experienceWillDisappear() was working properly.

experienceWillAppear() and experienceDidAppear() weren't being called because we were only checking isBeingPresented (which works for modals/tooltips) and not also isMovingToParent. I cleaned all the checks up with a simpler extension.

experienceDidDisappear() wasn't working because the state machine reaches the .idling state before containerDidDisappear gets called. This is essentially because the completion() for the dismisser of the embed gets called too early. There's nothing logically wrong with where it's called, but DispatchQueue.main.async fixes it. Alternatively, I could've added a case for .idling in containerDidDisappear but that could have wider ranging side effects an would be specific to embeds, which is the sort of code we've tried to avoid in the state machine.