File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
Leanplum-SDK/Classes/Notifications/Push Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,20 @@ - (void) test_receive_notification
105105
106106 // test when UNUserNotificationCenter.currentNotificationCenter.delegate is nil
107107 UNUserNotificationCenter .currentNotificationCenter .delegate = nil ;
108- [handler didReceiveRemoteNotification: userInfo
108+
109+ // Requires Leanplum Start
110+ // didReceiveRemoteNotification: UIApplicationState is Active -> calls handleNotification -> runs onContent on startIssued callback
111+ if (!Leanplum.hasStarted ){
112+ XCTAssertTrue ([LeanplumHelper start_production_test ]);
113+ }
114+
115+ // Change messageId so it is not a duplicate notification
116+ NSDictionary * userInfo2 = @{
117+ @" _lpm" : @" messageId_2" ,
118+ @" _lpx" : @" test_action" ,
119+ @" aps" : @{@" alert" : @" test" }};
120+
121+ [handler didReceiveRemoteNotification: userInfo2
109122 withAction: @" test_action"
110123 fetchCompletionHandler: ^(LeanplumUIBackgroundFetchResult result) {
111124 [applicationNotificationExpectation fulfill ];
Original file line number Diff line number Diff line change @@ -230,6 +230,10 @@ - (void)handleNotification:(NSDictionary *)userInfo
230230 return ;
231231 }
232232
233+ if ([self isDuplicateNotification: userInfo]) {
234+ return ;
235+ }
236+
233237 void (^onContent)(void ) = ^{
234238 if (completionHandler) {
235239 completionHandler (UIBackgroundFetchResultNewData);
@@ -266,11 +270,6 @@ - (void)maybePerformNotificationActions:(NSDictionary *)userInfo
266270 action : (NSString *)action
267271 active : (BOOL )active
268272{
269- // Do not perform the action if the app is in background
270- if (UIApplication.sharedApplication .applicationState == UIApplicationStateBackground) {
271- return ;
272- }
273-
274273 // Don't handle duplicate notifications.
275274 if ([self isDuplicateNotification: userInfo]) {
276275 return ;
You can’t perform that action at this time.
0 commit comments