Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:firebase_analytics_platform_interface/firebase_analytics_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,43 @@ class FirebaseAnalytics extends FirebasePluginPlatform {
);
}

/// Logs the standard `in_app_purchase` event.
///
/// This event signifies that an item(s) was purchased by a user.
///
/// This API supports manually logging in-app purchase events on iOS and Android.
/// This is especially useful in cases where purchases happen outside the native
/// billing systems (e.g. custom payment flows).
Future<void> logInAppPurchase({
String? currency,
bool? freeTrial,
double? price,
bool? priceIsDiscounted,
String? productID,
String? productName,
int? quantity,
bool? subscription,
num? value,
}) {
if (!Platform.isIOS) {
throw UnimplementedError('logInAppPurchase() is only supported on iOS.');
}
return _delegate.logEvent(
name: 'in_app_purchase',
parameters: filterOutNulls(<String, Object?>{
_CURRENCY: currency,
_FREE_TRIAL: freeTrial,
_PRICE: price,
_PRICE_IS_DISCOUNTED: priceIsDiscounted,
_PRODUCT_ID: productID,
_PRODUCT_NAME: productName,
_QUANTITY: quantity,
_SUBSCRIPTION: subscription,
_VALUE: value,
}),
);
}

/// Sets the duration of inactivity that terminates the current session.
///
/// The default value is 1800000 milliseconds (30 minutes).
Expand Down Expand Up @@ -1547,3 +1584,24 @@ const String _PROMOTION_ID = 'promotion_id';

/// The name of a product promotion
const String _PROMOTION_NAME = 'promotion_name';

/// Whether the purchase is a free trial
const String _FREE_TRIAL = 'free_trial';

/// The price of the item
const String _PRICE = 'price';

/// Whether the price is discounted
const String _PRICE_IS_DISCOUNTED = 'price_is_discounted';

/// The ID of the product
const String _PRODUCT_ID = 'product_id';

/// The name of the product
const String _PRODUCT_NAME = 'product_name';

/// The quantity of the product
const String _QUANTITY = 'quantity';

/// Whether the purchase is a subscription
const String _SUBSCRIPTION = 'subscription';
Loading