AirshipSubscriptionFormFactory

AirshipSubscriptionFormFactory

A factory for email and SMS subscription forms.

Note: This feature is not included by default, and must be loaded via the SDK plugin loader. You will not instantiate this class, but allow that loader to instantiate it for you. See the example for further information.

Note: This feature is not available to all plans; please verify with your account manager to ensure you are able to use this feature.

Constructor

new AirshipSubscriptionFormFactory()

Example
var element = document.querySelector("[rel=email-opt-in]")
var options = {
  platform: "email",
  size: "large"
  i18n: {
    en: {
      terms:
        'By opting into email, I agree to the <a href="https://brand.example/terms">terms and conditions</a>.'
    }
  }
}

// use the correct path for your region; EU, or Global
var pluginPath = isEU ?
  "https://aswpsdkeu.com/notify/v1/ua-subscription-form.min.js" :
  "https://aswpsdkus.com/notify/v1/ua-subscription-form.min.js"

UA.then(function (sdk) {
  return sdk.plugins.load("subscription-form", pluginPath)
}).then(function (formFactory) {
  formFactory.embedForm(element, options)
})

Methods

embedForm(el, options) → {Form}

Parameters:
Name Type Description
el HTMLElement

the HTML element into which the form will be rendered, replacing its contents.

options SmsFormOptions | EmailFormOptions

form options

Returns:
Type:
Form

the form

setupModalForm(options) → {ModalForm}

Instantiate a new modal subscription form.

Parameters:
Name Type Description
options ModalFormOptions

form options

Returns:
Type:
ModalForm

the modal form

Events

registration

The factory will emit a registration event whenever any form registers a new channel.

Properties:
Name Type Description
ev.detail EmailRegistrationEvent | SmsRegistrationEvent

Registration data