-
Notifications
You must be signed in to change notification settings - Fork 54
Analytics: Add apple store kit 2 support #1460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -354,6 +354,25 @@ public static void SetUserId(string userId) { | |
| public static void SetUserProperty(string name, string property) { | ||
| FirebaseAnalyticsInternal.SetUserProperty(name, property); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Logs an in-app purchase transaction specifically for Apple's StoreKit 2. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This method is intended for Unity developers on iOS who process transactions | ||
| /// via In-app purchases and need whish to log those purchases through Google Analytics. | ||
| /// The provided ID must map 1:1 with the native Apple `Transaction.id`. | ||
| /// If a matching transaction is not found in the apple devices purchase history then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| /// nothing will be logged to analytics. | ||
| /// | ||
| /// </remarks> | ||
| /// <param name="transactionId">The native Apple transaction identifier (e.g., | ||
| /// extracted from Unity IAP's <c>purchasedProduct.transactionID</c>).</param> | ||
| /// <returns>A Task that completes when the native StoreKit 2 transaction | ||
| /// is successfully located and logged.</returns> | ||
| public static System.Threading.Tasks.Task LogAppleTransactionAsync(string transactionId) { | ||
| return FirebaseAnalyticsInternal.LogAppleTransactionAsync(transactionId); | ||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -187,6 +187,35 @@ Press some of the buttons to log some events to your Firebase project. | |||||
| After around 5 hours, data should be visible under the *Analytics* tab in | ||||||
| the [Firebase Console](https://firebase.google.com/console/)). | ||||||
|
|
||||||
| ## iOS Testing LogAppleTransaction | ||||||
|
|
||||||
| To test the log apple transaction function, you should use the exported Xcode project and Xcode's simulated transactions. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method name 'LogAppleTransaction' and the proper noun 'Apple' should be capitalized for consistency and clarity.
Suggested change
|
||||||
| The manual test will involve running the testapp and verifying that it logs a transaction to the console. | ||||||
|
|
||||||
| - Step 1: Set up the Local Xcode Environment | ||||||
| - After building the sample for iOS and opening the exported project in Xcode: | ||||||
| - In Xcode, go to File > New > File from Template and create a StoreKit Configuration File (.storekit). | ||||||
| - Give the configuration any name. | ||||||
| - Target the `Unity-iPhone` scheme (or the relevant target for your exported app). | ||||||
| - Add at least one dummy product to this file. | ||||||
| - Do this by selecting the file in Xcode and clicking the + button in the bottom left corner. | ||||||
| - Choose a Consumable in app purchase product. | ||||||
| - Give it a Reference name of your choice (e.g. "ReferenceAppleIapProduct"). | ||||||
| - Give it a Product ID of your choice (e.g. "com.example.nonconsumable"). | ||||||
| - Make the app use the store kit file. In the top bar go to Product > Scheme > Edit Scheme... | ||||||
| - In the left hand menu select Run | ||||||
| - Select the Options tab on the top | ||||||
| - Set the StoreKit Configuration dropdown to your new .storekit file. | ||||||
| - Step 2: Validate logging transactions | ||||||
| - You can create a simulated transaction for testing. | ||||||
| - To create a simulated transaction ID: | ||||||
| - Go to Debug > StoreKit > Manage Transactions. | ||||||
| - Click the + button in the bottom left corner. | ||||||
| - Select the Consumable in app purchase product. | ||||||
| - Use the generated transaction ID in your code or test case. | ||||||
| - When you call `FirebaseAnalytics.LogAppleTransactionAsync(transactionId)` with the simulated transaction ID: | ||||||
| - It should log the transaction to the console. Both the Xcode console and firebase console should show a log for an in app purchase. | ||||||
|
|
||||||
|
|
||||||
| ## Troubleshooting | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -109,6 +109,12 @@ Support | |||||
|
|
||||||
| Release Notes | ||||||
| ------------- | ||||||
| ### Upcoming | ||||||
| - Changes | ||||||
| - Analytics: Add support for Apple's Store kit 2 transactions. Add new `LogAppleTransactionAsync` method | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The correct name for the framework is 'StoreKit 2'. Also, there is an extra space before the method name that should be removed.
Suggested change
|
||||||
| that takes in the App Store transaction string and logs the transaction. | ||||||
|
|
||||||
|
|
||||||
| ### 13.11.0 | ||||||
| - Changes | ||||||
| - General: Update to Firebase C++ SDK version 13.7.0. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo in the documentation: 'need whish' should be corrected to 'wish'.
/// via In-app purchases and wish to log those purchases through Google Analytics.