Skip to content

Conversation

@gyoshev
Copy link
Contributor

@gyoshev gyoshev commented Oct 25, 2021

With this PR, the JS SDK allows defining custom message templates to be consumed through a website.

Usage:

    // Define the action name and fields that will show up in the Leanplum dashboard
    Leanplum.defineAction({
      // name shown in the template picker
      name: 'Custom Popup',
      args: [
        // properties in message editor
        { name: 'Title',   type: ActionParameterType.String, value: 'Title placeholder' },
        { name: 'Content', type: ActionParameterType.Text,   value: 'Content placeholder' },
        { name: 'Image',   type: ActionParameterType.File,   value: '' },

        { name: 'Layout',  type: ActionParameterType.Group,  value: [
          { name: 'Width',   type: ActionParameterType.Number, value: 800 },
          { name: 'Height',  type: ActionParameterType.Number, value: 600 }
        ] },

        { name: 'Dismiss action', type: ActionParameterType.Action, value: '' }
      ]
    });

    // Render the action by processing the "showMessage" event
    Leanplum.on('showMessage', (args: RenderOptions) => {
      const { message, context } = args;

      if (message.__name__ === 'Custom Popup') {
        // render popup and use context
      }
   })

@gyoshev gyoshev marked this pull request as ready for review November 4, 2021 21:47
@gyoshev gyoshev requested a review from iignatov November 4, 2021 21:58
@gyoshev gyoshev merged commit 6cd558b into develop Nov 9, 2021
@gyoshev gyoshev deleted the define-action branch November 9, 2021 07:52
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