From d8205751d0de9c2deb5ab06f1eba304fa6fb9ea4 Mon Sep 17 00:00:00 2001 From: Nikola Zagorchev Date: Fri, 14 Jul 2023 19:01:07 +0300 Subject: [PATCH 1/2] Fix isEqualToHandledNotification for CT push --- .../Notifications/Proxy/NotificationsProxy+Utilities.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LeanplumSDK/LeanplumSDK/ClassesSwift/Notifications/Proxy/NotificationsProxy+Utilities.swift b/LeanplumSDK/LeanplumSDK/ClassesSwift/Notifications/Proxy/NotificationsProxy+Utilities.swift index fcade151..d658046d 100644 --- a/LeanplumSDK/LeanplumSDK/ClassesSwift/Notifications/Proxy/NotificationsProxy+Utilities.swift +++ b/LeanplumSDK/LeanplumSDK/ClassesSwift/Notifications/Proxy/NotificationsProxy+Utilities.swift @@ -3,7 +3,7 @@ // LeanplumSDK // // Created by Nikola Zagorchev on 23.12.21. -// Copyright © 2021 Leanplum. All rights reserved. +// Copyright © 2023 Leanplum. All rights reserved. import Foundation @@ -13,7 +13,8 @@ extension NotificationsProxy { if let fromStart = notificationHandledFromStart { let idA = Leanplum.notificationsManager().getNotificationId(fromStart) let idB = Leanplum.notificationsManager().getNotificationId(userInfo) - return idA == idB + // CleverTap notifications do not have notification Id + return idA == idB && idA != "-1" } return false } From 62c38176f4074cd46aae7d8d1aa98f27f488ad16 Mon Sep 17 00:00:00 2001 From: Nikola Zagorchev Date: Tue, 18 Jul 2023 20:58:14 +0300 Subject: [PATCH 2/2] CleverTap open deeplinks on push open --- LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m | 5 +++-- .../ClassesSwift/Migration/LPCTNotificationsManager.swift | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m b/LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m index 2b4de69b..6914a8a6 100644 --- a/LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m +++ b/LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m @@ -3,7 +3,7 @@ // Leanplum // // Created by Andrew First on 4/30/12. -// Copyright (c) 2022 Leanplum, Inc. All rights reserved. +// Copyright (c) 2023 Leanplum, Inc. All rights reserved. // // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file @@ -1625,7 +1625,8 @@ + (void)setShouldOpenNotificationHandler:(LeanplumShouldHandleNotificationBlock) + (void)setCleverTapOpenDeepLinksInForeground:(BOOL)openDeepLinksInForeground { LPCTNotificationsManager *manager = (LPCTNotificationsManager *)[Leanplum notificationsManager]; - [manager setOpenDeepLinksInForeground:openDeepLinksInForeground]; + NSNumber *value = [NSNumber numberWithBool:openDeepLinksInForeground]; + [manager setOpenDeepLinksInForeground:value]; } + (void)setHandleCleverTapNotification:(_Nullable LeanplumHandleCleverTapNotificationBlock)block diff --git a/LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/LPCTNotificationsManager.swift b/LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/LPCTNotificationsManager.swift index 0055cce5..1d0ec989 100644 --- a/LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/LPCTNotificationsManager.swift +++ b/LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/LPCTNotificationsManager.swift @@ -3,14 +3,15 @@ // LeanplumSDK // // Created by Nikola Zagorchev on 12.10.22. -// Copyright © 2022 Leanplum. All rights reserved. +// Copyright © 2023 Leanplum. All rights reserved. import Foundation // Use @_implementationOnly to *not* expose CleverTapSDK to the Leanplum-Swift header @_implementationOnly import CleverTapSDK @objc public class LPCTNotificationsManager: NotificationsManager { - @objc public var openDeepLinksInForeground = false + // Using NSNumber since Optional Bool cannot be represented in Objective-C + @objc public var openDeepLinksInForeground: NSNumber? @objc public var handleCleverTapNotificationBlock: LeanplumHandleCleverTapNotificationBlock? @@ -74,7 +75,8 @@ import Foundation return } - handleNotification(openDeepLinksInForeground) + // If `openDeepLinksInForeground` is not set explicitly, use `true` for notification Opens. + handleNotification(openDeepLinksInForeground?.boolValue ?? (event == .opened)) } @objc public func handleWithCleverTapInstance(action: @escaping () -> ()) {