@@ -495,6 +495,10 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
495
495
496
496
#if !os(OSX) && !os(watchOS)
497
497
@objc private func applicationDidEnterBackground( _ notification: Notification ) {
498
+ performFullBackgroundFlush ( )
499
+ }
500
+
501
+ private func performFullBackgroundFlush( propsToUnregister: InternalProperties ? = nil ) {
498
502
guard let sharedApplication = MixpanelInstance . sharedUIApplication ( ) else {
499
503
return
500
504
}
@@ -506,6 +510,12 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
506
510
let completionHandler : ( ) -> Void = { [ weak self] in
507
511
guard let self = self else { return }
508
512
513
+ if let propsToUnregister {
514
+ for (key, _) in propsToUnregister {
515
+ unregisterSuperProperty ( key)
516
+ }
517
+ }
518
+
509
519
if self . taskId != UIBackgroundTaskIdentifier . invalid {
510
520
sharedApplication. endBackgroundTask ( self . taskId)
511
521
self . taskId = UIBackgroundTaskIdentifier . invalid
@@ -653,11 +663,7 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
653
663
guard let properties = data as? Properties else { return }
654
664
registerSuperProperties ( properties)
655
665
} else {
656
- for (key, _) in data {
657
- if let keyToUnregister = key as? String {
658
- unregisterSuperProperty ( keyToUnregister)
659
- }
660
- }
666
+ performFullBackgroundFlush ( propsToUnregister: data as? InternalProperties )
661
667
}
662
668
}
663
669
}
0 commit comments