Can Amplitude track event from keyboard extension?

192 Views Asked by At

I can track/record event from container app by Amplitude. I use the code bellow

Amplitude.instance().logEvent("Launch")

but when I write the bellow line

Amplitude.instance().logEvent("Share Catmoji Keyboard Extension")

in keyboard extension

The event does not record in amplitude dashboard.

Can anyone faced this issue? please help me.

1

There are 1 best solutions below

0
On

Yes you can log events from App Extensions. I know this works in share extensions in production. You have to initialize Amplitude in the viewDidLoad of the principal view controller. According to the Amplitude docs this should work for all App Extensions except WatchOS, so I would imagine if you intialize Amplitude in your UIInputViewController subclass's viewDidLoad method it would work:

Amplitude.instance().initializeApiKey("{YOUR_API_KEY}")