No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UnityAnalytics.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #import <UnityAds/UnityAnalyticsAcquisitionType.h>
  2. NS_ASSUME_NONNULL_BEGIN
  3. /**
  4. * `UnityAnalytics` is a static class with methods for sending analytics events
  5. */
  6. @interface UnityAnalytics : NSObject
  7. /**
  8. * Sends an item acquired event to Unity Analytics
  9. *
  10. * @param transactionId Unique Identifier that can be used to identify the transaction in which the item was acquired. It is recommended to use the transactionId from the app store.
  11. * @param itemId Identifier for the item that is acquired
  12. * @param transactionContext Description about the game context in which the item was acquired. Example : "third_level_shop"
  13. * @param level Developer defined level that the player was on when the item was acquired
  14. * @param itemType Developer defined type that the item is grouped into
  15. * @param amount Number of items acquired
  16. * @param balance Number of items that the player now has after the transaction
  17. * @param acquisitionType The type of acquisition : `kUnityAnalyticsAcquisitionTypeSoft` or `kUnityAnalyticsAcquisitionTypePremium`
  18. */
  19. + (void)onItemAcquired: (NSString *)transactionId itemId: (NSString *)itemId transactionContext: (NSString *)transactionContext level: (NSString *)level itemType: (NSString *)itemType amount: (float)amount balance: (float)balance acquisitionType: (UnityAnalyticsAcquisitionType)acquisitionType;
  20. /**
  21. * Send an item spent event to Unity Analyitcs
  22. *
  23. * @param transactionId Unique Identifier that can be used to identify the transaction in which the item was spent. It is recommended to use the transactionId from the app store.
  24. * @param itemId Identifier for the item that is spent
  25. * @param transactionContext Description about the game context in which the item was spent. Example : "third_level_shop"
  26. * @param level Developer defined level that the player was on when the item was spent
  27. * @param itemType Developer defined type that the item is grouped into
  28. * @param amount Number of items spent
  29. * @param balance Number of items that the player now has after the transaction
  30. * @param acquisitionType The type of acquisition : `kUnityAnalyticsAcquisitionTypeSoft` or `kUnityAnalyticsAcquisitionTypePremium`
  31. */
  32. + (void)onItemSpent: (NSString *)transactionId itemId: (NSString *)itemId transactionContext: (NSString *)transactionContext level: (NSString *)level itemType: (NSString *)itemType amount: (float)amount balance: (float)balance acquisitionType: (UnityAnalyticsAcquisitionType)acquisitionType;
  33. /**
  34. * Sends a level fail event to Unity Analytics
  35. *
  36. * @param levelIndex The index for the level that the player failed
  37. */
  38. + (void)onLevelFail: (NSString *)levelIndex;
  39. /**
  40. * Sends a level up event to Unity Analytics
  41. *
  42. * @param theNewLevelIndex The index for the new level that the player just unlocked
  43. */
  44. + (void)onLevelUp: (NSString *)theNewLevelIndex;
  45. /**
  46. * Send an Ad Complete event to Unity Analytics
  47. *
  48. * @param placementId The Placement ID for the Ad
  49. * @param network Add network name
  50. * @param rewarded Boolean indicating if the Ad was rewarded or not
  51. */
  52. + (void)onAdComplete: (NSString *)placementId network: (NSString *)network rewarded: (BOOL)rewarded;
  53. /**
  54. * Send an In App Purchase Transaction event to Unity Analytics
  55. *
  56. * @param productId The Product Id specified by the developer for a promo
  57. * @param amount The price to purchase the promo
  58. * @param currency The iso currency code for the amount
  59. * @param isPromo A boolean specifying if the transaction came from a promo
  60. * @param receipt A json string of containing information about the transaction
  61. */
  62. + (void)onIapTransaction: (NSString *)productId amount: (float)amount currency: (NSString *)currency isPromo: (BOOL)isPromo receipt: (NSString *)receipt;
  63. /**
  64. * Send an analytics event.
  65. * The dictionary structure must be 100% correct when using this method or the event will not be validated and sent.
  66. *
  67. * @param jsonObject Json dictionary with all necessary fields that will be sent to analytics
  68. *
  69. * @note It is strongly encouraged to use a specific event handler so that the event format is correct
  70. */
  71. + (void)onEvent: (NSDictionary<NSString *, NSObject *> *)jsonObject;
  72. @end
  73. NS_ASSUME_NONNULL_END