Skip to content

Commit 5cdc937

Browse files
release: SDK 3.1.0
1 parent 6b90bf7 commit 5cdc937

File tree

135 files changed

+6880
-7143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+6880
-7143
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let package = Package(
1818
targets: [
1919
.binaryTarget(
2020
name: "Batch",
21-
url: "https://download.batch.com/sdk/ios/spm/BatchSDK-ios_spm-xcframework-3.0.3.zip",
22-
checksum: "65ce974990ec245eb45f6e104affd8291b73bfcb530950f9d2f6d70d9d46d5e5"
21+
url: "https://download.batch.com/sdk/ios/spm/BatchSDK-ios_spm-xcframework-3.1.0.zip",
22+
checksum: "0d18a0de47124835eaee086380a1244eb18e99699d8affee18b3643357091345"
2323
)
2424
]
2525
)

Sources/Batch.xcodeproj/project.pbxproj

Lines changed: 346 additions & 3507 deletions
Large diffs are not rendered by default.

Sources/Batch/BatchMessaging.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ - (id)copyWithZone:(nullable NSZone *)zone {
386386
copy.eventData = [self.eventData copy];
387387
copy.campaignIdentifier = self.campaignIdentifier;
388388
copy.campaignToken = self.campaignToken;
389+
copy.isCEPMessage = self.isCEPMessage;
389390
}
390391

391392
return copy;

Sources/Batch/Kernel/Helpers/BADelegatedApplicationDelegate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ NS_ASSUME_NONNULL_BEGIN
3636
+ (instancetype)sharedInstance;
3737

3838
/*!
39-
@method swizzleAppDelegate:
39+
@method findAndSwizzleAppDelegate:
4040
@abstract Swizzle the current [UIApplication sharedApplication].delegate class. Note that calling this method multiple
4141
times is an error. Make sure to set a `batchDelegate` on this object to be informed of the calls.
4242
@return Whether the operation succeeded
4343
*/
44-
- (BOOL)swizzleAppDelegate;
44+
- (BOOL)findAndSwizzleAppDelegate;
4545

4646
@end
4747

Sources/Batch/Kernel/Helpers/BADelegatedApplicationDelegate.m

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import <Batch/BAPushCenter.h>
1212
#import <objc/runtime.h>
1313

14-
#define DEBUG_SWIZZLE NO
14+
#define DEBUG_SWIZZLE 0
1515

1616
@implementation BADelegatedApplicationDelegate
1717

@@ -34,7 +34,7 @@ - (instancetype)init {
3434
return self;
3535
}
3636

37-
- (BOOL)swizzleAppDelegate {
37+
- (BOOL)findAndSwizzleAppDelegate {
3838
if (!_batchDelegate) {
3939
return false;
4040
}
@@ -50,6 +50,43 @@ - (BOOL)swizzleAppDelegate {
5050
return false;
5151
}
5252

53+
if ([[NSString stringWithFormat:@"SwiftUI.%@", @"AppDelegate"]
54+
isEqualToString:NSStringFromClass(appDelegate.class)]) {
55+
[BALogger debugForDomain:nil message:@"SwiftUI AppDelegate detected, adjusting swizzling"];
56+
// On a SwiftUI lifecycle app, SwiftUI.AppDelegate is always the application delegate
57+
// The SwiftUI class does not respond to the selectors, but implements
58+
// "forwardingTargetForSelector"
59+
// https://developer.apple.com/documentation/objectivec/nsobject-swift.class/forwardingtarget(for:) and returns
60+
// the instance set using @UIApplicationDelegateAdaptor In theory, this is never nil, but you never know how
61+
// Batch is implemented. So, the plan is:
62+
// - If it is nil, swizzle SwiftUI.AppDelegate
63+
// - If it is not nil, swizzle the developer's implementation
64+
if ([appDelegate respondsToSelector:@selector(forwardingTargetForSelector:)]) {
65+
id developerDelegate = [(NSObject *)appDelegate
66+
forwardingTargetForSelector:@selector(application:didRegisterForRemoteNotificationsWithDeviceToken:)];
67+
if (developerDelegate != nil) {
68+
[BALogger
69+
debugForDomain:nil
70+
message:
71+
@"SwiftUI AppDelegate has a UIApplicationDelegateAdaptor, switching swizzling target"];
72+
appDelegate = developerDelegate;
73+
}
74+
} else {
75+
[BALogger debugForDomain:nil
76+
message:@"SwiftUI AppDelegate does not respond to forwardingTargetForSelector. Swizzling "
77+
@"system delegate"];
78+
}
79+
}
80+
81+
if ([self swizzleAppDelegate:appDelegate]) {
82+
_didSwizzle = true;
83+
return true;
84+
} else {
85+
return false;
86+
}
87+
}
88+
89+
- (BOOL)swizzleAppDelegate:(nonnull id<UIApplicationDelegate>)appDelegate {
5390
Class appDelegateClass = [appDelegate class];
5491

5592
if (appDelegateClass == [_batchDelegate class]) {
@@ -70,8 +107,6 @@ - (BOOL)swizzleAppDelegate {
70107
}
71108

72109
[self swizzleMethodsOfDelegate:appDelegate];
73-
74-
_didSwizzle = true;
75110
return true;
76111
}
77112

@@ -92,6 +127,8 @@ - (nullable IMP)swizzleMethod:(nonnull SEL)selector
92127

93128
#if DEBUG_SWIZZLE
94129
NSLog(@"Swizzling %@", selectorString);
130+
NSLog(@"Swizzled class responds to selector %@ ? %@", NSStringFromSelector(selector),
131+
[targetClass instancesRespondToSelector:selector] ? @"YES" : @"NO");
95132
#endif
96133

97134
// If the class instance doesn't implement a selector and
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Batch
3+
//
4+
// Copyright © Batch.com. All rights reserved.
5+
//
6+
7+
#import <Foundation/Foundation.h>
8+
9+
@interface BADictionaryHelper : NSObject
10+
11+
+ (BOOL)dictionary:(NSDictionary *)actual containsValuesFromDictionary:(NSDictionary *)expected;
12+
13+
+ (BOOL)array:(NSArray *)actual containsValuesFromArray:(NSArray *)expected;
14+
15+
@end
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//
2+
// Batch
3+
//
4+
// Copyright © Batch.com. All rights reserved.
5+
//
6+
#import <Batch/BADictionaryHelper.h>
7+
#import <Foundation/Foundation.h>
8+
9+
@implementation BADictionaryHelper
10+
11+
+ (BOOL)dictionary:(NSDictionary *)actual containsValuesFromDictionary:(NSDictionary *)expected {
12+
if (expected == nil) {
13+
return actual == nil;
14+
}
15+
16+
if (actual == expected) {
17+
return YES;
18+
}
19+
20+
if (actual == nil) {
21+
return NO;
22+
}
23+
24+
for (NSString *key in expected.allKeys) {
25+
if (!actual[key]) {
26+
return NO;
27+
}
28+
29+
id expectedValue = expected[key];
30+
id actualValue = actual[key];
31+
32+
if ([expectedValue isKindOfClass:[NSDictionary class]] && [actualValue isKindOfClass:[NSDictionary class]]) {
33+
if (![self dictionary:actualValue containsValuesFromDictionary:expectedValue]) {
34+
return NO;
35+
}
36+
} else if ([expectedValue isKindOfClass:[NSArray class]] && [actualValue isKindOfClass:[NSArray class]]) {
37+
if (![self array:actualValue containsValuesFromArray:expectedValue]) {
38+
return NO;
39+
}
40+
} else if (![expectedValue isEqual:actualValue]) {
41+
return NO;
42+
}
43+
}
44+
return YES;
45+
}
46+
47+
+ (BOOL)array:(NSArray *)actual containsValuesFromArray:(NSArray *)expected {
48+
if (expected == nil) {
49+
return actual == nil;
50+
}
51+
52+
if (actual == nil) {
53+
return NO;
54+
}
55+
56+
if (expected.count > actual.count) {
57+
return NO;
58+
}
59+
60+
NSMutableArray *actualList = [actual mutableCopy];
61+
62+
for (id expectedValue in expected) {
63+
BOOL found = NO;
64+
for (int j = 0; j < actualList.count; j++) {
65+
id actualValue = actualList[j];
66+
if ([expectedValue isKindOfClass:[NSDictionary class]] &&
67+
[actualValue isKindOfClass:[NSDictionary class]]) {
68+
if ([self dictionary:actualValue containsValuesFromDictionary:expectedValue]) {
69+
[actualList removeObjectAtIndex:j];
70+
found = YES;
71+
break;
72+
}
73+
} else if ([expectedValue isKindOfClass:[NSArray class]] && [actualValue isKindOfClass:[NSArray class]]) {
74+
if ([self array:actualValue containsValuesFromArray:expectedValue]) {
75+
[actualList removeObjectAtIndex:j];
76+
found = YES;
77+
break;
78+
}
79+
} else if ([expectedValue isEqual:actualValue]) {
80+
[actualList removeObjectAtIndex:j];
81+
found = YES;
82+
break;
83+
}
84+
}
85+
if (!found) {
86+
return NO;
87+
}
88+
}
89+
return YES;
90+
}
91+
92+
@end

Sources/Batch/Kernel/Xson/BATJsonDictionary.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

Sources/Batch/Kernel/Xson/BATJsonDictionary.m

Lines changed: 0 additions & 68 deletions
This file was deleted.

Sources/Batch/Modules/BAUserDataEnums.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)