Skip to content

Commit 6d18f0f

Browse files
authored
CleverTap Push fixes (#569)
* Fix isEqualToHandledNotification for CT push * CleverTap open deeplinks on push open
1 parent 6621132 commit 6d18f0f

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Leanplum
44
//
55
// Created by Andrew First on 4/30/12.
6-
// Copyright (c) 2022 Leanplum, Inc. All rights reserved.
6+
// Copyright (c) 2023 Leanplum, Inc. All rights reserved.
77
//
88
// Licensed to the Apache Software Foundation (ASF) under one
99
// or more contributor license agreements. See the NOTICE file
@@ -1625,7 +1625,8 @@ + (void)setShouldOpenNotificationHandler:(LeanplumShouldHandleNotificationBlock)
16251625
+ (void)setCleverTapOpenDeepLinksInForeground:(BOOL)openDeepLinksInForeground
16261626
{
16271627
LPCTNotificationsManager *manager = (LPCTNotificationsManager *)[Leanplum notificationsManager];
1628-
[manager setOpenDeepLinksInForeground:openDeepLinksInForeground];
1628+
NSNumber *value = [NSNumber numberWithBool:openDeepLinksInForeground];
1629+
[manager setOpenDeepLinksInForeground:value];
16291630
}
16301631

16311632
+ (void)setHandleCleverTapNotification:(_Nullable LeanplumHandleCleverTapNotificationBlock)block

LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/LPCTNotificationsManager.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
// LeanplumSDK
44
//
55
// Created by Nikola Zagorchev on 12.10.22.
6-
// Copyright © 2022 Leanplum. All rights reserved.
6+
// Copyright © 2023 Leanplum. All rights reserved.
77

88
import Foundation
99
// Use @_implementationOnly to *not* expose CleverTapSDK to the Leanplum-Swift header
1010
@_implementationOnly import CleverTapSDK
1111

1212
@objc public class LPCTNotificationsManager: NotificationsManager {
13-
@objc public var openDeepLinksInForeground = false
13+
// Using NSNumber since Optional Bool cannot be represented in Objective-C
14+
@objc public var openDeepLinksInForeground: NSNumber?
1415
@objc public var handleCleverTapNotificationBlock: LeanplumHandleCleverTapNotificationBlock?
1516

1617

@@ -74,7 +75,8 @@ import Foundation
7475
return
7576
}
7677

77-
handleNotification(openDeepLinksInForeground)
78+
// If `openDeepLinksInForeground` is not set explicitly, use `true` for notification Opens.
79+
handleNotification(openDeepLinksInForeground?.boolValue ?? (event == .opened))
7880
}
7981

8082
@objc public func handleWithCleverTapInstance(action: @escaping () -> ()) {

LeanplumSDK/LeanplumSDK/ClassesSwift/Notifications/Proxy/NotificationsProxy+Utilities.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// LeanplumSDK
44
//
55
// Created by Nikola Zagorchev on 23.12.21.
6-
// Copyright © 2021 Leanplum. All rights reserved.
6+
// Copyright © 2023 Leanplum. All rights reserved.
77

88
import Foundation
99

@@ -13,7 +13,8 @@ extension NotificationsProxy {
1313
if let fromStart = notificationHandledFromStart {
1414
let idA = Leanplum.notificationsManager().getNotificationId(fromStart)
1515
let idB = Leanplum.notificationsManager().getNotificationId(userInfo)
16-
return idA == idB
16+
// CleverTap notifications do not have notification Id
17+
return idA == idB && idA != "-1"
1718
}
1819
return false
1920
}

0 commit comments

Comments
 (0)