Skip to content

New-arch/MOB-11479-update-ios-native-module #684

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions BridgelessEventEmitterHost.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Foundation
import React

@objc(BridgelessEventEmitterHost)
class BridgelessEventEmitterHost: NSObject {
private let appContext: RCTAppContext

init(appContext: RCTAppContext) {
self.appContext = appContext
super.init()
NSLog("*** BridgelessEventEmitterHost initialized ***")
}

func send(name: String, body: Any?) {
appContext.emit(eventName: name, payload: body)
}

func getShouldEmit() -> Bool {
// Optional logic if you want to control flow
return true
}
}
40 changes: 14 additions & 26 deletions Iterable-React-Native-SDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

Pod::Spec.new do |s|
s.name = "Iterable-React-Native-SDK"
Expand All @@ -14,31 +13,20 @@ Pod::Spec.new do |s|
s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/Iterable/react-native-sdk.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,swift}"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
if respond_to?(:install_modules_dependencies, true)
install_modules_dependencies(s)
else
s.dependency "React-Core"

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
}
s.dependency "React-Codegen"
s.dependency "RCT-Folly"
s.dependency "RCTRequired"
s.dependency "RCTTypeSafety"
s.dependency "ReactCommon/turbomodule/core"
end
end
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
s.private_header_files = "ios/**/*.h"

# Load Iterables iOS SDK as a dependency
s.dependency "Iterable-iOS-SDK", "6.5.4"


# Basic Swift support
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'CLANG_ENABLE_MODULES' => 'YES',
'SWIFT_VERSION' => '5.0',
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
}

install_modules_dependencies(s)

end
Empty file added RNIterableAPI+Module.swift
Empty file.
13 changes: 13 additions & 0 deletions example/ios/NotificationExt/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.usernotifications.service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).NotificationService</string>
</dict>
</dict>
</plist>
40 changes: 40 additions & 0 deletions example/ios/NotificationExt/NotificationService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// //
// // NotificationService.swift
// // NotificationExt
// //
// // Created by Loren Posen on 7/24/25.
// //

// import UserNotifications

// class NotificationService: UNNotificationServiceExtension {

// var contentHandler: ((UNNotificationContent) -> Void)?
// var bestAttemptContent: UNMutableNotificationContent?

// override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
// self.contentHandler = contentHandler
// bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

// if let bestAttemptContent = bestAttemptContent {
// // Modify the notification content here...
// bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"

// contentHandler(bestAttemptContent)
// }
// }

// override func serviceExtensionTimeWillExpire() {
// // Called just before the extension will be terminated by the system.
// // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
// if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
// contentHandler(bestAttemptContent)
// }
// }

// }

import UserNotifications
import IterableAppExtensions

class NotificationService: ITBNotificationServiceExtension { }
10 changes: 8 additions & 2 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ENV['RCT_NEW_ARCH_ENABLED'] = '1'
ENV['RCT_NEW_ARCH_ENABLED'] = '0'

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
Expand All @@ -13,7 +13,9 @@ prepare_react_native_project!
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
# IMPORTANT: New Architecture Issue solution
# This is needed to use the Swift code from Iterable-iOS-SDK in the RNIterableAPI module
use_frameworks! :linkage => :dynamic
end

target 'ReactNativeSdkExample' do
Expand All @@ -35,3 +37,7 @@ target 'ReactNativeSdkExample' do
)
end
end

target 'NotificationExt' do
pod 'Iterable-iOS-AppExtensions'
end
Loading
Loading