Report a Tagged Event in an iOS App (reportTag)

The reportTag API sends a tagged event from a mobile app to Aternity when monitoring custom activities. A custom activity for mobile apps starts and ends when the app reports specific events which match the events of an activity's signature file. If Aternity already reports these events by default, you do not need to add manual API calls. However, for some custom activities, you must manually tag and report those events using API calls.

reportTag sends the AternityContext object, which you created when you tagged an event.

Tagging a custom event with the API

Before reporting, you can optionally add further data to the Context object, like a search term, or a file size, or anything else which you want to send to the activity's signature waiting on the server side.

Before You Begin

Method Definition

reportTag sends the AternityContext object, which you created when you tagged an event. It is defined as a method belonging to the AternityContext object:

@interface AternityContext : NSObject
- (void)setContextValue:(NSString *)value
                 forKey:(NSString *)aKey;
- (NSString *)valueContextForKey:(NSString *)aKey;
- (void)removeContextForKey:(NSString *)aKey;
- (void)reportTag;
@end

Example

Before reporting, you can optionally add further data to the Context object, like a search term, or a file size, or anything else which you want to send to the activity's signature waiting on the server side.

In Objective-C:

//Create an AternityContext object called "dl_start" which tags the start of "Download"
AternityContext *dl_start= [[Aternity sharedManager] tagApplicationWithName:@"Download"
                        withPhase:AternityStartPhase];

//You can also set some values in the context object before reporting it to the server
[dl_start setContextValue:self.urlText.text forKey:@"FileName"];
[dl_start setContextValue:[fileAtrrib objectForKey:@"NSFileSize"] forKey:@"FileSize"];

//Report the AternityContext object with its tag and contextuals to the server
[dl_start reportTag];

//When user taps Cancel, tell the server that the activity is canceled. 
//Optionally add contextuals here too.
AternityContext *dl_cancel= [[Aternity sharedManager] tagCancelledWithName:@"Download"];
[dl_cancel reportTag];

//Tag and report an error to the server.
AternityContext *dl_error = [[AternityAgent sharedManager] tagErrorWithName:@"Download"];
[dl_error reportTag];

In Swift:

//Create an AternityContext object called "dl_end" which tags the end of "Download"
var dl_end: AternityContext = Aternity.sharedManager().tagApplicationWithName("Download", 
                             withPhase:AternityEndPhase)

//You can also set some values in the context object before reporting it to the server
dl_end.setContextValue(self.urlText.text forKey:"FileName")
dl_end.setContextValue(fileAtrrib.objectForKey("NSFileSize") forKey:"FileSize")

//Report the AternityContext object with its tag and contextuals to the server
dl_end.reportTag()

//When user taps Cancel, tell the server that the activity is canceled.
//Optionally add contextuals here too.
var dl_cancel: AternityContext = AternityAgent.sharedManager().tagCancelledWithName("Download")
dl_cancel.reportTag()

//Tag and report an error to the server.
var dl_error: AternityContext = AternityAgent.sharedManager().tagErrorWithName("Download")
dl_error.reportTag()