-
Notifications
You must be signed in to change notification settings - Fork 39
New arch/master #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
New arch/master #704
Conversation
…le from RNIterableAPI.mm
…or new architecture
… consistent formatting
…7-add-new-architecture-support
…IterableAPI module
…unnecessary logging
…acy architectures
…ft to streamline code
…ew-arch/MOB-11828-add-backwards-compatibility
…new-arch/MOB-11833-format-files
…7-add-new-architecture-support
…ew-arch/MOB-11828-add-backwards-compatibility
…eAPI in package.json
…d-api-and-codegen [MOB-11826] make-frontend-api-and-codegen
[MOB-11833] format-files
…ew-arch/MOB-11828-add-backwards-compatibility
…ft and iOS SDK dependency
…ew-arch/MOB-11828-add-backwards-compatibility
…s-compatibility [MOB-11828] add-backwards-compatibility
Added copilot suggestion Co-authored-by: Copilot <[email protected]>
…t suggestion Co-authored-by: Copilot <[email protected]>
…t suggestion Co-authored-by: Copilot <[email protected]>
…itecture-support [MOB-11827] add-new-architecture-support
…erableapimodule-so-that-its-major-func [MOB-11954] restructure RNIterableAPIModule to delegate functionality to RNIterableAPIModuleImpl
…encies-correctly [MOB-11994] align-dependencies-correctly
…w-architecture [MOB-11955] configure-new-architecture
…en-clicking-track-push-open-with-ca
…in the same order
…AppClose method per PR comment
…when-clicking-track-push-open-with-ca [MOB-11957] ios-crashes-when-clicking-track-push-open-with-ca
…on typo in IterableInAppManager
…elease-it to version 18.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements React Native New Architecture support for the Iterable SDK, transitioning from legacy architecture to support both new TurboModules/Fabric and legacy patterns. Key changes include adding TurboModule specifications, updating native bridge implementations, and adjusting type signatures for compatibility.
Key Changes:
- Added New Architecture support with TurboModule specifications and dual architecture compatibility
- Refactored native iOS/Android bridge implementations to support both legacy and new architectures
- Updated type signatures throughout codebase to use more precise null-safe types (string | null vs string | undefined)
Reviewed Changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
src/api/NativeRNIterableAPI.ts | New TurboModule specification interface for New Architecture |
src/api/index.ts | Bridge module that exports either TurboModule or legacy NativeModule |
ios/RNIterableAPI/ReactIterableAPI.swift | Refactored Swift implementation to support both architectures |
ios/RNIterableAPI/RNIterableAPI.mm | Updated Objective-C bridge with dual architecture support |
android/src/newarch/java/com/RNIterableAPIModule.java | New Architecture Android implementation |
android/src/oldarch/java/com/RNIterableAPIModule.java | Legacy Architecture Android implementation |
src/core/classes/Iterable.ts | Updated type signatures for null-safe parameters |
package.json | Updated dependencies and build configuration for New Architecture |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if (messageId != null) { | ||
IterableLogger.v(TAG, "inAppConsume"); | ||
IterableApi.getInstance().inAppConsume(RNIterableInternal.getMessageById(messageId), Serialization.getIterableDeleteActionTypeFromInteger((int) source), Serialization.getIterableInAppLocationFromInteger((int) location)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic has been inverted from the original version (was if (messageId == null) { return; }
). This change puts all the logic inside the if block, which increases nesting. Consider reverting to early return pattern for better readability: if (messageId == null) { return; }
if (messageId != null) { | |
IterableLogger.v(TAG, "inAppConsume"); | |
IterableApi.getInstance().inAppConsume(RNIterableInternal.getMessageById(messageId), Serialization.getIterableDeleteActionTypeFromInteger((int) source), Serialization.getIterableInAppLocationFromInteger((int) location)); | |
} | |
if (messageId == null) { | |
return; | |
} | |
IterableLogger.v(TAG, "inAppConsume"); | |
IterableApi.getInstance().inAppConsume( | |
RNIterableInternal.getMessageById(messageId), | |
Serialization.getIterableDeleteActionTypeFromInteger((int) source), | |
Serialization.getIterableInAppLocationFromInteger((int) location) | |
); |
Copilot uses AI. Check for mistakes.
return | ||
} | ||
delegate?.sendEvent( | ||
withName: EventName.receivedIterableInboxChanged.rawValue, body: nil as Any?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explicit cast nil as Any?
is unnecessary in Swift. Simply using nil
would be sufficient as the parameter is already typed as Any?
. This makes the code cleaner and more idiomatic.
withName: EventName.receivedIterableInboxChanged.rawValue, body: nil as Any?) | |
withName: EventName.receivedIterableInboxChanged.rawValue, body: nil) |
Copilot uses AI. Check for mistakes.
Diff Coverage: The code coverage on the diff in this pull request is 64.3%. Total Coverage: This PR will decrease coverage by 0.13%. File Coverage Changes
🛟 Help
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
❌ 2 blocking issues (20 total)
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
android/src/main/java/com/iterable/reactnative/RNIterableAPIModuleImpl.java
Show resolved
Hide resolved
@ReactMethod | ||
public void trackPushOpenWithCampaignId(Integer campaignId, Integer templateId, String messageId, Boolean appAlreadyRunning, ReadableMap dataFields) { | ||
RNIterableInternal.trackPushOpenWithCampaignId(campaignId, templateId, messageId, optSerializedDataFields(dataFields)); | ||
public void trackPushOpenWithCampaignId(double campaignId, @Nullable Double templateId, String messageId, boolean appAlreadyRunning, @Nullable ReadableMap dataFields) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
@ReactMethod | ||
public void updateSubscriptions(ReadableArray emailListIds, ReadableArray unsubscribedChannelIds, ReadableArray unsubscribedMessageTypeIds, ReadableArray subscribedMessageTypeIds, Integer campaignId, Integer templateId) { | ||
public void updateSubscriptions(@Nullable ReadableArray emailListIds, @Nullable ReadableArray unsubscribedChannelIds, @Nullable ReadableArray unsubscribedMessageTypeIds, @Nullable ReadableArray subscribedMessageTypeIds, double campaignId, double templateId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
@ReactMethod | ||
public void trackInAppClose(String messageId, Integer location, Integer source, @Nullable String clickedUrl) { | ||
public void trackInAppClose(String messageId, double location, double source, @Nullable String clickedUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
@Override | ||
public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, String version, Promise promise) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
@ReactMethod | ||
public void updateSubscriptions(@Nullable ReadableArray emailListIds, @Nullable ReadableArray unsubscribedChannelIds, @Nullable ReadableArray unsubscribedMessageTypeIds, @Nullable ReadableArray subscribedMessageTypeIds, double campaignId, double templateId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
@ReactMethod | ||
public void trackInAppClose(String messageId, double location, double source, @Nullable String clickedUrl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,140 @@ | |||
import type { TurboModule } from 'react-native'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,6 @@ | |||
import { NativeModules } from 'react-native'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void initializeWithApiKey(String apiKey, ReadableMap configReadableMap, String version, Promise promise) { | ||
IterableLogger.d(TAG, "initializeWithApiKey: " + apiKey); | ||
IterableConfig.Builder configBuilder = Serialization.getConfigFromReadableMap(configReadableMap); | ||
|
||
@Override | ||
public String getName() { | ||
return "RNIterableAPI"; | ||
if (configReadableMap.hasKey("urlHandlerPresent") && configReadableMap.getBoolean("urlHandlerPresent") == true) { | ||
configBuilder.setUrlHandler(this); | ||
} | ||
|
||
if (configReadableMap.hasKey("customActionHandlerPresent") && configReadableMap.getBoolean("customActionHandlerPresent") == true) { | ||
configBuilder.setCustomActionHandler(this); | ||
} | ||
|
||
if (configReadableMap.hasKey("inAppHandlerPresent") && configReadableMap.getBoolean("inAppHandlerPresent") == true) { | ||
configBuilder.setInAppHandler(this); | ||
} | ||
|
||
if (configReadableMap.hasKey("authHandlerPresent") && configReadableMap.getBoolean("authHandlerPresent") == true) { | ||
configBuilder.setAuthHandler(this); | ||
} | ||
|
||
IterableApi.initialize(reactContext, apiKey, configBuilder.build()); | ||
IterableApi.getInstance().setDeviceAttribute("reactNativeSDKVersion", version); | ||
|
||
IterableApi.getInstance().getInAppManager().addListener(this); | ||
|
||
// MOB-10421: Figure out what the error cases are and handle them appropriately | ||
// This is just here to match the TS types and let the JS thread know when we are done initializing | ||
promise.resolve(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static updateSubscriptions( | ||
emailListIds: number[] | undefined, | ||
unsubscribedChannelIds: number[] | undefined, | ||
unsubscribedMessageTypeIds: number[] | undefined, | ||
subscribedMessageTypeIds: number[] | undefined, | ||
emailListIds: number[] | null, | ||
unsubscribedChannelIds: number[] | null, | ||
unsubscribedMessageTypeIds: number[] | null, | ||
subscribedMessageTypeIds: number[] | null, | ||
campaignId: number, | ||
templateId: number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔹 JIRA Ticket(s) if any
✏️ Description