The Salesforce Developers website will undergo maintenance on May 29, 2024 from 3:00 a.m. UTC to 10:00 a.m. UTC. The maintenance process may affect the availability of our documentation. Please plan accordingly.

EVGCampaignHandler Block Reference

Declared in
EVGCampaign.h

Callback implemented by the app to handle potential custom data campaigns served in response to Marketing Cloud Personalization actions generated by the user interacting with the app.

For additional information, see Mobile Data Campaigns. For lifecycle details, see [EVGContext setCampaignHandler:forTarget:].

Usage Details:

  • For a view controller, it is recommended to setup handlers in viewWillAppear:, as shown in the examples in this section.
  • Validate the expected campaign data/JSON before processing, since campaigns are dynamic and designed in the Personalization web app.
  • The same campaign could be re-served, so when applicable, check if the same content is already active. For example, there’s no need to re-render the same message/UI to the user if it’s still visible. This is especially true when testing a specific experience, see [Evergage(Swizzling) handleOpenURL:].
  • Follow best practices using weak references within the handler block, to avoid retaining objects in memory longer than expected, which could lead to memory bloat and unexpected behavior. The following examples correctly use weak reference.

The following is example code that expects the featured product’s name and updates a UILabel on screen.

  • Objective-C

  • Swift