Leanplum iOS In-app message templates changes

Starting from Leanplum iOS SDK version 2.7.0 there are changes to the in-app messages templates. The templates are now separated and in their own files.
Previously all templates were in the LPMessageTemplates.h and LPMessageTemplates.m files which were downloadable with the SDK.

The templates are located under MessageTemplates folder in the SDK (Leanplum-iOS-SDK/Leanplum-SDK/Classes/MessageTemplates/).

If you are using version 3.0.0 or newer, check the updated documentation article:
Customizing in-app message templates


iOS Custom Templates GitHub repo

We have new examples on GitHub available in both Swift and Objective-C: Leanplum-iOS-CustomTemplates

Override a template


The files LPMessageTemplates.h and LPMessageTemplates.m come with the SDK. Just download the SDK, unzip, and put the template files in your project. Then, initialize them before the [Leanplum start] call with:

[LPMessageTemplates sharedTemplates];

Take a look at LPMessageTemplates.m to see how the messages are implemented.

If there are issues with the files existing in the Pods SDK, register the override this way:
In the header file:

#ifndef LPMessageTemplatesClass
#define LPMessageTemplatesClass LPMessageTemplatesOverride

Modify the code in the implementation file (.m) and then register the override:


The messages are split. Override the templates by defining using the same template name.

func overrideTemplates() {
// Ensure the default templates are initialised

//Define the template you want to override again, using its exact same name "Open URL"
Leanplum.defineAction(LPMT_OPEN_URL_NAME, of: .action, withArguments: [ActionArg.init(name: LPMT_ARG_URL, string: "https://www.leanplum.com")], withResponder: { (ctx) -> Bool in
         // Implement the desired handling
         print("Custom open url")
         return true

The code for the templates can be found in the SDK in GitHub.

Defining a new template

Depending on the version, the Swift code for the Action Arguments might differ:


The same goes for the Action Arguments initialization:

ActionArg.init(name: "URL", string: "https://www.leanplum.com")
LPActionArg.init(named: "URL",, with: "https://www.leanplum.com")
LPActionArg(named: "URL", with: "https://www.leanplum.com")