appcues / appcues-ios-sdk

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

Ensure latest device prop values are always sent #545

Closed mmaatttt closed 2 months ago

mmaatttt commented 2 months ago

James noted a while back that there can be a race where pushEnabled is read and sent to the backend at startup before the correct value can be determined.

To fix this, we want to make sure the initial request for the permission status will send a device updated event if the value is different than the one that was used. This initial request was the only place with a false argument like refreshPushStatus(publishChange: false).

So I've removed the publishChange parameter in favour of calculating a shouldPublish property that confirms that the value has changed AND (new) that there's an active session (this means that the previous value was used).

I've also added the same check to setPushToken so we're not triggering device update events with an unchanged push token value.