Skip to content
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

[MC-1465] Custom templates define (Custom Templates Part 1) #327

Merged
merged 21 commits into from
Jun 13, 2024

Conversation

nzagorchev
Copy link
Contributor

Overview

  1. Define Custom In-app Templates and Functions.
  2. Presenter protocol.
  3. Implement the sync payload.
  4. TemplateContext boilerplate.

Usage

    NSMutableSet *templates = [NSMutableSet set];
    CTInAppTemplateBuilder *templateBuilder = [[CTInAppTemplateBuilder alloc] init];
    [templateBuilder setName:@"Template 1"];
    [templateBuilder addArgument:@"boolean" withBool:NO];
    [templateBuilder addArgument:@"string" withString:@"string"];
    [templateBuilder addArgument:@"number" withNumber:@2];
    [templateBuilder addArgument:@"dictionary" withDictionary:@{
        @"key": @"value"
    }];
    [templateBuilder addFileArgument:@"file"];
    [templateBuilder addActionArgument:@"action"];
    [templateBuilder setPresenter:[MyTemplatePresenter new]];
    [templates addObject:[templateBuilder build]];
    
    CTTestTemplateProducer *producer = [[MyTemplateProducer alloc] initWithTemplates:templates];
    [CTCustomTemplatesManager registerTemplateProducer:producer];

@implementation MyTemplateProducer

- (instancetype)initWithTemplates:(NSSet<CTCustomTemplate *> *)templates {
    if (self = [super init]) {
        _templates = templates;
    }
    return self;
}

- (NSSet<CTCustomTemplate *> *)defineTemplates:(NSString *)accountId {
    return self.templates;
}

@end
    class TemplateProducer: CTTemplateProducer {
        func defineTemplates(_ instanceConfig: CleverTapInstanceConfig) -> Set<CTCustomTemplate> {
            
            let builder = CTInAppTemplateBuilder()
            builder.setName("Template 1")
            builder.addArgument("key", string: "value")
            builder.addArgument("number", number: 52)
            builder.addArgument("bool", boolean: false)
            builder.addActionArgument("action")
            builder.setPresenter(Template1Presenter())
            let template1 = builder.build()
            
            return [template1]
        }
    }

    class Template1Presenter: CTTemplatePresenter {
        func onPresent(context: CTTemplateContext) {
        }
        
        func onCloseClicked(context: CTTemplateContext) {
        }
    }
    
CTCustomTemplatesManager.register(TemplateProducer())

@nzagorchev nzagorchev requested review from akashvercetti and vasct May 2, 2024 09:17
@nzagorchev nzagorchev changed the base branch from master to custom_inapp_templates May 2, 2024 09:18
@nzagorchev nzagorchev changed the title Custom templates define [MC-1465] Custom templates define May 2, 2024
@nzagorchev nzagorchev changed the title [MC-1465] Custom templates define [MC-1465] Custom templates define (Custom Templates Part 1) May 10, 2024
@nzagorchev nzagorchev merged commit 17e0ff9 into custom_inapp_templates Jun 13, 2024
1 check passed
nzagorchev added a commit that referenced this pull request Aug 6, 2024
* [MC-1465] Custom templates define (Custom Templates Part 1) (#327)

* [MC-1467] Custom templates Sync (Custom Templates Part 2) (#329)

* [MC-1466] Custom templates data in inapp notification (Custom Templates Part 3) (#330)

* [MC-1468] Custom templates present and dismiss (Custom Templates Part 4) (#332)

* [MC-1470] Custom templates actions (Custom Templates Part 5) (#336)

* [MC-1649] Custom functions allow dictionaries (Custom Templates Part 6) (#337)

* [MC-1472] In-app actions js interface (Custom Templates Part 7) (#338)

* Implement custom templates file arguments (#348)

* Add template and template context debug descriptions (#351)

* [MC-1823] Fix html view controller presented before scene became active (#352)

* tvOS compatibility (#353)

* Add SDK version as window variable to the JS interface (#354)

* Create the syncPayload and meta outside the syncWithBlock (#356)

* Expose activeContextForTemplate (#357)

* [MC-1883] File download concurrency (#358)

* Enumerate synchronously (#359)

* Update docs, Changelog and README (#360)

* Update SPM (#362)

* Bump version to 7.0.0 (#361)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants