Skip to content

Commit

Permalink
Merge pull request #419 from CleverTap/feature/custom-inapp-templates…
Browse files Browse the repository at this point in the history
…-new-arch-ios

Custom in-app Templates iOS
  • Loading branch information
nzagorchev authored Oct 8, 2024
2 parents 3d36543 + 56c62a2 commit 1abff9e
Show file tree
Hide file tree
Showing 21 changed files with 458 additions and 80 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ node_modules
# CocoaPods
Pods
Podfile.lock

# Ignore assets in custom directory
android/app/src/main/assets/custom/*

# Ignore all link-assets-manifest.json files
**/link-assets-manifest.json
14 changes: 14 additions & 0 deletions Example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ class Expandable_ListView extends Component {
case 89:
CleverTap.clearInAppResources(true);
break;
case 700:
CleverTap.syncCustomTemplates();
break;
case 701:
CleverTap.syncCustomTemplatesInProd(true);
break;
}
}

Expand Down Expand Up @@ -815,6 +821,14 @@ export default class App extends Component {
},
],
},
{
expanded: false,
category_Name: 'Custom Templates',
sub_Category: [
{id: 700, name: 'Sync Custom Templates'},
{id: 701, name: 'Sync Custom Templates In Prod'}
],
},
{
expanded: false,
category_Name: 'Push Templates',
Expand Down
43 changes: 0 additions & 43 deletions Example/android/app/src/main/assets/templates.json

This file was deleted.

43 changes: 43 additions & 0 deletions Example/assets/templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"template-lina": {
"type": "template",
"arguments": {
"var1": {
"type": "boolean",
"value": false
},
"var2": {
"type": "string",
"value": "Default"
},
"folder1": {
"type": "object",
"value": {
"var3": {
"type": "number",
"value": 0
}
}
},
"folder1.var4": {
"type": "file"
},
"map": {
"type": "object",
"value": {
"int": {
"type": "number",
"value": 0
},
"string": {
"type": "string",
"value": "Default"
}
}
},
"action": {
"type": "action"
}
}
}
}
3 changes: 3 additions & 0 deletions Example/ios/Example/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "CleverTap.h"
#import "CleverTapReactManager.h"
#import "CleverTapReactCustomTemplates.h"

@implementation AppDelegate

Expand All @@ -23,6 +24,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
#ifdef DEBUG
[CleverTap setDebugLevel:CleverTapLogDebug];
#endif

[CleverTapReactCustomTemplates registerCustomTemplates:@"templates", nil];
[CleverTap autoIntegrate];
[self addNotificationCategories];

Expand Down
12 changes: 10 additions & 2 deletions Example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ if linkage != nil
use_frameworks! :linkage => linkage.to_sym
end


def ct_pod
pod "CleverTap-iOS-SDK", :modular_headers => true,
git: 'https://github.com/CleverTap/clevertap-ios-sdk', branch: 'custom_templates_json'
end

target 'Example' do
config = use_native_modules!

Expand All @@ -23,6 +29,8 @@ target 'Example' do
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

ct_pod

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
Expand All @@ -44,7 +52,7 @@ target 'Example' do
end

target 'NotificationService' do
pod "CleverTap-iOS-SDK", :modular_headers => true
ct_pod
pod "CTNotificationService", :modular_headers => true
end

Expand All @@ -54,7 +62,7 @@ end

# Added these target for sample code only in Swift
target 'NotificationServiceSwift' do
pod "CleverTap-iOS-SDK", :modular_headers => true
ct_pod
pod "CTNotificationService", :modular_headers => true
end

Expand Down
9 changes: 9 additions & 0 deletions Example/ios/link-assets-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"migIndex": 1,
"data": [
{
"path": "assets/templates.json",
"sha1": "c414f3fcad970b458e77fd89b73c7a08002ccd9f"
}
]
}
6 changes: 4 additions & 2 deletions Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"postinstall": "react-native-asset",
"android": "react-native-asset && react-native run-android",
"ios": "react-native-asset && react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
Expand All @@ -16,6 +17,7 @@
"clevertap-react-native": "file:..",
"react": "18.2.0",
"react-native": "^0.74.1",
"react-native-asset": "^2.1.1",
"react-native-drawer": "^2.5.1",
"react-native-gesture-handler": "^1.10.3",
"react-native-pager-view": "^5.1.2",
Expand Down
7 changes: 7 additions & 0 deletions Example/react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
project: {
ios: {},
android: {},
},
assets: ['./assets'],
};
24 changes: 24 additions & 0 deletions ios/CleverTapReact.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
5266DAB91E4B9C16000008F5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5266DAB61E4B9B8C000008F5 /* UIKit.framework */; };
5266DABA1E4B9C20000008F5 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52DFC6831E4B990A00EDC368 /* SystemConfiguration.framework */; };
5266DADB1E4BB5BD000008F5 /* CleverTapSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5266DAD91E4BB598000008F5 /* CleverTapSDK.framework */; };
6B102BB02CAD8B7800296828 /* CleverTapReactCustomTemplates.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B102BAE2CAD8B7800296828 /* CleverTapReactCustomTemplates.h */; };
6B102BB42CAD8BB700296828 /* CleverTapReactTemplatePresenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B102BB22CAD8BB700296828 /* CleverTapReactTemplatePresenter.h */; };
6B102BB82CAD8BEE00296828 /* CleverTapReactAppFunctionPresenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B102BB62CAD8BEE00296828 /* CleverTapReactAppFunctionPresenter.h */; };
6B102BBF2CADE31500296828 /* CleverTapReactCustomTemplates.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6B102BBC2CADE31500296828 /* CleverTapReactCustomTemplates.mm */; };
6B102BC02CADE31500296828 /* CleverTapReactTemplatePresenter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6B102BBD2CADE31500296828 /* CleverTapReactTemplatePresenter.mm */; };
6B102BC12CADE31500296828 /* CleverTapReactAppFunctionPresenter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6B102BBE2CADE31500296828 /* CleverTapReactAppFunctionPresenter.mm */; };
6B587A032BC02ECD0077493E /* CleverTapReactPendingEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6B587A022BC02ECD0077493E /* CleverTapReactPendingEvent.mm */; };
6B587A042BC02ECD0077493E /* CleverTapReactPendingEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B587A012BC02ECD0077493E /* CleverTapReactPendingEvent.h */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -43,6 +49,12 @@
52DFC6831E4B990A00EDC368 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
52DFC6851E4B991000EDC368 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
5D72D2E81C16249000E22EC1 /* libCleverTapReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCleverTapReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
6B102BAE2CAD8B7800296828 /* CleverTapReactCustomTemplates.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CleverTapReactCustomTemplates.h; sourceTree = "<group>"; };
6B102BB22CAD8BB700296828 /* CleverTapReactTemplatePresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CleverTapReactTemplatePresenter.h; sourceTree = "<group>"; };
6B102BB62CAD8BEE00296828 /* CleverTapReactAppFunctionPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CleverTapReactAppFunctionPresenter.h; sourceTree = "<group>"; };
6B102BBC2CADE31500296828 /* CleverTapReactCustomTemplates.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CleverTapReactCustomTemplates.mm; sourceTree = "<group>"; };
6B102BBD2CADE31500296828 /* CleverTapReactTemplatePresenter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CleverTapReactTemplatePresenter.mm; sourceTree = "<group>"; };
6B102BBE2CADE31500296828 /* CleverTapReactAppFunctionPresenter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CleverTapReactAppFunctionPresenter.mm; sourceTree = "<group>"; };
6B587A012BC02ECD0077493E /* CleverTapReactPendingEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CleverTapReactPendingEvent.h; sourceTree = "<group>"; };
6B587A022BC02ECD0077493E /* CleverTapReactPendingEvent.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CleverTapReactPendingEvent.mm; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -71,6 +83,12 @@
52344FBC1E4CE7F000661762 /* CleverTapReactManager.mm */,
6B587A012BC02ECD0077493E /* CleverTapReactPendingEvent.h */,
6B587A022BC02ECD0077493E /* CleverTapReactPendingEvent.mm */,
6B102BAE2CAD8B7800296828 /* CleverTapReactCustomTemplates.h */,
6B102BBC2CADE31500296828 /* CleverTapReactCustomTemplates.mm */,
6B102BB22CAD8BB700296828 /* CleverTapReactTemplatePresenter.h */,
6B102BBD2CADE31500296828 /* CleverTapReactTemplatePresenter.mm */,
6B102BB62CAD8BEE00296828 /* CleverTapReactAppFunctionPresenter.h */,
6B102BBE2CADE31500296828 /* CleverTapReactAppFunctionPresenter.mm */,
);
path = CleverTapReact;
sourceTree = "<group>";
Expand Down Expand Up @@ -110,6 +128,9 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
6B102BB42CAD8BB700296828 /* CleverTapReactTemplatePresenter.h in Headers */,
6B102BB02CAD8B7800296828 /* CleverTapReactCustomTemplates.h in Headers */,
6B102BB82CAD8BEE00296828 /* CleverTapReactAppFunctionPresenter.h in Headers */,
52344FC21E4CEC3200661762 /* CleverTapReactManager.h in Headers */,
6B587A042BC02ECD0077493E /* CleverTapReactPendingEvent.h in Headers */,
);
Expand Down Expand Up @@ -174,8 +195,11 @@
buildActionMask = 2147483647;
files = (
52344FBF1E4CE7F000661762 /* CleverTapReactManager.mm in Sources */,
6B102BC12CADE31500296828 /* CleverTapReactAppFunctionPresenter.mm in Sources */,
52344FBE1E4CE7F000661762 /* CleverTapReact.mm in Sources */,
6B102BBF2CADE31500296828 /* CleverTapReactCustomTemplates.mm in Sources */,
6B587A032BC02ECD0077493E /* CleverTapReactPendingEvent.mm in Sources */,
6B102BC02CADE31500296828 /* CleverTapReactTemplatePresenter.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
5 changes: 4 additions & 1 deletion ios/CleverTapReact/CleverTapReact.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ static NSString *const kCleverTapPushPermissionResponseReceived = @"CleverTapPus
static NSString *const kCleverTapInAppNotificationShowed = @"CleverTapInAppNotificationShowed";
static NSString *const kCleverTapOnVariablesChanged = @"CleverTapOnVariablesChanged";
static NSString *const kCleverTapOnValueChanged = @"CleverTapOnValueChanged";
static NSString *const kCleverTapCustomTemplatePresent = @"CleverTapCustomTemplatePresent";
static NSString *const kCleverTapCustomFunctionPresent = @"CleverTapCustomFunctionPresent";
static NSString *const kCleverTapCustomTemplateClose = @"CleverTapCustomTemplateClose";
static NSString *const kXPS = @"XPS";

#ifdef RCT_NEW_ARCH_ENABLED
Expand All @@ -31,4 +34,4 @@ static NSString *const kXPS = @"XPS";

+ (void)sendEventOnObserving:(NSString *)name body:(id)body;

@end
@end
Loading

0 comments on commit 1abff9e

Please sign in to comment.