From b927f791a9e8188f713b979020cc27f236cd5e8a Mon Sep 17 00:00:00 2001 From: Sergey Korney Date: Thu, 11 Jul 2024 18:42:24 +0500 Subject: [PATCH] 1.6.17 --- CHANGELOG.md | 18 +- README.md | 216 ++++++++++++++++-- example/android/app/build.gradle | 1 + example/ios/Podfile | 1 + example/src/App.tsx | 20 +- example/src/affise/AffiseApiWidget.tsx | 171 ++------------ example/src/affise/AffiseWidget.tsx | 9 +- .../src/affise/components/AffiseButton.tsx | 19 ++ example/src/affise/factories/ApiFactory.ts | 158 +++++++++++++ .../{ => factories}/DefaultEventsFactory.ts | 0 package.json | 2 +- src/Export.ts | 12 +- src/callback/OnDeeplinkCallback.ts | 1 - src/deeplink/DeeplinkValue.ts | 26 +++ src/deeplink/OnDeeplinkCallback.ts | 3 + src/events/base/AffiseCustomEventProps.ts | 5 + src/events/base/AffiseEvent.ts | 4 +- src/events/base/AffiseEventProps.ts | 4 + src/events/base/NativeEvent.ts | 5 +- src/events/custom/CustomId01Event.ts | 5 +- src/events/custom/CustomId02Event.ts | 5 +- src/events/custom/CustomId03Event.ts | 5 +- src/events/custom/CustomId04Event.ts | 5 +- src/events/custom/CustomId05Event.ts | 5 +- src/events/custom/CustomId06Event.ts | 5 +- src/events/custom/CustomId07Event.ts | 5 +- src/events/custom/CustomId08Event.ts | 5 +- src/events/custom/CustomId09Event.ts | 5 +- src/events/custom/CustomId10Event.ts | 5 +- src/events/custom/UserCustomEvent.ts | 6 +- .../custom/UserCustomSubscriptionEvent.ts | 18 +- src/events/predefined/AchieveLevelEvent.ts | 5 +- src/events/predefined/AdRevenueEvent.ts | 5 +- src/events/predefined/AddPaymentInfoEvent.ts | 5 +- src/events/predefined/AddToCartEvent.ts | 5 +- src/events/predefined/AddToWishlistEvent.ts | 5 +- src/events/predefined/ClickAdvEvent.ts | 5 +- .../predefined/CompleteRegistrationEvent.ts | 5 +- src/events/predefined/CompleteStreamEvent.ts | 5 +- src/events/predefined/CompleteTrialEvent.ts | 5 +- .../predefined/CompleteTutorialEvent.ts | 5 +- src/events/predefined/ContactEvent.ts | 5 +- .../predefined/ContentItemsViewEvent.ts | 5 +- .../predefined/CustomizeProductEvent.ts | 5 +- src/events/predefined/DeepLinkedEvent.ts | 5 +- src/events/predefined/DonateEvent.ts | 5 +- src/events/predefined/FindLocationEvent.ts | 5 +- .../predefined/InitiateCheckoutEvent.ts | 5 +- .../predefined/InitiatePurchaseEvent.ts | 5 +- src/events/predefined/InitiateStreamEvent.ts | 5 +- src/events/predefined/InviteEvent.ts | 5 +- .../predefined/LastAttributedTouchEvent.ts | 5 +- src/events/predefined/LeadEvent.ts | 5 +- src/events/predefined/ListViewEvent.ts | 5 +- src/events/predefined/LoginEvent.ts | 5 +- .../OpenedFromPushNotificationEvent.ts | 5 +- src/events/predefined/OrderCancelEvent.ts | 5 +- src/events/predefined/OrderEvent.ts | 5 +- src/events/predefined/OrderItemAddedEvent.ts | 5 +- src/events/predefined/OrderItemRemoveEvent.ts | 5 +- .../OrderReturnRequestCancelEvent.ts | 5 +- .../predefined/OrderReturnRequestEvent.ts | 5 +- src/events/predefined/PurchaseEvent.ts | 5 +- src/events/predefined/RateEvent.ts | 5 +- src/events/predefined/ReEngageEvent.ts | 5 +- src/events/predefined/ReserveEvent.ts | 5 +- src/events/predefined/SalesEvent.ts | 5 +- src/events/predefined/ScheduleEvent.ts | 5 +- src/events/predefined/SearchEvent.ts | 5 +- src/events/predefined/ShareEvent.ts | 5 +- src/events/predefined/SpendCreditsEvent.ts | 5 +- .../predefined/StartRegistrationEvent.ts | 5 +- src/events/predefined/StartTrialEvent.ts | 5 +- src/events/predefined/StartTutorialEvent.ts | 5 +- .../predefined/SubmitApplicationEvent.ts | 5 +- src/events/predefined/SubscribeEvent.ts | 5 +- src/events/predefined/TravelBookingEvent.ts | 5 +- .../predefined/UnlockAchievementEvent.ts | 5 +- src/events/predefined/UnsubscribeEvent.ts | 5 +- src/events/predefined/UpdateEvent.ts | 5 +- src/events/predefined/ViewAdvEvent.ts | 5 +- src/events/predefined/ViewCartEvent.ts | 5 +- src/events/predefined/ViewContentEvent.ts | 5 +- src/events/predefined/ViewItemEvent.ts | 5 +- src/events/predefined/ViewItemsEvent.ts | 5 +- .../AffiseCustomSubscriptionEventProps.ts | 6 + .../AffiseSubscriptionEventProps.ts | 4 + .../subscription/BaseSubscriptionEvent.ts | 12 +- .../subscription/ConvertedOfferEvent.ts | 14 +- .../ConvertedOfferFromRetryEvent.ts | 14 +- .../subscription/ConvertedTrialEvent.ts | 14 +- .../ConvertedTrialFromRetryEvent.ts | 14 +- .../subscription/FailedOfferFromRetryEvent.ts | 14 +- .../subscription/FailedOfferiseEvent.ts | 14 +- .../subscription/FailedSubscriptionEvent.ts | 14 +- .../FailedSubscriptionFromRetryEvent.ts | 14 +- src/events/subscription/FailedTrialEvent.ts | 14 +- .../subscription/FailedTrialFromRetryEvent.ts | 14 +- src/events/subscription/InitialOfferEvent.ts | 14 +- .../subscription/InitialSubscriptionEvent.ts | 14 +- src/events/subscription/InitialTrialEvent.ts | 14 +- src/events/subscription/OfferInRetryEvent.ts | 14 +- .../ReactivatedSubscriptionEvent.ts | 14 +- .../subscription/RenewedSubscriptionEvent.ts | 14 +- .../RenewedSubscriptionFromRetryEvent.ts | 14 +- .../subscription/SubscriptionInRetryEvent.ts | 14 +- src/events/subscription/TrialInRetryEvent.ts | 14 +- .../subscription/UnsubscriptionEvent.ts | 14 +- src/index.ts | 52 ++++- src/module/AffiseKeyValue.ts | 15 -- src/module/AffiseModules.ts | 1 + src/module/link/AffiseLinkCallback.ts | 1 + src/native/AffiseApiMethod.ts | 15 +- src/native/AffiseNative.ts | 101 ++++---- src/native/NativeBasePlatform.ts | 4 +- src/native/utils/DataMapper.ts | 37 +++ src/native/utils/DebugUtils.ts | 27 +-- 117 files changed, 1030 insertions(+), 544 deletions(-) create mode 100644 example/src/affise/components/AffiseButton.tsx create mode 100644 example/src/affise/factories/ApiFactory.ts rename example/src/affise/{ => factories}/DefaultEventsFactory.ts (100%) delete mode 100644 src/callback/OnDeeplinkCallback.ts create mode 100644 src/deeplink/DeeplinkValue.ts create mode 100644 src/deeplink/OnDeeplinkCallback.ts create mode 100644 src/events/base/AffiseCustomEventProps.ts create mode 100644 src/events/base/AffiseEventProps.ts create mode 100644 src/events/subscription/AffiseCustomSubscriptionEventProps.ts create mode 100644 src/events/subscription/AffiseSubscriptionEventProps.ts create mode 100644 src/module/link/AffiseLinkCallback.ts create mode 100644 src/native/utils/DataMapper.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 91239aa..954cca1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,25 @@ # Changelog +## [1.6.17] - 2024-07-11 + +### Added + +- New module `Link` support. +- New module `AndroidId` support. + +### Changed + +- Update `registerDeeplinkCallback` change uri to convenient values. +- Update api `Affise.getStatus` moved to `Affise.module.getStatus`. +- Update api `Affise.moduleStart` moved to `Affise.module.moduleStart`. +- Update api `Affise.getModulesInstalled` moved to `Affise.module.getModulesInstalled`. + ## [1.6.16] - 2024-07-03 ### Fixed -- AGP error for `crossplatform`. -- Event timestamp field for `crossplatform`. +- AGP error. +- Event timestamp field. ### Changed diff --git a/README.md b/README.md index 4a0ccbc..2ec6956 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ - [Modules](#modules) - [Android](#android) - [iOS](#ios) + - [Module Advertising](#module-advertising) + - [Module Link](#module-link) - [Initialize](#initialize) - [Domain](#domain) - [Requirements](#requirements) @@ -45,6 +47,9 @@ - [Deeplinks](#deeplinks) - [Android](#android-2) - [iOS](#ios-2) + - [AppLinks](#applinks) + - [Android](#android-3) + - [iOS](#ios-3) - [Offline mode](#offline-mode) - [Disable tracking](#disable-tracking) - [Disable background tracking](#disable-background-tracking) @@ -63,7 +68,7 @@ - [Debug](#debug) - [Validate credentials](#validate-credentials) - [Troubleshoots](#troubleshoots) - - [iOS](#ios-3) + - [iOS](#ios-4) # Description @@ -95,13 +100,13 @@ yarn add affise-attribution-lib If module start type is `manual`, then call: ```typescript -Affise.moduleStart(AffiseModules.ADVERTISING) +Affise.module.moduleStart(AffiseModules.ADVERTISING) ``` Get list of installed modules: ```typescript -Affise.getModulesInstalled().then((modules) => { +Affise.module.getModulesInstalled().then((modules) => { console.log(`Modules: ${modules}`); }); ``` @@ -114,6 +119,7 @@ Add modules to Android project |---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------| | `ADVERTISING` | [![module-advertising](https://img.shields.io/maven-central/v/com.affise/module-advertising?label=latest)](https://mvnrepository.com/artifact/com.affise/module-advertising) | `Auto` | | `ANDROIDID` | [![module-androidid](https://img.shields.io/maven-central/v/com.affise/module-androidid?label=latest)](https://mvnrepository.com/artifact/com.affise/module-androidid) | `Auto` | +| `LINK` | [![module-link](https://img.shields.io/maven-central/v/com.affise/module-link?label=latest)](https://mvnrepository.com/artifact/com.affise/module-link) | `Auto` | | `NETWORK` | [![module-network](https://img.shields.io/maven-central/v/com.affise/module-network?label=latest)](https://mvnrepository.com/artifact/com.affise/module-network) | `Auto` | | `PHONE` | [![module-phone](https://img.shields.io/maven-central/v/com.affise/module-phone?label=latest)](https://mvnrepository.com/artifact/com.affise/module-phone) | `Auto` | | `STATUS` | [![module-status](https://img.shields.io/maven-central/v/com.affise/module-status?label=latest)](https://mvnrepository.com/artifact/com.affise/module-status) | `Auto` | @@ -127,6 +133,7 @@ dependencies { // Affise modules implementation "com.affise:module-advertising:$affise_version" implementation "com.affise:module-androidid:$affise_version" + implementation "com.affise:module-link:$affise_version" implementation "com.affise:module-network:$affise_version" implementation "com.affise:module-phone:$affise_version" implementation "com.affise:module-status:$affise_version" @@ -140,6 +147,7 @@ Add modules to iOS project | Module | Version | Start | |---------------|:------------------------------------------------------------------------------------:|----------| | `ADVERTISING` | [`1.6.33`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Manual` | +| `LINK` | [`1.6.33`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | | `STATUS` | [`1.6.33`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | Example [example/ios/Podfile](example/ios/Podfile) @@ -150,6 +158,7 @@ target 'YourAppProject' do # Affise Modules pod 'AffiseModule/Advertising', `1.6.33` + pod 'AffiseModule/Link', `1.6.33` pod 'AffiseModule/Status', `1.6.33` end ``` @@ -166,6 +175,36 @@ end Open `info.plist` and add key `NSUserTrackingUsageDescription` with string value. For more information [read requirements](#requirements) +#### Module Advertising + +`iOS` + +This module required to Use [`IDFA`](https://developer.apple.com/documentation/adsupport/asidentifiermanager/advertisingidentifier) (Identifier for advertisers) + +> **Warning** +> +> πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯ +> +> Module Advertising requires `NSUserTrackingUsageDescription` key in `info.plist` +> +> Application **will crash** if key not present +> +> πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯ + +Open `info.plist` and add key `NSUserTrackingUsageDescription` with string value. For more information [read requirements](#requirements) + +#### Module Link + +Return last url in chan of redirection + +πŸŸ₯Support MAX 10 redirectionsπŸŸ₯ + +```typescript +Affise.module.linkResolve("SITE_WITH_REDIRECTION", (redirectUrl) => { + // handle redirect url +}); +``` + ### Initialize After dependency is added, and project is sync with `npm install` and initialize. @@ -390,7 +429,7 @@ AddToCartEvent() ## Events tracking -> Demo app [DefaultEventsFactory.ts](example/src/affise/DefaultEventsFactory.ts) +> Demo app [DefaultEventsFactory.ts](example/src/affise/factories/DefaultEventsFactory.ts) For example, we want to track what items usually user adds to shopping cart. To send event first create it with following code @@ -722,19 +761,62 @@ To use this feature, create file with name `partner_key` in your app assets dire ## Deeplinks -Register deeplink callback right after `Affise.settings({affiseAppId, secretKey}).start()` +> **Warning** +> +> πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯ +> +> Deeplinks support only **CUSTOM** scheme **NOT** `http` or `https` +> +> For `http` or `https` read how to setup [AppLinks](#applinks) +> +> πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯ + +To integrate deeplink support you need: + +- Follow how to set up deeplinks for [Android](#android-2) or [iOS](#ios-2) + +- Register deeplink callback right after `Affise.settings({affiseAppId, secretKey}).start()` ```typescript -Affise.registerDeeplinkCallback((uri) => { - // Handle deeplink +Affise.registerDeeplinkCallback((value) => { + // full uri "scheme://host/path?parameters" + const deeplink = value.deeplink; + + // separated for convenience + const scheme = value.scheme; + const host = value.host; + const path = value.path; + const queryParametersMap = value.parameters; + + if((queryParametersMap[""] || []).includes("")) { + // handle value + } }); ``` +Test Android DeepLink via terminal command: + +```terminal +adb shell am start -a android.intent.action.VIEW -d "YOUR_SCHEME://YOUR_DOMAIN/somepath?param=1\&list=some\&list=other\&list=" +``` + +Test iOS DeepLink via terminal command: + +```terminal +xcrun simctl openurl booted "YOUR_SCHEME://YOUR_DOMAIN/somepath?param=1&list=some&list=other&list=1" +``` + ### Android To integrate deeplink support in android you need: -Add intent filter to `AndroidManifest.xml` as in [`example/android/app/src/main/AndroidManifest.xml`](example/android/app/src/main/AndroidManifest.xml), +- Add intent filter to one of your activities [`AndroidManifest.xml example`](example/android/app/src/main/AndroidManifest.xml) + +- Add **custom** scheme (**NOT** `http` or `https`) and host to filter + +Example: `YOUR_SCHEME://YOUR_DOMAIN` + +Example: `myapp://mydomain.com` ```xml @@ -745,7 +827,7 @@ Add intent filter to `AndroidManifest.xml` as in [`example/android/app/src/main/ + android:scheme="YOUR_SCHEME" /> ``` @@ -753,9 +835,7 @@ Add intent filter to `AndroidManifest.xml` as in [`example/android/app/src/main/ To integrate deeplink support in iOS you need: -Add deeplink handler to `AppDelegate.mm` as in [`example/ios/AffiseAttributionLibExample/AppDelegate.mm`](example/ios/AffiseAttributionLibExample/AppDelegate.mm) - -- [React Docs](https://reactnavigation.org/docs/deep-linking/#set-up-with-bare-react-native-projects) +- Add deeplink handler [React Docs](https://reactnavigation.org/docs/deep-linking/#set-up-with-bare-react-native-projects). [`example AppDelegate.mm`](example/ios/AffiseAttributionLibExample/AppDelegate.mm) ```objective-c - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url @@ -766,9 +846,11 @@ Add deeplink handler to `AppDelegate.mm` as in [`example/ios/AffiseAttributionLi } ``` -Add key `CFBundleURLTypes` to `Info.plist` +- Add key `CFBundleURLTypes` to `Info.plist` [`example Info.plist`](example/ios/AffiseAttributionLibExample/Info.plist) -Example: [`example/ios/AffiseAttributionLibExample/Info.plist`](example/ios/AffiseAttributionLibExample/Info.plist) +Example: `YOUR_SCHEME://YOUR_DOMAIN` + +Example: `myapp://mydomain.com` ```xml CFBundleURLTypes @@ -786,6 +868,110 @@ Example: [`example/ios/AffiseAttributionLibExample/Info.plist`](example/ios/Affi ``` +## AppLinks + +> **Warning** +> +> πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯ +> +> You must owne website domain. +> +> And has ability to add file `https://yoursite/.well-known/apple-app-site-association` for iOS support +> +> And has ability to add file `https://yoursite/.well-known/assetlinks.json` for Android support +> +> πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯πŸŸ₯ + +- Follow how to set up AppLinks for [Android](#android-3) or [iOS](#ios-3) + +### Android + +To integrate applink support in android you need: + +- Add intent filter to one of your activities [`AndroidManifest.xml example`](example/android/app/src/main/AndroidManifest.xml) + +- Add `https` or `http` scheme and host to filter + +Example: `https://YOUR_DOMAIN` + +Example: `https://mydomain.com` + +```xml + + + + + + + + +``` + +- Associate your app with your website. [Read Google instructions](https://developer.android.com/studio/write/app-link-indexing#associatesite)
+ How To Associate your app with your website + + --- + + After setting up URL support for your app, the App Links Assistant generates a Digital Assets Links file you can use to [associate your website with your app](https://developer.android.com/training/app-links/verify-android-applinks#web-assoc). + + As an alternative to using the Digital Asset Links file, you can [associate your site and app in Search Console](https://support.google.com/webmasters/answer/6212023). + + If you're using [Play App Signing](https://support.google.com/googleplay/android-developer/answer/9842756) for your app, then the certificate fingerprint produced by the App Links Assistant usually doesn't match the one on users' devices. In this case, you can find the correct Digital Asset Links JSON snippet for your app in your [Play Console](https://play.google.com/console/) developer account under **Release** > **Setup** > **App signing**. + + To associate your app and your website using the App Links Assistant, click **Open Digital Asset Links File Generator** from the App Links Assistant and follow these steps: + + ![app-links-assistant-dal-file-generator_2x](https://developer.android.com/static/studio/images/write/app-links-assistant-dal-file-generator_2x.png) + **Figure 2**. Enter details about your site and app to generate a Digital Asset Links file. + + 1. Enter your **Site domain** and your [**Application ID**](https://developer.android.com/studio/build/configure-app-module#set-application-id). + + 2. To include support in your Digital Asset Links file for [One Tap sign-in](https://developers.google.com/identity/one-tap/android/overview), select **Support sharing credentials between the app and the website** and enter your site's sign-in URL.This adds the following string to your Digital Asset Links file declaring that your app and website share sign-in credentials: `delegate_permission/common.get_login_creds`. + + 3. Specify the [signing config](https://developer.android.com/studio/publish/app-signing#sign-auto) or select a [keystore file](https://developer.android.com/studio/publish/app-signing#certificates-keystores). + + Make sure you select the right release config or keystore file for the release build or the debug config or keystore file for the debug build of your app. If you want to set up your production build, use the release config. If you want to test your build, use the debug config. + + 4. Click **Generate Digital Asset Links file**. + 5. Once Android Studio generates the file, click **Save file** to download it. + 6. Upload the `assetlinks.json` file to your site, with read access for everyone, at `https://yoursite/.well-known/assetlinks.json`. + + > **Important** + > + > The system verifies the Digital Asset Links file via the encrypted HTTPS protocol. Make sure that the **assetlinks.json** file is accessible over an HTTPS connection, regardless of whether your app's intent filter includes **https**. + + 7. Click **Link and Verify** to confirm that you've uploaded the correct Digital Asset Links file to the correct location. + + Learn more about associating your website with your app through the Digital Asset Links file in Declare website associations. + + --- + +
+ +### iOS + +To integrate deeplink support in iOS you need: + +- Follow how to set up applink in the [official documentation](https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app). + +- Associate your app with your website. [Supporting associated domains](https://developer.apple.com/documentation/xcode/supporting-associated-domains) + +- [Configuring an associated domain](https://developer.apple.com/documentation/xcode/configuring-an-associated-domain/) + +- Add key `com.apple.developer.associated-domains` to `Info.plist` + +Example: `https://YOUR_DOMAIN` + +Example: `https://mydomain.com` + +```xml +com.apple.developer.associated-domains + + applinks:YOUR_DOMAIN + +``` + ## Offline mode In some scenarios you would want to limit Affise network usage, to pause that activity call anywhere in your application following code after Affise start: @@ -961,7 +1147,7 @@ In examples above `ReferrerKey.CLICK_ID` is used, but many others is available: ## Get module state ```typescript -Affise.getStatus(AffiseModules.STATUS, (response) => { +Affise.module.getStatus(AffiseModules.STATUS, (response) => { // handle status response }); ``` diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 7abf571..79e627b 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -256,6 +256,7 @@ dependencies { // Affise modules implementation "com.affise:module-advertising:$affise_version" implementation "com.affise:module-androidid:$affise_version" + implementation "com.affise:module-link:$affise_version" implementation "com.affise:module-network:$affise_version" implementation "com.affise:module-phone:$affise_version" implementation "com.affise:module-status:$affise_version" diff --git a/example/ios/Podfile b/example/ios/Podfile index 1c9a0a3..61c9d00 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -29,6 +29,7 @@ target 'AffiseAttributionLibExample' do # Affise Modules pod 'AffiseModule/Advertising', '1.6.33' pod 'AffiseModule/Status', '1.6.33' + pod 'AffiseModule/Link', '1.6.33' target 'AffiseAttributionLibExampleTests' do inherit! :complete diff --git a/example/src/App.tsx b/example/src/App.tsx index 1ac0769..366d16f 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import {Button, SafeAreaView, StyleSheet, View} from 'react-native'; +import {Alert, Button, SafeAreaView, StyleSheet, View} from 'react-native'; import { Affise } from 'affise-attribution-lib'; @@ -25,15 +25,23 @@ export default function App() { .start(); // Start Affise SDK // Deeplinks https://github.com/affise/sdk-react#deeplinks - Affise.registerDeeplinkCallback((url) => { - console.log(`Deeplink: ${url}`); - setDeeplink(`Deeplink: ${url}`); + Affise.registerDeeplinkCallback((value) => { + console.log(`Deeplink: ${value}`); + setDeeplink(`Deeplink: ${value}`); + const parameters = Object.entries(value.parameters).map(([k, v]) => `${k}=[${v.join(", ")}]`).join("; "); + Alert.alert("Deeplink", `${value.deeplink}\n\n` + + `scheme: "${value.scheme}"\n` + + `host: "${value.host}"\n` + + `path: "${value.path}"\n` + + `parameters: [${parameters}]`, [ + {text: 'OK', onPress: () => {}}, + ]); }); // Debug: network request/response - Affise.debug.network((request, response) => + Affise.debug.network((_request, response) => { - console.log(`Affise: ${request}`); + // console.log(`Affise: ${request}`); console.log(`Affise: ${response}`); }); diff --git a/example/src/affise/AffiseApiWidget.tsx b/example/src/affise/AffiseApiWidget.tsx index 197aa4c..e8ed633 100644 --- a/example/src/affise/AffiseApiWidget.tsx +++ b/example/src/affise/AffiseApiWidget.tsx @@ -1,6 +1,7 @@ import React, {Component} from "react"; -import {Button, ScrollView, StyleSheet, TextInput, View} from "react-native"; -import {Affise, AffiseModules, ProviderType, ReferrerKey, SKAdNetwork} from 'affise-attribution-lib'; +import {FlatList, StyleSheet, TextInput, View} from "react-native"; +import {AffiseButton} from "./components/AffiseButton"; +import {api, ApiFactory} from "./factories/ApiFactory"; interface Props { value?: string; @@ -11,16 +12,23 @@ interface State { } export class AffiseApiWidget extends Component { + + apiFactory: ApiFactory; + apis: api[]; + constructor(props: Props) { super(props); this.state = { ...props }; + + this.apiFactory = new ApiFactory(this.output); + this.apis = this.apiFactory.create(); } - setCallback = (callback: string) => { + output = (value: string) => { this.setState({ - value: callback + value: value }); }; @@ -31,149 +39,18 @@ export class AffiseApiWidget extends Component { - - + /> )} /> ); diff --git a/example/src/affise/components/AffiseButton.tsx b/example/src/affise/components/AffiseButton.tsx new file mode 100644 index 0000000..c0ea2ce --- /dev/null +++ b/example/src/affise/components/AffiseButton.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import type {PropsWithChildren} from "react"; +import {Button, ColorValue} from "react-native"; + +type SectionProps = PropsWithChildren<{ + title: string; + color: ColorValue; + onPress?: (() => void); +}>; + +export function AffiseButton({title, color, onPress}: SectionProps) { + return ( +