File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,8 @@ - (void)handleAppStateNotification:(NSNotification *)note
111
111
[self _applicationDidFinishLaunchingWithOptions: note.userInfo];
112
112
} else if ([note.name isEqualToString: UIApplicationWillEnterForegroundNotification]) {
113
113
[self _applicationWillEnterForeground ];
114
+ } else if ([note.name isEqualToString: UIApplicationDidEnterBackgroundNotification]) {
115
+ [self _applicationDidEnterBackground ];
114
116
}
115
117
}
116
118
@@ -167,15 +169,19 @@ - (void)_applicationWillEnterForeground
167
169
if (!self.configuration .trackApplicationLifecycleEvents ) {
168
170
return ;
169
171
}
170
- NSString *currentVersion = [[NSBundle mainBundle ] infoDictionary ][@" CFBundleShortVersionString" ];
171
- NSString *currentBuild = [[NSBundle mainBundle ] infoDictionary ][@" CFBundleVersion" ];
172
172
[self track: @" Application Opened" properties: @{
173
173
@" from_background" : @YES ,
174
- @" version" : currentVersion ?: @" " ,
175
- @" build" : currentBuild ?: @" " ,
176
174
}];
177
175
}
178
176
177
+ - (void )_applicationDidEnterBackground
178
+ {
179
+ if (!self.configuration .trackApplicationLifecycleEvents ) {
180
+ return ;
181
+ }
182
+ [self track: @" Application Backgrounded" ];
183
+ }
184
+
179
185
180
186
#pragma mark - Public API
181
187
Original file line number Diff line number Diff line change @@ -102,6 +102,13 @@ class AnalyticsTests: QuickSpec {
102
102
expect ( event? . event) == " Application Opened "
103
103
expect ( event? . properties ? [ " from_background " ] as? Bool ) == true
104
104
}
105
+
106
+ it ( " fires Application Backgrounded during UIApplicationDidEnterBackground " ) {
107
+ testMiddleware. swallowEvent = true
108
+ NotificationCenter . default. post ( name: . UIApplicationDidEnterBackground, object: testApplication)
109
+ let event = testMiddleware. lastContext? . payload as? SEGTrackPayload
110
+ expect ( event? . event) == " Application Backgrounded "
111
+ }
105
112
106
113
it ( " flushes when UIApplicationDidEnterBackgroundNotification is fired " ) {
107
114
analytics. track ( " test " )
Original file line number Diff line number Diff line change 1
1
target 'AnalyticsTests' do
2
2
platform :ios , '11'
3
-
3
+
4
4
use_frameworks!
5
-
5
+
6
6
pod 'Quick' , '~> 1.2.0'
7
7
pod 'Nimble' , '~> 7.3.4'
8
8
pod 'Nocilla' , '~> 0.11.0'
You can’t perform that action at this time.
0 commit comments