AMAAppMetrica class
- Instance methods
- Properties
- Method descriptions
- +activateReporterWithConfiguration:
- +activateWithConfiguration:
- +clearAppEnvironment
- +pauseSession
- +reportAdRevenue:onFailure:
- +reportECommerce:onFailure:
- +reportEvent:onFailure:
- +reportEvent:parameters:onFailure:
- +reportExternalAttribution:source:onFailure:
- +reportRevenue:onFailure:
- +reportUserProfile:onFailure:
- +reporterForAPIKey:
- +requestStartupIdentifiersWithCompletionQueue:completionBlock:
- +requestStartupIdentifiersWithKeys:completionQueue:completionBlock:
- +resumeSession
- +sendEventsBuffer
- +setAppEnvironmentValue:forKey:
- +setDataSendingEnabled:
- +setupWebViewReporting:onFailure:
- +trackOpeningURL:
- Property descriptions
Methods of the class are used for configuring the library.
Instance methods
Initializes a reporter with the extended configuration. |
|
Initializes the library in an app with the extended startup configuration. |
|
Deleting all key-value data associated with all future events. |
|
Pauses the session. |
|
Sends information about advertising revenue to the AppMetrica server. |
|
Sends a message about an E-commerce event. |
|
Sends an event message. |
|
Sends an event message with additional parameters. |
|
Sends external attribution data to AppMetrica. |
|
Sends information about the purchase to the AppMetrica server. |
|
Sends information about a user profile update. |
|
Creates a reporter for sending events to an additional API key. |
|
+requestStartupIdentifiersWithCompletionQueue:completionBlock: |
Requests all predefined IDs. |
+requestStartupIdentifiersWithKeys:completionQueue:completionBlock: |
Requests IDs for specific keys. |
Resumes the session or creates a new one if the session timeout has expired. |
|
Sends stored events from the buffer. |
|
Sets a key-value pair associated with all future events. |
|
Enables/disables sending statistics to the AppMetrica server. |
|
Adds a JavaScript interface with the AppMetrica name in a window to the specified WebView. This lets you send client events from JavaScript code. |
|
Processes the URL that opened the app. |
Properties
The current UUID. |
|
Controls the accuracy of location tracking used by the internal location manager. |
|
Indicates whether AppMetrica was activated. |
|
Enable/disable background tracking of location updates. |
|
The current appmetrica_device_id_hash. |
|
The current appmetrica_device_id. |
|
The current version of the AppMetrica library. |
|
Enables/disables sending location of the device. |
|
Sets the ID of the user profile. |
Method descriptions
+activateReporterWithConfiguration:
+ (void)activateReporterWithConfiguration:(AMAReporterConfiguration *)configuration;
Initializes a reporter with the extended configuration.
The configuration of the reporter should be initialized before the first call to the reporter. Otherwise, the configuration of the reporter is ignored.
The reporter should be activated with the configuration using a different API key instead of the app's API key.
Parameters:
|
The instance of the AMAReporterConfiguration class which contains the extended configuration for the reporter. |
+activateWithConfiguration:
+ (void)activateWithConfiguration:(AMAAppMetricaConfiguration *)configuration;
Initializes the library in an app with the extended startup configuration.
Parameters:
|
The instance of the AMAAppMetricaConfiguration class which contains the extended startup configuration for the library. |
+clearAppEnvironment
+ (void)clearAppEnvironment;
Cleaning the app environment, such as deleting all key-value data associated with all future events.
+pauseSession
+ (void)pauseSession;
Pauses the session.
Note
The session duration depends on the specified timeout. If the time interval between pausing and resuming the session is less than the specified timeout, the current session will be resumed; otherwise, a new one will be created.
For more information about sessions, see Tracking user activity.
+reportAdRevenue:onFailure:
+ (void)reportAdRevenue:(AMAAdRevenueInfo *)adRevenue
onFailure:(nullable void (^)(NSError *error))onFailure;
Sends information about advertising revenue to the AppMetrica server.
Parameters:
|
The instance of the AMAAdRevenueInfo class which contains information about advertising revenue. |
|
A callback method to be called in the event of an error. |
+reportECommerce:onFailure:
+ (void)reportECommerce:(AMAECommerce *)eCommerce
onFailure:(nullable void (^)(NSError *error))onFailure;
Sends a message about an E-commerce event.
Parameters:
|
The AMAECommerce class instance. |
|
A callback method to be called in the event of an error. |
+reportEvent:onFailure:
+ (void)reportEvent:(NSString *)name
onFailure:(nullable void (^)(NSError *error))onFailure;
Sends an event message.
Parameters:
|
Short name or description of the event. |
|
The block that is executed when an error occurs. The error is passed as a block argument. |
+reportEvent:parameters:onFailure:
+ (void)reportEvent:(NSString *)name
parameters:(nullable NSDictionary *)params
onFailure:(nullable void (^)(NSError *error))onFailure;
Sends an event message with additional parameters.
Parameters:
|
Short name or description of the event. |
|
Parameters as |
|
A callback method to be called in the event of an error. |
+reportExternalAttribution:source:onFailure:
+ (void)reportExternalAttribution:(NSDictionary *)attribution
source:(AMAAttributionSource)source
onFailure:(nullable void (^)(NSError *error))onFailure;
Sends external attribution data to AppMetrica.
Parameters:
|
A dictionary with attribution data. It must be convertible to JSON, or else the method fails with the |
|
The attribution data source. Source list. |
|
A callback method to be called in the event of an error. The error is passed as an argument. |
+reportRevenue:onFailure:
+ (void)reportRevenue:(AMARevenueInfo *)revenueInfo
onFailure:(nullable void (^)(NSError *error))onFailure;
Sends information about the purchase to the AppMetrica server.
Parameters:
|
The instance of the AMARevenueInfo class which contains information about a purchase. |
|
A callback method to be called in the event of an error. |
+reportUserProfile:onFailure:
+ (void)reportUserProfile:(AMAUserProfile *)userProfile
onFailure:(nullable void (^)(NSError *error))onFailure;
Sends information about a user profile update.
Parameters:
|
The instance of the AMAUserProfile class which contains information about the user profile. |
|
A callback method to be called in the event of an error. |
+reporterForAPIKey:
+ (nullable id<AMAAppMetricaReporting>)reporterForAPIKey:(NSString *)APIKey;
Creates a reporter for sending events to an additional API key.
To initialize a reporter with the extended configuration, use the activateReporterWithConfiguration: method. The configuration of the reporter should be initialized before the first call to the reporter. Otherwise, the configuration of the reporter is ignored.
Parameters:
|
An API key that differs from the app's API key. |
Returns:
The instance that implements the AMAAppMetricaReporting protocol for the specified API key.
+requestStartupIdentifiersWithCompletionQueue:completionBlock:
+ (void)requestStartupIdentifiersWithCompletionQueue:(nullable dispatch_queue_t)queue
completionBlock:(AMAIdentifiersCompletionBlock)block;
Getting all predefined IDs
Parameters:
|
Queue for sending a block. If the value is zero, the main queue is used. |
|
The block will be sent when available IDs appear or in case of an error. Predefined IDs are:
If they are available at the time of calling, the block is sent immediately. See the |
+requestStartupIdentifiersWithKeys:completionQueue:completionBlock:
+ (void)requestStartupIdentifiersWithKeys:(NSArray<AMAStartupKey> *)keys
completionQueue:(nullable dispatch_queue_t)queue
completionBlock:(AMAIdentifiersCompletionBlock)block;
Getting IDs for specific keys
Parameters:
|
An array of identification keys for the query. See |
|
Queue for sending a block. If the value is zero, the main queue is used. |
|
The block will be sent when available IDs appear or in case of an error. If they are available at the time of calling, the block is sent immediately. See the |
+resumeSession
+ (void)resumeSession;
Resumes the session, or creates a new one if the session timeout has expired.
Note
The session duration depends on the specified timeout. If the time interval between pausing and resuming the session is less than the specified timeout, the current session will be resumed; otherwise, a new one will be created.
For more information about sessions, see Tracking user activity.
+sendEventsBuffer
+ (void)sendEventsBuffer;
Sends stored events from the buffer.
AppMetrica SDK does not send an event immediately after it occurred. The library stores event data in the buffer. The +sendEventsBuffer
method sends data from the buffer and flushes it. Use the method to force sending stored events after passing important checkpoints of user scenarios.
Alert
Frequent use of the method can lead to increased outgoing internet traffic and energy consumption.
+setAppEnvironmentValue:forKey:
+ (void)setAppEnvironmentValue:(nullable NSString *)value
forKey:(NSString *)key;
Setting key-value data to be used as additional information associated with all future events.
If the value is zero, the previously set key value is deleted. Nothing is done if the key wasn't added.
Parameters:
|
Value. |
|
Key. |
+setDataSendingEnabled:
+ (void)setDataSendingEnabled:(BOOL)enabled;
Enables/disables sending statistics to the AppMetrica server.
For more information about using the method, see Disabling and enabling sending statistics.
Note
Disabling sending also turns off sending data from all reporters that initialized with the other API key.
Parameters:
|
A flag indicating that sending statistics is enabled. The default value is Possible values:
|
+setupWebViewReporting:onFailure:
+ (void)setupWebViewReporting:(id<AMAJSControlling>)controller
onFailure:(nullable void (^)(NSError *error))onFailure;
Adds a JavaScript interface with the AppMetrica name in a window to the specified webview. This lets you send client events from JavaScript code.
Notes:
- The method must be called from the main queue.
- The method is not available on tvOS.
- Call this method before loading any content. We recommend calling this method before creating a webview and before adding your scripts to WKUserContentController. For more information, see Usage examples.
Parameters:
|
The |
|
A callback method to be called in the event of an error. |
+trackOpeningURL:
+ (void)trackOpeningURL:(NSURL *)URL;
Processes the URL that opened the app.
Used for tracking app openings via deeplink.
Parameters:
|
URL that opened the app. |
Property descriptions
uuid
@property (class, nonatomic, readonly) NSString *UUID;
Retrieves the current UUID.
accurateLocationTrackingEnabled
@property (class, nonatomic, getter=isAccurateLocationTrackingEnabled) BOOL accurateLocationTrackingEnabled;
Controls the accuracy of location tracking used by the internal location manager.
If set to YES
, the location manager attempts to use the most accurate location data available.
This property takes effect only if the isLocationTrackingEnabled
parameter is set to YES
, and the location
wasn't set manually using the customLocation
property.
activated
@property (class, assign, readonly, getter=isActivated) BOOL activated;
Indicates whether AppMetrica was activated.
Note
Use this property to check whether AppMetrica has already been activated, typically to avoid redundant activation calls or to make sure that statistics collection is running.
allowsBackgroundLocationUpdates
@property (class, nonatomic) BOOL allowsBackgroundLocationUpdates;
Enable/disable background tracking of location updates. Disabled by default.
customLocation
@property (class, nonatomic, nullable) CLLocation *customLocation;
Sets custom location of the device.
deviceIDHash
@property (class, nonatomic, nullable, readonly) NSString *deviceIDHash;
Retrieves the appmetrica_device_id_hash.
deviceID
@property (class, nonatomic, nullable, readonly) NSString *deviceID;
Retrieves the appmetrica_device_id.
libraryVersion
@property (class, nonatomic, readonly) NSString *libraryVersion;
Returns the current version of the AppMetrica library.
locationTrackingEnabled
@property (class, nonatomic, getter=isLocationTrackingEnabled) BOOL locationTrackingEnabled;
Enables/disables sending location of the device .
userProfileID
@property (class, nonatomic, nullable) NSString *userProfileID;
Sets the ID of the user profile. AppMetrica doesn't display predefined attributes
in the web interface if ProfieId sending isn't configured.