Skip to content
Merged
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
33 changes: 17 additions & 16 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@ sample/
# Android build artifacts and libs
android/libs/
android/build/
android/src/test/
android/.gradle/
android/local.properties
android/.idea/
android/.kotlin/
android/gradlew
android/gradlew.bat
android/gradle.properties
android/gradle/

# iOS build artifacts
ios/build/
ios/Pods/
ios/Podfile.lock

# Build directories
build/
dist/
ios/RNMParticle.xcodeproj/xcuserdata/
ios/RNMParticle.xcodeproj/xcshareddata/
ios/RNMParticle.xcodeproj/project.xcworkspace/

# Dependencies
node_modules/

# IDE files
.idea/
.vscode/
.trunk/
*.iml
*.iws

Expand All @@ -32,6 +37,7 @@ Thumbs.db
# Git
.git/
.github/
.gitignore

# Logs
*.log
Expand All @@ -47,19 +53,14 @@ yarn-error.log*

# Heavy binary files
*.jar
*.aar
*.so
*.dylib
*.dll

# Development files
package-lock.json
yarn.lock
tsconfig.json
release.sh

# Development and test files
**/*.test.ts
**/*.test.tsx
**/*.spec.ts
**/*.spec.tsx
dev-link.sh
.prettierrc.js
.eslintrc.js
metro.config.js
ONBOARDING.md
30 changes: 18 additions & 12 deletions ios/RNMParticle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
objects = {

/* Begin PBXBuildFile section */
B39BCD8E2E2A06D700FC90B8 /* RNMPRokt.m in Sources */ = {isa = PBXBuildFile; fileRef = B39BCD8A2E2A06D700FC90B8 /* RNMPRokt.m */; };
B39BCD8F2E2A06D700FC90B8 /* RoktEventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B39BCD8C2E2A06D700FC90B8 /* RoktEventManager.m */; };
B39BCD902E2A06D700FC90B8 /* RoktWidgetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B39BCD8D2E2A06D700FC90B8 /* RoktWidgetManager.m */; };
DBDF24DC1E007EB1000F3D73 /* RNMParticle.m in Sources */ = {isa = PBXBuildFile; fileRef = DBDF24DB1E007EB1000F3D73 /* RNMParticle.m */; };
B39BCD962E30562400FC90B8 /* RoktLayoutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B39BCD932E30562400FC90B8 /* RoktLayoutManager.m */; };
B39BCD972E30562400FC90B8 /* RNMPRokt.mm in Sources */ = {isa = PBXBuildFile; fileRef = B39BCD922E30562400FC90B8 /* RNMPRokt.mm */; };
B39BCD982E30562400FC90B8 /* RNMParticle.mm in Sources */ = {isa = PBXBuildFile; fileRef = B39BCD912E30562400FC90B8 /* RNMParticle.mm */; };
B39BCD992E30562400FC90B8 /* RoktNativeLayoutComponentView.mm in Sources */ = {isa = PBXBuildFile; fileRef = B39BCD952E30562400FC90B8 /* RoktNativeLayoutComponentView.mm */; };
DBDF24DD1E007EB1000F3D73 /* RNMParticle.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBDF24DA1E007EB1000F3D73 /* RNMParticle.h */; };
/* End PBXBuildFile section */

Expand All @@ -29,13 +30,15 @@

/* Begin PBXFileReference section */
B39BCD892E2A06D700FC90B8 /* RNMPRokt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNMPRokt.h; sourceTree = "<group>"; };
B39BCD8A2E2A06D700FC90B8 /* RNMPRokt.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNMPRokt.m; sourceTree = "<group>"; };
B39BCD8B2E2A06D700FC90B8 /* RoktEventManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoktEventManager.h; sourceTree = "<group>"; };
B39BCD8C2E2A06D700FC90B8 /* RoktEventManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoktEventManager.m; sourceTree = "<group>"; };
B39BCD8D2E2A06D700FC90B8 /* RoktWidgetManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoktWidgetManager.m; sourceTree = "<group>"; };
B39BCD912E30562400FC90B8 /* RNMParticle.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RNMParticle.mm; sourceTree = "<group>"; };
B39BCD922E30562400FC90B8 /* RNMPRokt.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RNMPRokt.mm; sourceTree = "<group>"; };
B39BCD932E30562400FC90B8 /* RoktLayoutManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoktLayoutManager.m; sourceTree = "<group>"; };
B39BCD942E30562400FC90B8 /* RoktNativeLayoutComponentView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoktNativeLayoutComponentView.h; sourceTree = "<group>"; };
B39BCD952E30562400FC90B8 /* RoktNativeLayoutComponentView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RoktNativeLayoutComponentView.mm; sourceTree = "<group>"; };
DBDF24D71E007EB1000F3D73 /* libRNMParticle.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNMParticle.a; sourceTree = BUILT_PRODUCTS_DIR; };
DBDF24DA1E007EB1000F3D73 /* RNMParticle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNMParticle.h; sourceTree = "<group>"; };
DBDF24DB1E007EB1000F3D73 /* RNMParticle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNMParticle.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -68,13 +71,15 @@
DBDF24D91E007EB1000F3D73 /* RNMParticle */ = {
isa = PBXGroup;
children = (
B39BCD912E30562400FC90B8 /* RNMParticle.mm */,
B39BCD922E30562400FC90B8 /* RNMPRokt.mm */,
B39BCD932E30562400FC90B8 /* RoktLayoutManager.m */,
B39BCD942E30562400FC90B8 /* RoktNativeLayoutComponentView.h */,
B39BCD952E30562400FC90B8 /* RoktNativeLayoutComponentView.mm */,
B39BCD892E2A06D700FC90B8 /* RNMPRokt.h */,
B39BCD8A2E2A06D700FC90B8 /* RNMPRokt.m */,
B39BCD8B2E2A06D700FC90B8 /* RoktEventManager.h */,
B39BCD8C2E2A06D700FC90B8 /* RoktEventManager.m */,
B39BCD8D2E2A06D700FC90B8 /* RoktWidgetManager.m */,
DBDF24DA1E007EB1000F3D73 /* RNMParticle.h */,
DBDF24DB1E007EB1000F3D73 /* RNMParticle.m */,
);
path = RNMParticle;
sourceTree = "<group>";
Expand Down Expand Up @@ -137,10 +142,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DBDF24DC1E007EB1000F3D73 /* RNMParticle.m in Sources */,
B39BCD8E2E2A06D700FC90B8 /* RNMPRokt.m in Sources */,
B39BCD962E30562400FC90B8 /* RoktLayoutManager.m in Sources */,
B39BCD972E30562400FC90B8 /* RNMPRokt.mm in Sources */,
B39BCD982E30562400FC90B8 /* RNMParticle.mm in Sources */,
B39BCD992E30562400FC90B8 /* RoktNativeLayoutComponentView.mm in Sources */,
B39BCD8F2E2A06D700FC90B8 /* RoktEventManager.m in Sources */,
B39BCD902E2A06D700FC90B8 /* RoktWidgetManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
11 changes: 9 additions & 2 deletions ios/RNMParticle/RNMPRokt.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>

@interface RNMPRokt : NSObject <RCTBridgeModule>
#ifdef RCT_NEW_ARCH_ENABLED
#import <RNMParticle/RNMParticle.h>
#import <React/RCTBridge.h>

@interface RNMPRokt : NSObject<NativeMPRoktSpec>
@property (nonatomic, weak, nullable) RCTBridge *bridge;
#else

#import <React/RCTBridgeModule.h>
@interface RNMPRokt : NSObject <RCTBridgeModule>
#endif

@end
57 changes: 48 additions & 9 deletions ios/RNMParticle/RNMPRokt.m → ios/RNMParticle/RNMPRokt.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#elif defined(__has_include) && __has_include(<mParticle_Apple_SDK_NoLocation/mParticle.h>)
#import <mParticle_Apple_SDK_NoLocation/mParticle.h>
#else
#import "mParticle.h"
#import <mParticle_Apple_SDK/Include/mParticle.h>
#endif
#if defined(__has_include) && __has_include(<mParticle_Apple_SDK/mParticle_Apple_SDK-Swift.h>)
#import <mParticle_Apple_SDK/mParticle_Apple_SDK-Swift.h>
Expand All @@ -21,6 +21,11 @@
#import <React/RCTBridge.h>
#import "RoktEventManager.h"

#ifdef RCT_NEW_ARCH_ENABLED
#import "RoktNativeLayoutComponentView.h"
#import <RNMParticle/RNMParticle.h>
#endif // RCT_NEW_ARCH_ENABLED

@interface RNMPRokt ()

@property (nonatomic, nullable) RoktEventManager *eventManager;
Expand Down Expand Up @@ -52,15 +57,43 @@ - (void)setMethodQueue:(dispatch_queue_t)methodQueue
// We always return the UI manager's method queue
}

#ifdef RCT_NEW_ARCH_ENABLED
// New Architecture Implementation
- (void)selectPlacements:(NSString *)identifer
attributes:(NSDictionary *)attributes
placeholders:(NSDictionary *)placeholders
roktConfig:(JS::NativeMPRokt::RoktConfigType &)roktConfig
fontFilesMap:(NSDictionary *)fontFilesMap
{
NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings:attributes];

// Convert JS struct to NSDictionary for internal use
NSMutableDictionary *roktConfigDict = [[NSMutableDictionary alloc] init];
if (&roktConfig != nullptr && roktConfig.cacheConfig().has_value()) {
NSMutableDictionary *cacheConfigDict = [[NSMutableDictionary alloc] init];
auto cacheConfig = roktConfig.cacheConfig().value();
if (cacheConfig.cacheDurationInSeconds().has_value()) {
cacheConfigDict[@"cacheDurationInSeconds"] = @(cacheConfig.cacheDurationInSeconds().value());
}
if (cacheConfig.cacheAttributes()) {
cacheConfigDict[@"cacheAttributes"] = cacheConfig.cacheAttributes();
}
roktConfigDict[@"cacheConfig"] = cacheConfigDict;
}

MPRoktConfig *config = [self buildRoktConfigFromDict:roktConfigDict];
#else
// Old Architecture Implementation
RCT_EXPORT_METHOD(selectPlacements:(NSString *) identifer attributes:(NSDictionary *)attributes placeholders:(NSDictionary * _Nullable)placeholders roktConfig:(NSDictionary * _Nullable)roktConfig fontFilesMap:(NSDictionary * _Nullable)fontFilesMap)
{
NSMutableDictionary *finalAttributes = [self convertToMutableDictionaryOfStrings:attributes];
MPRoktConfig *config = [self buildRoktConfigFromDict:roktConfig];
#endif

// Create callback implementation
MPRoktEventCallback *callbacks = [[MPRoktEventCallback alloc] init];

__weak typeof(self) weakSelf = self;
__weak __typeof__(self) weakSelf = self;

callbacks.onLoad = ^{
[self.eventManager onRoktCallbackReceived:@"onLoad"];
Expand Down Expand Up @@ -88,7 +121,6 @@ - (void)setMethodQueue:(dispatch_queue_t)methodQueue

[self subscribeViewEvents:identifer];

// TODO: Add placeholders and fontFilesMap
[[[MParticle sharedInstance] rokt] selectPlacements:identifer
attributes:finalAttributes
embeddedViews:nativePlaceholders
Expand Down Expand Up @@ -176,25 +208,32 @@ - (NSMutableDictionary *)getNativePlaceholders:(NSDictionary *)placeholders view
NSMutableDictionary *nativePlaceholders = [[NSMutableDictionary alloc]initWithCapacity:placeholders.count];

for(id key in placeholders){
//#ifdef RCT_NEW_ARCH_ENABLED
/*RoktNativeWidgetComponentView *wrapperView = (RoktNativeWidgetComponentView *)viewRegistry[[placeholders objectForKey:key]];
if (!wrapperView || ![wrapperView isKindOfClass:[RoktNativeWidgetComponentView class]]) {
#ifdef RCT_NEW_ARCH_ENABLED
RoktNativeLayoutComponentView *wrapperView = (RoktNativeLayoutComponentView *)viewRegistry[[placeholders objectForKey:key]];
if (!wrapperView || ![wrapperView isKindOfClass:[RoktNativeLayoutComponentView class]]) {
RCTLogError(@"Cannot find RoktNativeWidgetComponentView with tag #%@", key);
continue;
}
nativePlaceholders[key] = wrapperView.roktEmbeddedView;*/
//#else
nativePlaceholders[key] = wrapperView.roktEmbeddedView;
#else
MPRoktEmbeddedView *view = viewRegistry[[placeholders objectForKey:key]];
if (!view || ![view isKindOfClass:[MPRoktEmbeddedView class]]) {
RCTLogError(@"Cannot find RoktEmbeddedView with tag #%@", key);
continue;
}

nativePlaceholders[key] = view;
//#endif // RCT_NEW_ARCH_ENABLED
#endif // RCT_NEW_ARCH_ENABLED
}

return nativePlaceholders;
}

#ifdef RCT_NEW_ARCH_ENABLED
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
self.bridge = params.instance.bridge;
return std::make_shared<facebook::react::NativeMPRoktSpecJSI>(params);
}
#endif // RCT_NEW_ARCH_ENABLED

@end
7 changes: 6 additions & 1 deletion ios/RNMParticle/RNMParticle.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <RNMParticle/RNMParticle.h>
@interface RNMParticle : NSObject <NativeMParticleSpec>
#else
#import <React/RCTBridgeModule.h>
@interface RNMParticle : NSObject <RCTBridgeModule>
#endif

@end
Loading
Loading