Skip to content

Commit 27c5b33

Browse files
committed
Update iOS support to SDK 3.10
This does not include Unity functions for any new features to 3.10.
1 parent 5b0381f commit 27c5b33

12 files changed

+458
-16
lines changed

source/Plugins/GoogleAnalyticsV3/GAIHandler.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ limitations under the License.
2424
*/
2525
public class GAIHandler {
2626
#if UNITY_IPHONE && !UNITY_EDITOR
27-
[DllImport("__Internal")]
28-
private static extern void setName(string name);
29-
public void _setName(string name){
30-
setName(name);
31-
}
32-
3327
[DllImport("__Internal")]
3428
private static extern void setOptOut(bool optOut);
3529
public void _setOptOut(bool optOut){

source/Plugins/iOS/GAI.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
#import "GAITracker.h"
1111
#import "GAITrackedViewController.h"
1212

13+
14+
typedef NS_ENUM(NSUInteger, GAIDispatchResult) {
15+
kGAIDispatchNoData,
16+
kGAIDispatchGood,
17+
kGAIDispatchError
18+
};
19+
1320
/*! Google Analytics product string. */
1421
extern NSString *const kGAIProduct;
1522

@@ -157,10 +164,24 @@ typedef enum {
157164
/*!
158165
Dispatches any pending tracking information.
159166
167+
Note that this does not have any effect on dispatchInterval, and can be used in
168+
conjunction with periodic dispatch. */
169+
- (void)dispatch;
170+
171+
/*!
172+
Dispatches the next tracking beacon in the queue, calling completionHandler when
173+
the tracking beacon has either been sent (returning kGAIDispatchGood) or an error has resulted
174+
(returning kGAIDispatchError). If there is no network connection or there is no data to send,
175+
kGAIDispatchNoData is returned.
176+
177+
Calling this method with a nil completionHandler is the same as calling the dispatch
178+
above.
179+
180+
This method can be used for background data fetching in iOS 7.0 or later.
181+
160182
It would be wise to call this when application is exiting to initiate the
161183
submission of any unsubmitted tracking information. Note that this does not
162-
have any effect on dispatchInterval, and can be used in conjuntion with
184+
have any effect on dispatchInterval, and can be used in conjunction with
163185
periodic dispatch. */
164-
- (void)dispatch;
165-
186+
- (void)dispatchWithCompletionHandler:(void (^)(GAIDispatchResult))completionHandler;
166187
@end

source/Plugins/iOS/GAIDictionaryBuilder.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
#import <Foundation/Foundation.h>
88

9+
#import "GAIEcommerceProduct.h"
10+
#import "GAIEcommerceProductAction.h"
11+
#import "GAIEcommercePromotion.h"
12+
913
/*!
1014
* Helper class to build a dictionary of hit parameters and values.
1115
* <br>
@@ -120,9 +124,21 @@
120124
Note that using this method will not set the screen name for followon hits. To
121125
do that you need to call set:kGAIDescription value:<screenName> on the
122126
GAITracker instance.
127+
128+
This method is deprecated. Use createScreenView instead.
123129
*/
124130
+ (GAIDictionaryBuilder *)createAppView;
125131

132+
/*!
133+
Returns a GAIDictionaryBuilder object with parameters specific to a screenview
134+
hit.
135+
136+
Note that using this method will not set the screen name for followon hits. To
137+
do that you need to call set:kGAIDescription value:<screenName> on the
138+
GAITracker instance.
139+
*/
140+
+ (GAIDictionaryBuilder *)createScreenView;
141+
126142
/*!
127143
Returns a GAIDictionaryBuilder object with parameters specific to an event hit.
128144
*/
@@ -175,4 +191,25 @@
175191
shipping:(NSNumber *)shipping
176192
currencyCode:(NSString *)currencyCode;
177193

194+
/*!
195+
Set the product action field for this hit.
196+
*/
197+
- (GAIDictionaryBuilder *)setProductAction:(GAIEcommerceProductAction *)productAction;
198+
199+
/*!
200+
Adds a product to this hit.
201+
*/
202+
- (GAIDictionaryBuilder *)addProduct:(GAIEcommerceProduct *)product;
203+
204+
/*!
205+
Add a product impression to this hit.
206+
*/
207+
- (GAIDictionaryBuilder *)addProductImpression:(GAIEcommerceProduct *)product
208+
impressionList:(NSString *)name
209+
impressionSource:(NSString *)source;
210+
211+
/*!
212+
Add a promotion to this hit.
213+
*/
214+
- (GAIDictionaryBuilder *)addPromotion:(GAIEcommercePromotion *)promotion;
178215
@end
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*!
2+
@header GAIEcommerceFields.h
3+
@abstract Google Analytics iOS SDK Ecommerce Hit Format Header
4+
@copyright Copyright 2014 Google Inc. All rights reserved.
5+
*/
6+
7+
#import <Foundation/Foundation.h>
8+
9+
/*!
10+
This class provides several fields and methods useful as wire format parameters for
11+
Enhanced Ecommerce. See the online developer guides for Enhanced Ecommerce for details
12+
on how to use the Enhanced Ecommerce features.
13+
*/
14+
15+
// Enhanced Ecommerce Product fields
16+
extern NSString *const kGAIProductId;
17+
extern NSString *const kGAIProductName;
18+
extern NSString *const kGAIProductBrand;
19+
extern NSString *const kGAIProductCategory;
20+
extern NSString *const kGAIProductVariant;
21+
extern NSString *const kGAIProductPrice;
22+
extern NSString *const kGAIProductQuantity;
23+
extern NSString *const kGAIProductCouponCode;
24+
extern NSString *const kGAIProductPosition;
25+
26+
extern NSString *const kGAIProductAction;
27+
28+
// product action values
29+
extern NSString *const kGAIPADetail;
30+
extern NSString *const kGAIPAClick;
31+
extern NSString *const kGAIPAAdd;
32+
extern NSString *const kGAIPARemove;
33+
extern NSString *const kGAIPACheckout;
34+
extern NSString *const kGAIPACheckoutOption;
35+
extern NSString *const kGAIPAPurchase;
36+
extern NSString *const kGAIPARefund;
37+
38+
// product action fields
39+
// used for 'purchase' and 'refund' actions
40+
extern NSString *const kGAIPATransactionId;
41+
extern NSString *const kGAIPAAffiliation;
42+
extern NSString *const kGAIPARevenue;
43+
extern NSString *const kGAIPATax;
44+
extern NSString *const kGAIPAShipping;
45+
extern NSString *const kGAIPACouponCode;
46+
// used for 'checkout' action
47+
extern NSString *const kGAICheckoutStep;
48+
extern NSString *const kGAICheckoutOption;
49+
// used for 'detail' and 'click' actions
50+
extern NSString *const kGAIProductActionList;
51+
extern NSString *const kGAIProductListSource;
52+
53+
// Enhanced Ecommerce Impressions fields
54+
extern NSString *const kGAIImpressionName;
55+
extern NSString *const kGAIImpressionListSource;
56+
extern NSString *const kGAIImpressionProduct;
57+
extern NSString *const kGAIImpressionProductId;
58+
extern NSString *const kGAIImpressionProductName;
59+
extern NSString *const kGAIImpressionProductBrand;
60+
extern NSString *const kGAIImpressionProductCategory;
61+
extern NSString *const kGAIImpressionProductVariant;
62+
extern NSString *const kGAIImpressionProductPosition;
63+
extern NSString *const kGAIImpressionProductPrice;
64+
65+
// Enhanced Ecommerce Promotions fields
66+
extern NSString *const kGAIPromotionId;
67+
extern NSString *const kGAIPromotionName;
68+
extern NSString *const kGAIPromotionCreative;
69+
extern NSString *const kGAIPromotionPosition;
70+
71+
// Promotion actions
72+
extern NSString *const kGAIPromotionAction;
73+
extern NSString *const kGAIPromotionView;
74+
extern NSString *const kGAIPromotionClick;
75+
76+
@interface GAIEcommerceFields : NSObject
77+
78+
/*!
79+
Generates an enhanced ecommerce product field. Note that field names generated by
80+
customDimensionForIndex and customMetricForIndex can be used as suffixes.
81+
82+
@param index the index of the product
83+
@param suffix the product field suffix (such as kGAIProductPrice).
84+
85+
@return an NSString representing the product field parameter
86+
*/
87+
+ (NSString *)productFieldForIndex:(NSUInteger)index suffix:(NSString *)suffix;
88+
89+
/*!
90+
Genrates an enhanced ecommerce impression list field name with an index. The return value of
91+
this method should also be used as input to the productImpressionForList method below.
92+
93+
@param index the index of the impression list
94+
95+
@return an NSString representing the impression list parameter
96+
*/
97+
+ (NSString *)impressionListForIndex:(NSUInteger)index;
98+
99+
/*!
100+
Generates an enhanced ecommerce product impression field with the impression list, product index
101+
and product suffix as parameters. The output of the method impressionListForIndex above should be
102+
used as the input list for this method. The output of customDimensionForIndex and
103+
customMetricForIndex can be used as suffixes.
104+
105+
@param list the impression list for this product impression
106+
@param index the index of this product in the impression list
107+
@param suffix the product impression suffix for this field
108+
109+
@return an NSString representing this product impression field parameter
110+
*/
111+
+ (NSString *)productImpressionForList:(NSString *)list
112+
index:(NSUInteger)index
113+
suffix:(NSString *)Suffix;
114+
115+
/*!
116+
Generates an enhanced ecommerce promotion field with an index and suffix.
117+
118+
@param index the index of the promotion
119+
@param suffix the promotion suffix (such as kGAIPromotionId)
120+
121+
@return an NSString representing this promotion field paramter
122+
*/
123+
+ (NSString *)promotionForIndex:(NSUInteger)index suffix:(NSString *)suffix;
124+
@end
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*!
2+
@header GAIEcommerceProduct.h
3+
@abstract Google Analytics iOS SDK Hit Format Header
4+
@copyright Copyright 2014 Google Inc. All rights reserved.
5+
*/
6+
7+
#import <Foundation/Foundation.h>
8+
9+
/*!
10+
* Class to construct product related information for a Google Analytics beacon. Use this class to
11+
* report information about products sold by merchants or impressions of products seen by users.
12+
* Instances of this class can be associated with both Product Actions and Product
13+
* Impression Lists.
14+
* <br>
15+
* Typical usage:
16+
* <code>
17+
* [tracker set:kGAIScreenName value:@"MyScreen"];
18+
* GAIDictionaryBuilder *builder = [GAIDictionaryBuilder createScreenView];
19+
* GAIEcommerceProduct *product = [[GAIEcommerceProduct alloc] init];
20+
* [product setId:@""PID-1234""];
21+
* [product setName:@"Space Monkeys!"];
22+
* [product setPrice:@100];
23+
* [product setQuantity:@2];
24+
* [builder addProductImpression:product impressionList:@"listName"];
25+
* [tracker send:[builder build]];
26+
* </code>
27+
*/
28+
@interface GAIEcommerceProduct : NSObject
29+
30+
/*!
31+
Sets the id that is used to identify a product in GA reports.
32+
*/
33+
- (GAIEcommerceProduct *)setId:(NSString *)productId;
34+
35+
/*!
36+
Sets the name that is used to indentify the product in GA reports.
37+
*/
38+
- (GAIEcommerceProduct *)setName:(NSString *)productName;
39+
40+
/*!
41+
Sets the brand associated with the product in GA reports.
42+
*/
43+
- (GAIEcommerceProduct *)setBrand:(NSString *)productBrand;
44+
45+
/*!
46+
Sets the category associated with the product in GA reports.
47+
*/
48+
- (GAIEcommerceProduct *)setCategory:(NSString *)productCategory;
49+
50+
/*!
51+
Sets the variant of the product.
52+
*/
53+
- (GAIEcommerceProduct *)setVariant:(NSString *)productVariant;
54+
55+
/*!
56+
Sets the price of the product.
57+
*/
58+
- (GAIEcommerceProduct *)setPrice:(NSNumber *)productPrice;
59+
60+
/*!
61+
Sets the quantity of the product. This field is usually not used with product impressions.
62+
*/
63+
- (GAIEcommerceProduct *)setQuantity:(NSNumber *)productQuantity;
64+
65+
/*!
66+
Sets the coupon code associated with the product. This field is usually not used with product
67+
impressions.
68+
*/
69+
- (GAIEcommerceProduct *)setCouponCode:(NSString *)productCouponCode;
70+
71+
/*!
72+
Sets the position of the product on the screen/product impression list, etc.
73+
*/
74+
- (GAIEcommerceProduct *)setPosition:(NSNumber *)productPosition;
75+
76+
/*!
77+
Sets the custom dimension associated with this product.
78+
*/
79+
- (GAIEcommerceProduct *)setCustomDimension:(NSUInteger)index value:(NSString *)value;
80+
81+
/*!
82+
Sets the custom metric associated with this product.
83+
*/
84+
- (GAIEcommerceProduct *)setCustomMetric:(NSUInteger)index value:(NSNumber *)value;
85+
86+
/*!
87+
Builds an NSDictionary of fields stored in this instance suitable for a product action. The
88+
index parameter is the index of this product in the product action list.
89+
<br>
90+
Normally, users will have no need to call this method.
91+
*/
92+
- (NSDictionary *)buildWithIndex:(NSUInteger)index;
93+
94+
/*!
95+
Builds an NSDictionary of fields stored in this instance suitable for an impression list. The
96+
lIndex parameter is the index of the product impression list while the index parameter is the
97+
index of this product in that impression list.
98+
<br>
99+
Normally, users will have no need to call this method.
100+
*/
101+
- (NSDictionary *)buildWithListIndex:(NSUInteger)lIndex index:(NSUInteger)index;
102+
@end

0 commit comments

Comments
 (0)