Handling callbacks
What gets emitted
Subscribing to system events
import AmplySDK
class SdkEventsAdapter: SystemEventsListener {
func onEvent(event: EventInterface) {
print("Amply system event: \(event.name) props: \(event.properties)")
// Example: log to your analytics tool
if event.name == "CampaignShown" {
Analytics.log("amply_campaign_shown", params: event.properties)
}
}
}
// Hold a strong reference from your own side (e.g., on AppDelegate) so the adapter stays alive.
let adapter = SdkEventsAdapter()
amply.setSystemEventsListener(listener: adapter)import tools.amply.sdk.events.EventInterface
import tools.amply.sdk.events.SystemEventsListener
class SdkEventsAdapter : SystemEventsListener {
override fun onEvent(event: EventInterface) {
Log.d("Amply", "system event: ${event.name} props=${event.properties}")
if (event.name == "CampaignShown") {
Analytics.log("amply_campaign_shown", event.properties)
}
}
}
amply.setSystemEventsListener(SdkEventsAdapter())React Native hook
Pending events at startup
When to use this API vs ignore it
One listener at a time (native iOS / Android)
Related
Last updated