Skip to content

Commit cfb7a1d

Browse files
committed
chore: remove old arch support ios
1 parent 95c76b8 commit cfb7a1d

12 files changed

+52
-417
lines changed

example/ios/Podfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ load "/tmp/override_cio_sdk.rb"
66
# end of internal Customer.io testing code
77
# -------------
88

9-
# Uncomment the next line to disable react-native's new architecture.
10-
# ENV['RCT_NEW_ARCH_ENABLED'] = '0'
119
# Resolve react_native_pods.rb with node to allow for hoisting
1210
require Pod::Executable.execute_command("node", ["-p",
1311
'require.resolve(

example/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ios/wrappers/NativeCustomerIO.mm

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#import "utils/RCTCustomerIOUtils.h"
22
#import <React/RCTBridgeModule.h>
3-
4-
#ifdef RCT_NEW_ARCH_ENABLED
5-
63
#import <RNCustomerIOSpec/RNCustomerIOSpec.h>
74

85
// Objective-C wrapper for new architecture TurboModule implementation
@@ -101,34 +98,3 @@ - (void)deleteDeviceToken {
10198
Class<RCTBridgeModule> NativeCustomerIOCls(void) { return RCTNativeCustomerIO.class; }
10299

103100
@end
104-
105-
#else
106-
107-
// Old Architecture: Bridge methods exposed via RCT_EXTERN macros
108-
// Maps to Swift implementation without TurboModule overhead
109-
110-
@interface RCT_EXTERN_REMAP_MODULE (NativeCustomerIO, NativeCustomerIO, NSObject)
111-
112-
RCT_EXTERN_METHOD(initialize
113-
: (NSDictionary *)config args
114-
: (NSDictionary *)args resolve
115-
: (RCTPromiseResolveBlock)resolve reject
116-
: (RCTPromiseRejectBlock)reject)
117-
RCT_EXTERN_METHOD(identify : (NSDictionary *)params)
118-
RCT_EXTERN_METHOD(clearIdentify)
119-
RCT_EXTERN_METHOD(track : (NSString *)name properties : (NSDictionary *)properties)
120-
RCT_EXTERN_METHOD(screen : (NSString *)title properties : (NSDictionary *)properties)
121-
RCT_EXTERN_METHOD(setProfileAttributes : (NSDictionary *)attributes)
122-
RCT_EXTERN_METHOD(setDeviceAttributes : (NSDictionary *)attributes)
123-
RCT_EXTERN_METHOD(registerDeviceToken : (NSString *)token)
124-
RCT_EXTERN_METHOD(trackMetric : (NSString *)deliveryID deviceToken : (NSString *)deviceToken event : (NSString *)event)
125-
RCT_EXTERN_METHOD(deleteDeviceToken)
126-
127-
// Module initialization can happen on background thread
128-
+ (BOOL)requiresMainQueueSetup {
129-
return NO;
130-
}
131-
132-
@end
133-
134-
#endif

ios/wrappers/NativeCustomerIO.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ public class NativeCustomerIO: NSObject {
111111
@objc
112112
func setProfileAttributes(_ attributes: [String: Any]) {
113113
guard ensureInitialized() else { return }
114-
CustomerIO.shared.profileAttributes = attributes
114+
CustomerIO.shared.setProfileAttributes(attributes)
115115
}
116116

117117
@objc
118118
func setDeviceAttributes(_ attributes: [String: Any]) {
119119
guard ensureInitialized() else { return }
120-
CustomerIO.shared.deviceAttributes = attributes
120+
CustomerIO.shared.setDeviceAttributes(attributes)
121121
}
122122

123123
@objc

ios/wrappers/inapp/NativeMessagingInApp.mm

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#import <React/RCTEventEmitter.h>
44
#import <React/RCTInitializing.h>
55
#import <React/RCTInvalidating.h>
6-
7-
#ifdef RCT_NEW_ARCH_ENABLED
8-
96
#import <RNCustomerIOSpec/RNCustomerIOSpec.h>
107

118
// Protocol that extends the spec with setEventEmitter method
@@ -24,13 +21,11 @@ @implementation RCTNativeMessagingInApp
2421

2522
RCT_EXPORT_MODULE()
2623

27-
#ifdef RCT_NEW_ARCH_ENABLED
2824
// Create TurboModule instance for new architecture JSI integration
2925
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
3026
(const facebook::react::ObjCTurboModule::InitParams &)params {
3127
return std::make_shared<facebook::react::NativeCustomerIOMessagingInAppSpecJSI>(params);
3228
}
33-
#endif
3429

3530
// Validates Swift bridge is available before method calls
3631
- (void)assertBridgeAvailable:(NSString *)context {
@@ -89,23 +84,3 @@ - (void)emitOnInAppEventReceived:(NSDictionary *)value {
8984
}
9085

9186
@end
92-
93-
#else
94-
95-
// Old Architecture: Bridge methods exposed via RCT_EXTERN macros
96-
// Maps to Swift implementation without TurboModule overhead
97-
98-
@interface RCT_EXTERN_REMAP_MODULE (NativeCustomerIOMessagingInApp, NativeMessagingInAppLegacy,
99-
RCTEventEmitter)
100-
101-
RCT_EXTERN_METHOD(supportedEvents)
102-
RCT_EXTERN_METHOD(dismissMessage)
103-
104-
// Module initialization can happen on background thread
105-
+ (BOOL)requiresMainQueueSetup {
106-
return NO;
107-
}
108-
109-
@end
110-
111-
#endif

ios/wrappers/inapp/NativeMessagingInApp.swift

Lines changed: 21 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,13 @@ import CioMessagingInApp
22
import Foundation
33
import React
44

5-
// Core in-app messaging implementation shared between new and old architecture
6-
class NativeMessagingInAppImplementation {
7-
private let inAppEventCallback: (_ body: [String: Any]) -> Void
8-
9-
init(inAppEventCallback: @escaping (_ body: [String: Any]) -> Void) {
10-
self.inAppEventCallback = inAppEventCallback
11-
}
12-
13-
// Initialize in-app event listener - called by React Native
14-
func initialize() {
15-
ReactInAppEventListener.shared.setEventEmitter { [weak self] data in
16-
guard let self else { return }
17-
18-
// Filter out nil values to convert [String: Any?] to [String: Any]
19-
let body = data.compactMapValues { $0 }
20-
inAppEventCallback(body)
21-
}
22-
// If MessagingInApp module has already been initialized, this sets the listener directly.
23-
// If this method is called early, accessing ReactInAppEventListener.shared will also register
24-
// it into the DI graph, making it available for access in Expo during auto-initialization.
25-
MessagingInApp.shared.setEventListener(ReactInAppEventListener.shared)
26-
}
27-
28-
// Clears the in-app event listener to prevent leaks when module is deallocated or invalidated
29-
func clearInAppEventListener() {
30-
ReactInAppEventListener.shared.clearEventEmitter()
31-
}
32-
33-
// Clear in-app event listener to prevent leaks
34-
func invalidate() {
35-
clearInAppEventListener()
36-
}
37-
}
38-
395
// In-app messaging module for new React Native architecture (TurboModule)
406
@objc(NativeMessagingInApp)
417
public class NativeMessagingInApp: NSObject {
42-
private var implementation: NativeMessagingInAppImplementation!
438
// Reference to the ObjC event emitter for new architecture (TurboModule)
449
private weak var objcEventEmitter: AnyObject?
45-
46-
@objc
47-
override public init() {
48-
super.init()
49-
50-
self.implementation = .init(inAppEventCallback: { [weak self] body in
51-
self?.sendEvent(body: body)
52-
})
10+
private lazy var inAppEventCallback: (_ body: [String: Any]) -> Void = { [weak self] body in
11+
self?.sendEvent(body: body)
5312
}
5413

5514
// Set ObjC event emitter reference for new architecture
@@ -61,13 +20,25 @@ public class NativeMessagingInApp: NSObject {
6120
// Initialize in-app event listener - called by React Native
6221
@objc
6322
public func initialize() {
64-
implementation.initialize()
23+
// Initialize in-app event listener - called by React Native
24+
ReactInAppEventListener.shared.setEventEmitter { [weak self] data in
25+
guard let self else { return }
26+
27+
// Filter out nil values to convert [String: Any?] to [String: Any]
28+
let body = data.compactMapValues { $0 }
29+
inAppEventCallback(body)
30+
}
31+
// If MessagingInApp module has already been initialized, this sets the listener directly.
32+
// If this method is called early, accessing ReactInAppEventListener.shared will also register
33+
// it into the DI graph, making it available for access in Expo during auto-initialization.
34+
MessagingInApp.shared.setEventListener(ReactInAppEventListener.shared)
6535
}
6636

6737
// Clear in-app event listener to prevent memory leaks - called by React Native
6838
@objc
6939
public func invalidate() {
70-
implementation.invalidate()
40+
// Clear in-app event listener to prevent leaks
41+
clearInAppEventListener()
7142
}
7243

7344
/**
@@ -78,6 +49,11 @@ public class NativeMessagingInApp: NSObject {
7849
MessagingInApp.shared.dismissMessage()
7950
}
8051

52+
// Clears the in-app event listener to prevent leaks when module is deallocated or invalidated
53+
func clearInAppEventListener() {
54+
ReactInAppEventListener.shared.clearEventEmitter()
55+
}
56+
8157
// Send in-app event to React Native layer using ObjC event emitter
8258
private func sendEvent(body: [String: Any]) {
8359
guard let emitter = objcEventEmitter else {
@@ -94,52 +70,3 @@ public class NativeMessagingInApp: NSObject {
9470
_ = emitter.perform(selector, with: body as NSDictionary)
9571
}
9672
}
97-
98-
// Legacy in-app messaging module for old React Native architecture (pre-TurboModule)
99-
@objc(NativeMessagingInAppLegacy)
100-
public class NativeMessagingInAppLegacy: RCTEventEmitter {
101-
private var implementation: NativeMessagingInAppImplementation!
102-
103-
@objc
104-
override public init() {
105-
super.init()
106-
107-
self.implementation = .init(inAppEventCallback: { [weak self] body in
108-
guard let self else { return }
109-
110-
// Old architecture: use self as RCTEventEmitter
111-
sendEvent(withName: CustomerioConstants.inAppEventListener, body: body)
112-
})
113-
initialize()
114-
}
115-
116-
deinit {
117-
invalidate()
118-
}
119-
120-
// Initialize in-app event listener - called by React Native
121-
@objc
122-
public func initialize() {
123-
implementation.initialize()
124-
}
125-
126-
@objc
127-
override public func invalidate() {
128-
implementation.invalidate()
129-
super.invalidate()
130-
}
131-
132-
// Returns array of supported event names for RCTEventEmitter
133-
// All in-app events are combined under a single event name
134-
override public func supportedEvents() -> [String]! {
135-
[CustomerioConstants.inAppEventListener]
136-
}
137-
138-
/**
139-
* Dismisses any currently displayed in-app message
140-
*/
141-
@objc
142-
public func dismissMessage() {
143-
MessagingInApp.shared.dismissMessage()
144-
}
145-
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#ifdef RCT_NEW_ARCH_ENABLED
2-
1+
// RCTViewComponentView.h transitively includes C++ code from React Native's Fabric renderer.
2+
// When this header is imported from an Objective-C (.h) file, certain build phases
3+
// (e.g., Clang dependency scanning, Swift bridging, and module indexing) parse it in
4+
// pure Objective-C mode, where C++ constructs are not allowed.
5+
//
6+
// Wrapping the import in `#ifdef __cplusplus` ensures it is only visible when the file
7+
// is compiled in Objective-C++ mode (.mm), preventing build failures.
8+
#ifdef __cplusplus
39
#import <React/RCTViewComponentView.h>
410
#import <UIKit/UIKit.h>
511

6-
#ifndef RCTInlineMessageNative_h
7-
#define RCTInlineMessageNative_h
8-
912
NS_ASSUME_NONNULL_BEGIN
1013

1114
@interface RCTInlineMessageNative : RCTViewComponentView
1215
@end
1316

1417
NS_ASSUME_NONNULL_END
15-
16-
#endif /* RCTInlineMessageNative_h */
17-
1818
#endif

ios/wrappers/inapp/inline/RCTInlineMessageNative.mm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#ifdef RCT_NEW_ARCH_ENABLED
2-
31
#import "RCTInlineMessageNative.h"
42
#import "ReactInlineMessageView.h"
53

@@ -13,7 +11,7 @@
1311
using namespace facebook::react;
1412

1513
/// New architecture React Native view for inline messages
16-
@interface RCTInlineMessageNative ()
14+
@interface RCTInlineMessageNative () <RCTInlineMessageNativeViewProtocol>
1715
/// Bridge to Swift ReactInlineMessageView for platform-agnostic implementation
1816
@property(nonatomic, strong) id bridge;
1917
@end
@@ -155,5 +153,3 @@ + (ComponentDescriptorProvider)componentDescriptorProvider {
155153
Class<RCTComponentViewProtocol> InlineMessageNativeCls(void) {
156154
return RCTInlineMessageNative.class;
157155
}
158-
159-
#endif

0 commit comments

Comments
 (0)