Skip to content

Commit 04ebab0

Browse files
Fixes CT push notification handled twice when app is using AppDelegate only. (#591)
1 parent f5e4384 commit 04ebab0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/LPCTNotificationsManager.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Foundation
1313
// Using NSNumber since Optional Bool cannot be represented in Objective-C
1414
@objc public var openDeepLinksInForeground: NSNumber?
1515
@objc public var handleCleverTapNotificationBlock: LeanplumHandleCleverTapNotificationBlock?
16-
16+
private(set) var handlePushNotificationFromCleverTap = false
1717

1818
enum NotificationEvent: String, CustomStringConvertible {
1919
case opened = "Open"
@@ -33,6 +33,16 @@ import Foundation
3333
// If the app is launched from notification and CT instance has already been created,
3434
// CT will handle the notification from their UIApplication didFinishLaunchingNotification observer
3535
if fromLaunch && MigrationManager.shared.hasLaunched {
36+
// If the app is using AppDelegate only, push notification at app launched will
37+
// be handled from CleverTap. Setting `handlePushNotificationFromCleverTap` to true
38+
// here ensures that app is launched from killed state and using AppDelegate file only.
39+
handlePushNotificationFromCleverTap = true
40+
return
41+
}
42+
43+
if handlePushNotificationFromCleverTap && MigrationManager.shared.hasLaunched {
44+
Log.info("[Wrapper] Push Notification will be handled from CleverTap: \(userInfo)")
45+
handlePushNotificationFromCleverTap = false
3646
return
3747
}
3848

0 commit comments

Comments
 (0)