App Extensions

Add SDK to app extension target

  • To include the Apptics SDK in your app extension, add the below to your Podfile under the specific extension target. You should replace `EXTENSION_TARGET_NAME` with the actual name of your extension target.
Copiedtarget 'EXTENSION TARGET NAME' do
    pod 'AppticsExtension'
  end

Import AppticsExtension

Copiedimport AppticsExtension
Copiedimport <AppticsExtension/AppticsExtension-swift.h>

Track events in Apptics extensions

CopiedAppticsExtensionManager.trackEvent(groupname: <#T##String#>, eventName: <#T##String#>, property: <#T##[String : Any]#>, appGroup : <#T##String#>)
Copied[AppticsExtensionManager trackEventWithGroupname:<#(NSString * _Nonnull)#> eventName:<#(NSString * _Nonnull)#> property:<#(NSDictionary<NSString *,id> * _Nonnull)#> appGroup:<#(NSString * _Nonnull)#>];

Required params:

  • groupName (string) - Optional: A category or group name for the event (e.g., "Compose")
  • eventName (string) - Mandatory: The name of the event you want to track (e.g., "mail_sent")
  • property (dictionary object) - Optional: Additional data related to the event in dictionary format (e.g., ["isScheduled: "true"])
  • appgroup (string) - Mandatory: This is a dedicated app group you must create for your app and your app's extension. The main app will access the event data and send it to the server using this app group. Make sure to pass this app group via the run script during the build phase of your main app.

Logging timed events for extensions

  • Follow the below steps to track sessions or specific actions within app extensions using timed events.

Start the timed event in extension

  • Use the startTimedEventWithGroupName method from AppticsExtensionManager. This method also returns a timestamp that is needed to end the event.
CopiedNSNumber *startTime = [AppticsExtensionManager startTimedEventWithGroupname:(NSString * _Nonnull) eventName:(NSString * _Nonnull) property:(NSDictionary<NSString *,id> * _Nonnull) appGroup:(NSString * _Nonnull)];
Copiedlet startTime = AppticsExtensionManager.startTimedEvent(withGroupname: (String), eventName: (String), property: (Dictionary<String, Any>), appGroup: (String))

End the timed event in extension

  • Pass the startTime returned by startTimedEvent method to the endTimedEvent method to stop the timer for the specific event.
Copied[AppticsExtensionManager endTimedEventWithGroupname:(NSString * _Nonnull) eventName:(NSString * _Nonnull) andStartTime:startTime];
CopiedAppticsExtensionManager.endTimedEvent(withGroupname: (String), eventName: (String), andStartTime: startTime)