我正在尝试使用 Google Analytics 在 iOS 中实现应用内购买跟踪,但我收到以下错误:
从 Google Analytics 页面获取的确切示例代码有 2 个错误:
- (void)onPurchaseCompleted {
GAITransaction *transaction =
[GAITransaction transactionWithId:@"0_123456" // (NSString) Transaction ID, should be unique.
withAffiliation:@"In-App Store"; // (NSString) Affiliation
当我在上面编译时,它说要插入一个“]”
transaction.taxMicros = (int64_t)(0.17 * 1000000); // (int64_t) Total tax (in micros)
transaction.shippingMicros = (int64_t)(0); // (int64_t) Total shipping (in micros)
transaction.revenueMicros = (int64_t)(2.16 * 1000000); // (int64_t) Total revenue (in micros)
在下面我收到此错误:“'GAITransaction' 没有可见界面声明选择器'addItemWithSKU:name:category:priceMicros:quantity'”
[transaction addItemWithSKU:@"L_789" // (NSString) Product SKU
name:@"Level Pack: Space" // (NSString) Product name
category:@"Game expansions" // (NSString) Product category
priceMicros:(int64_t)(1.99 * 1000000) // (int64_t) Product price (in micros)
quantity:1]; // (NSInteger) Product quantity
[[GAI sharedInstance].defaultTracker sendTransaction:transaction]; // Send the transaction.
}
这里有什么问题?