la-haus / flutter-segment

Segment.io library for flutter
MIT License
22 stars 140 forks source link

Fix for iOS Application Installed event #56

Closed b099l3 closed 2 years ago

b099l3 commented 2 years ago

Context

This PR is a workaround fix for the Application Installed events not firing when setting the config via dart and not via a file (info.plist), issue #26.

Fix Details:

Due to the method sequence and the way the native library works, described here, we need to either call the dart code Segment.config() in didFinishLaunchingWithOptions(), similar to how the configFromFile works or send the Application Installed event when we call the dart code Segment.config().

As I dont think there is an easy way to call Segment.config() in the native code didFinishLaunchingWithOptions(), I have instead opted to add a similar method to the way the native code works when sending Application Installed / Application Updated events, this code is here.

This will make use of the same NSUserDefaults keys as the native library and manually send the events.

This maybe isn't the best way to explain this fix so happy to chat. Also keep up the good work 💙.

b099l3 commented 2 years ago

I have tested this and can see the events being fired

image