@@ -259,6 +259,8 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
259259#if os(iOS) || os(tvOS) || os(visionOS)
260260 let automaticEvents = AutomaticEvents ( )
261261#endif
262+ private let registerSuperPropertiesNotificationName = Notification . Name ( " com.mixpanel.properties.register " )
263+ private let unregisterSuperPropertiesNotificationName = Notification . Name ( " com.mixpanel.properties.unregister " )
262264
263265 convenience init (
264266 apiToken: String ? ,
@@ -421,6 +423,18 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
421423 selector: #selector( applicationWillEnterForeground ( _: ) ) ,
422424 name: UIApplication . willEnterForegroundNotification,
423425 object: nil )
426+ notificationCenter. addObserver (
427+ self ,
428+ selector: #selector( handleSuperPropertiesRegistrationNotification ( _: ) ) ,
429+ name: registerSuperPropertiesNotificationName,
430+ object: nil
431+ )
432+ notificationCenter. addObserver (
433+ self ,
434+ selector: #selector( handleSuperPropertiesRegistrationNotification ( _: ) ) ,
435+ name: unregisterSuperPropertiesNotificationName,
436+ object: nil
437+ )
424438 }
425439 }
426440#elseif os(OSX)
@@ -632,6 +646,20 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
632646#endif
633647#endif // os(iOS)
634648
649+ @objc func handleSuperPropertiesRegistrationNotification( _ notification: Notification ) {
650+ guard let data = notification. userInfo else { return }
651+
652+ if notification. name. rawValue == registerSuperPropertiesNotificationName. rawValue {
653+ guard let properties = data as? Properties else { return }
654+ registerSuperProperties ( properties)
655+ } else {
656+ for (key, _) in data {
657+ if let keyToUnregister = key as? String {
658+ unregisterSuperProperty ( keyToUnregister)
659+ }
660+ }
661+ }
662+ }
635663}
636664
637665extension MixpanelInstance {
0 commit comments