Content Handling

Content Handling

Android Applications

To handle content, implement the CampaignListener interface, which contains the method didCampaignArrived(intent: Intent):


class MainActivity : AppCompatActivity() {             
            fun handleCampaignContent() {
                EngageSDK.setListener(object: EngageSDK.CampaignListener {
                    override fun didCampaignArrived(campaign: CampaignContent?) {
                        //Handle campaign
                        getContent(campaign)
                    }
                })
            }
        }

Opening Content as an Activity

To launch the value campaign, you use the default widget handler Widgets Presenter:


private fun getContent(campaign: CampaignContent?){
            WidgetsPresenter.presentWidget(applicationContext, campaign)
        }

WidgetPresenter takes generated content and opens it as an Activity if the application is in the foreground;
When the app is in the background, content is sent as a notification.

iOS Applications

To handle content, implement WidgetsPresenterDelegate, which is an xib file with its own view controller that lets you present Locally Campaign contents in a collection view.

Here, a collection view is an object that manages an ordered collection of data items for presentation using customizable layouts.
widget is a visual container for the content delivered by Locally campaigns.


extension CampaignListViewController: WidgetsPresenterDelegate {
    
    func present(widget: WidgetViewController) {
    	// do something with the widget, e.g. add it to a collection view that gets reloaded to the screen
        widgets.append(widget)
    }
}