Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-274] Fix open notification #432

Merged
merged 3 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Example/Tests/Classes/LPPushNotificationsHandlerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,20 @@ - (void) test_receive_notification

//test when UNUserNotificationCenter.currentNotificationCenter.delegate is nil
UNUserNotificationCenter.currentNotificationCenter.delegate = nil;
[handler didReceiveRemoteNotification:userInfo

// Requires Leanplum Start
// didReceiveRemoteNotification: UIApplicationState is Active -> calls handleNotification -> runs onContent on startIssued callback
if (!Leanplum.hasStarted){
XCTAssertTrue([LeanplumHelper start_production_test]);
}

// Change messageId so it is not a duplicate notification
NSDictionary* userInfo2 = @{
@"_lpm": @"messageId_2",
@"_lpx": @"test_action",
@"aps" : @{@"alert": @"test"}};

[handler didReceiveRemoteNotification:userInfo2
withAction:@"test_action"
fetchCompletionHandler: ^(LeanplumUIBackgroundFetchResult result) {
[applicationNotificationExpectation fulfill];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ - (void)handleNotification:(NSDictionary *)userInfo
return;
}

if ([self isDuplicateNotification:userInfo]) {
return;
}

void (^onContent)(void) = ^{
if (completionHandler) {
completionHandler(UIBackgroundFetchResultNewData);
Expand Down Expand Up @@ -266,11 +270,6 @@ - (void)maybePerformNotificationActions:(NSDictionary *)userInfo
action:(NSString *)action
active:(BOOL)active
{
// Do not perform the action if the app is in background
if (UIApplication.sharedApplication.applicationState == UIApplicationStateBackground) {
return;
}

// Don't handle duplicate notifications.
if ([self isDuplicateNotification:userInfo]) {
return;
Expand Down