appcues / appcues-ios-sdk

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

Update push auto config to be static #528

Closed mmaatttt closed 4 months ago

mmaatttt commented 4 months ago

This is a tweak targeting #526 in its own PR for readability. I've made the swizzling automatic push config static on Appcues for a couple reasons:

  1. Swizzling affects the whole app, not just the instance. So in the theoretical multiple Appcues instance app, it'd be very strange to suggest that you could automatically configure one instance but not the other.
  2. A static config option better sets us up for x-plat success. More here, but since the x-plat libraries create the Appcues instance on-demand, that may be too late for the config necessary in didFinishLaunching.

The static observer list pattern I've added means that,

  1. If an Appcues instance is created before the push auto config, then it's already in the observer list for when the swizzled methods start getting called, and
  2. If the auto config is done, and then a new Appcues instant is created, the instance will add itself to the observer list and start receiving any push events from that point forward.