Skip to content

Commit 2c9f0aa

Browse files
authored
CT Push notification improvements (#565)
1 parent 139ebfc commit 2c9f0aa

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

LeanplumSDK/LeanplumSDK/Classes/Internal/Leanplum.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,13 +1628,8 @@ + (void)setCleverTapOpenDeepLinksInForeground:(BOOL)openDeepLinksInForeground
16281628
[manager setOpenDeepLinksInForeground:openDeepLinksInForeground];
16291629
}
16301630

1631-
+ (void)setHandleCleverTapNotification:(LeanplumHandleCleverTapNotificationBlock)block
1631+
+ (void)setHandleCleverTapNotification:(_Nullable LeanplumHandleCleverTapNotificationBlock)block
16321632
{
1633-
if (!block) {
1634-
[self throwError:@"[Leanplum setHandleCleverTapNotification:] Nil block parameter "
1635-
@"provided."];
1636-
return;
1637-
}
16381633
LP_TRY
16391634
((LPCTNotificationsManager *)[Leanplum notificationsManager]).handleCleverTapNotificationBlock = block;
16401635
LP_END_TRY

LeanplumSDK/LeanplumSDK/Classes/Leanplum.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ typedef void (^LeanplumSetLocationBlock)(BOOL success);
145145
typedef BOOL (^LeanplumActionBlock)(LPActionContext* context);
146146
typedef void (^LeanplumHandleNotificationBlock)(void);
147147
typedef void (^LeanplumShouldHandleNotificationBlock)(NSDictionary *userInfo, LeanplumHandleNotificationBlock response);
148+
typedef void (^LeanplumCleverTapNotificationBlock)(BOOL openDeeplink);
148149
typedef void (^LeanplumHandleCleverTapNotificationBlock)(NSDictionary *userInfo,
149150
BOOL isNotificationOpen,
150-
LeanplumHandleNotificationBlock response);
151+
LeanplumCleverTapNotificationBlock response);
151152
typedef void (^LeanplumPushSetupBlock)(void);
152153
/**@}*/
153154

@@ -453,7 +454,7 @@ NS_SWIFT_NAME(defineAction(name:kind:args:options:present:dismiss:));
453454
* The block provides the notification userInfo, a bool if the push is received or opened, and a block with the default implementation.
454455
* @see LeanplumHandleCleverTapNotificationBlock for details.
455456
*/
456-
+ (void)setHandleCleverTapNotification:(LeanplumHandleCleverTapNotificationBlock)block;
457+
+ (void)setHandleCleverTapNotification:(_Nullable LeanplumHandleCleverTapNotificationBlock)block;
457458

458459
/**
459460
* Sets if a Deliver event should be tracked when a Push Notification is received.

LeanplumSDK/LeanplumSDK/ClassesSwift/Migration/LPCTNotificationsManager.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ import Foundation
5757
}
5858

5959
func handleCleverTapNotification(userInfo: [AnyHashable : Any], event: NotificationEvent) {
60-
let handleNotification = {
61-
let openInForeground = self.openDeepLinksInForeground
60+
let handleNotification:LeanplumCleverTapNotificationBlock = { openInForeground in
6261
self.handleWithCleverTapInstance {
6362
Log.info("""
6463
[Wrapper] Calling CleverTap.handlePushNotification:openDeepLinksInForeground: \
@@ -75,10 +74,10 @@ import Foundation
7574
return
7675
}
7776

78-
handleNotification()
77+
handleNotification(openDeepLinksInForeground)
7978
}
8079

81-
func handleWithCleverTapInstance(action: @escaping () -> ()) {
80+
@objc public func handleWithCleverTapInstance(action: @escaping () -> ()) {
8281
if MigrationManager.shared.hasLaunched {
8382
action()
8483
} else {

0 commit comments

Comments
 (0)