|
1 | 1 | import './ExploreContainer.css'; |
2 | 2 | import { IonButton, isPlatform } from '@ionic/react'; |
3 | | -import { AFEvent, AppsFlyer } from "appsflyer-capacitor-plugin"; |
| 3 | +import { AFEvent, AFPurchaseDetailsV2, AFPurchaseType, AppsFlyer } from "appsflyer-capacitor-plugin"; |
4 | 4 | import React from "react"; |
5 | 5 |
|
6 | 6 | interface ContainerProps { |
@@ -57,81 +57,49 @@ function generateInviteLink() { |
57 | 57 | .catch(e => alert('user invite error: ' + e)); |
58 | 58 | } |
59 | 59 |
|
60 | | -function validateAndLogInAppPurchase() { |
61 | | - if (isPlatform('android')) { |
62 | | - AppsFlyer.validateAndLogInAppPurchaseAndroid({ |
63 | | - additionalParameters: { aa: 'cc' }, |
64 | | - currency: 'usd', |
65 | | - price: '20', |
66 | | - signature: 'the_signature', |
67 | | - publicKey: 'your_public_key', |
68 | | - purchaseData: 'the_purchase_data' |
69 | | - }) |
70 | | - .then(r => alert('validateAndLogInAppPurchase success: ' + r.res)) |
71 | | - .catch(e => alert('validateAndLogInAppPurchase error: ' + e)); |
72 | | - } else if (isPlatform('ios')) { |
73 | | - AppsFlyer.validateAndLogInAppPurchaseIos({ |
74 | | - additionalParameters: { aa: 'cc' }, |
75 | | - currency: 'usd', |
76 | | - price: '20', |
77 | | - inAppPurchase: 'productIdentifier', |
78 | | - transactionId: 'transactionId' |
79 | | - }) |
80 | | - .then(r => alert('validateAndLogInAppPurchase success: ' + r.res)) |
81 | | - .catch(e => alert('validateAndLogInAppPurchase error: ' + JSON.stringify(e))); |
82 | | - } |
83 | | -} |
84 | | - |
85 | 60 | function validateAndLogInAppPurchaseV2() { |
86 | | - alert('Not implemented yet'); |
87 | | - // const purchaseDetails: AFPurchaseDetails = { |
88 | | - // purchaseType: AFPurchaseType.oneTimePurchase, |
89 | | - // purchaseToken: isPlatform('android') ? 'android_purchase_token_example' : 'ios_transaction_id_example', |
90 | | - // productId: 'com.example.product.premium' |
91 | | - // }; |
92 | | - |
93 | | - // const additionalParams = { |
94 | | - // 'test_param': 'test_value', |
95 | | - // 'custom_data': 'example_data' |
96 | | - // }; |
97 | | -// |
98 | | - // AppsFlyer.validateAndLogInAppPurchaseV2({ |
99 | | - // purchaseDetails: purchaseDetails, |
100 | | - // additionalParameters: additionalParams |
101 | | - // }) |
102 | | - // .then(result => { |
103 | | - // alert('validateAndLogInAppPurchaseV2 success: ' + JSON.stringify(result)); |
104 | | - // }) |
105 | | - // .catch(error => { |
106 | | - // alert('validateAndLogInAppPurchaseV2 error: ' + JSON.stringify(error)); |
107 | | - // }); |
| 61 | + const purchaseData: AFPurchaseDetailsV2 = { |
| 62 | + purchaseDetails: { |
| 63 | + purchaseType: AFPurchaseType.oneTimePurchase, |
| 64 | + purchaseToken: isPlatform('android') ? 'android_purchase_token_example' : 'ios_transaction_id_example', |
| 65 | + productId: 'com.example.product.premium' |
| 66 | + }, |
| 67 | + additionalParameters: { |
| 68 | + 'test_param': 'test_value', |
| 69 | + 'custom_data': 'example_data' |
| 70 | + } |
| 71 | + }; |
| 72 | + |
| 73 | + AppsFlyer.validateAndLogInAppPurchaseV2(purchaseData) |
| 74 | + .then(result => { |
| 75 | + alert('validateAndLogInAppPurchaseV2 success: ' + JSON.stringify(result)); |
| 76 | + }) |
| 77 | + .catch(error => { |
| 78 | + alert('validateAndLogInAppPurchaseV2 error: ' + JSON.stringify(error)); |
| 79 | + }); |
108 | 80 | } |
109 | 81 |
|
110 | 82 | function validateAndLogInAppPurchaseV2Subscription() { |
111 | | - alert('Not implemented yet'); |
112 | | - // const purchaseDetails: AFPurchaseDetails = { |
113 | | - // purchaseType: AFPurchaseType.subscription, |
114 | | - // purchaseToken: isPlatform('android') ? 'android_subscription_token_example' : 'ios_subscription_transaction_id_example', |
115 | | - // productId: 'com.example.subscription.monthly' |
116 | | - // }; |
117 | | - |
118 | | - // const additionalParams = { |
119 | | - // 'subscription_period': 'monthly', |
120 | | - // 'test_subscription': 'true' |
121 | | - // }; |
122 | | -// |
123 | | - // AppsFlyer.validateAndLogInAppPurchaseV2({ |
124 | | - // purchaseDetails: purchaseDetails, |
125 | | - // additionalParameters: additionalParams |
126 | | - // }) |
127 | | - // .then(result => { |
128 | | - |
129 | | - // alert('validateAndLogInAppPurchaseV2 (Subscription) success: ' + JSON.stringify(result)); |
130 | | - // }) |
131 | | - // .catch(error => |
132 | | - // { |
133 | | - // alert('validateAndLogInAppPurchaseV2 (Subscription) error: ' + JSON.stringify(error)); |
134 | | - // }); |
| 83 | + const purchaseData: AFPurchaseDetailsV2 = { |
| 84 | + purchaseDetails: { |
| 85 | + purchaseType: AFPurchaseType.subscription, |
| 86 | + purchaseToken: isPlatform('android') ? 'android_subscription_token_example' : 'ios_subscription_transaction_id_example', |
| 87 | + productId: 'com.example.subscription.monthly' |
| 88 | + }, |
| 89 | + additionalParameters: { |
| 90 | + 'subscription_period': 'monthly', |
| 91 | + 'test_subscription': 'true' |
| 92 | + } |
| 93 | + }; |
| 94 | + |
| 95 | + AppsFlyer.validateAndLogInAppPurchaseV2(purchaseData) |
| 96 | + .then(result => { |
| 97 | + |
| 98 | + alert('validateAndLogInAppPurchaseV2 (Subscription) success: ' + JSON.stringify(result)); |
| 99 | + }) |
| 100 | + .catch(error => { |
| 101 | + alert('validateAndLogInAppPurchaseV2 (Subscription) error: ' + JSON.stringify(error)); |
| 102 | + }); |
135 | 103 | } |
136 | 104 |
|
137 | 105 | function setSharingFilterForAllPartners() { |
@@ -220,12 +188,10 @@ const ExploreContainer: React.FC<ContainerProps> = () => { |
220 | 188 | <IonButton color="primary" expand="block" onClick={() => stop()}>Stop SDK</IonButton> |
221 | 189 | <IonButton color="primary" expand="block" onClick={() => generateInviteLink()}>generate Invite |
222 | 190 | Link</IonButton> |
223 | | - <IonButton color="primary" expand="block" onClick={() => validateAndLogInAppPurchase()}>validate And Log |
224 | | - IAP (Legacy)</IonButton> |
225 | | - <IonButton color="success" expand="block" onClick={() => validateAndLogInAppPurchaseV2()}>validate And Log |
226 | | - IAP V2 (One-time Purchase) - BETA</IonButton> |
227 | | - <IonButton color="success" expand="block" onClick={() => validateAndLogInAppPurchaseV2Subscription()}>validate And Log |
228 | | - IAP V2 (Subscription) - BETA</IonButton> |
| 191 | + <IonButton color="primary" expand="block" onClick={() => validateAndLogInAppPurchaseV2()}>Validate IAP |
| 192 | + (One-time Purchase)</IonButton> |
| 193 | + <IonButton color="primary" expand="block" onClick={() => validateAndLogInAppPurchaseV2Subscription()}>Validate IAP |
| 194 | + (Subscription)</IonButton> |
229 | 195 | <IonButton color="primary" expand="block" onClick={() => setSharingFilter()}>set Sharing Filter</IonButton> |
230 | 196 |
|
231 | 197 | <IonButton color="primary" expand="block" onClick={() => setSharingFilterForAllPartners()}>set Sharing |
|
0 commit comments