diff --git a/CHANGELOG.md b/CHANGELOG.md index 95bda51..1ebd6e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [1.6.20] - 2024-09-11 + +### Added + +- Module `Subscription` support. + +### Changed + +- Update native iOS to [`1.6.40`](https://github.com/affise/sdk-ios/blob/1.6.40/CHANGELOG.md). +- Update native Android to [`1.6.44`](https://github.com/affise/sdk-android/blob/v1.6.44/CHANGELOG.md). + ## [1.6.19] - 2024-08-19 ### Added @@ -112,6 +123,7 @@ - Api `Affise.android.getReferrer` to `Affise.getReferrer` - Api `Affise.android.getReferrerValue` to `Affise.getReferrerValue` +[1.6.20]: https://github.com/affise/sdk-react/compare/1.6.19...1.6.20 [1.6.19]: https://github.com/affise/sdk-react/compare/1.6.18...1.6.19 [1.6.18]: https://github.com/affise/sdk-react/compare/1.6.17...1.6.18 [1.6.17]: https://github.com/affise/sdk-react/compare/1.6.16...1.6.17 diff --git a/README.md b/README.md index 7fdd5bd..41d783c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,11 @@ - [iOS](#ios) - [Module Advertising](#module-advertising) - [Module Link](#module-link) + - [Module Status](#module-status) + - [Module Subscription](#module-subscription) + - [AffiseProductType](#affiseproducttype) - [Initialize](#initialize) + - [Before application is published](#before-application-is-published) - [Domain](#domain) - [Requirements](#requirements) - [Android](#android-1) @@ -117,19 +121,20 @@ Affise.module.getModulesInstalled().then((modules) => { Add modules to Android project -| Module | Version | Start | -|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------| -| `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` | +| Module | Version | Start | +|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------| +| `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` | +| `SUBSCRIPTION` | [![module-status](https://img.shields.io/maven-central/v/com.affise/module-subscription?label=latest)](https://mvnrepository.com/artifact/com.affise/module-subscription) | `Auto` | Example [`example/android/app/build.gradle`](example/android/app/build.gradle) ```gradle -final affise_version = '1.6.42' +final affise_version = '1.6.44' dependencies { // Affise modules @@ -139,6 +144,7 @@ dependencies { implementation "com.affise:module-network:$affise_version" implementation "com.affise:module-phone:$affise_version" implementation "com.affise:module-status:$affise_version" + implementation 'com.affise:module-subscription:1.6.44' } ``` @@ -146,11 +152,12 @@ dependencies { Add modules to iOS project -| Module | Version | Start | -|---------------|:------------------------------------------------------------------------------------:|----------| -| `ADVERTISING` | [`1.6.39`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Manual` | -| `LINK` | [`1.6.39`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | -| `STATUS` | [`1.6.39`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | +| Module | Version | Start | +|----------------|:------------------------------------------------------------------------------------:|----------| +| `ADVERTISING` | [`1.6.40`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Manual` | +| `LINK` | [`1.6.40`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | +| `STATUS` | [`1.6.40`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | +| `SUBSCRIPTION` | [`1.6.40`](https://github.com/CocoaPods/Specs/tree/master/Specs/0/3/d/AffiseModule/) | `Auto` | Example [example/ios/Podfile](example/ios/Podfile) @@ -159,9 +166,10 @@ target 'YourAppProject' do # ... # Affise Modules - pod 'AffiseModule/Advertising', `1.6.39` - pod 'AffiseModule/Link', `1.6.39` - pod 'AffiseModule/Status', `1.6.39` + pod 'AffiseModule/Advertising', `1.6.40` + pod 'AffiseModule/Link', `1.6.40` + pod 'AffiseModule/Status', `1.6.40` + pod 'AffiseModule/Subscription', `1.6.40` end ``` @@ -207,6 +215,62 @@ Affise.module.linkResolve("SITE_WITH_REDIRECTION", (redirectUrl) => { }); ``` +#### Module Status + +> **Warning** +> +> 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 +> +> If `getStatus` return an error or working more than 2 minutes +> +> Please see section [validation credentials](#validate-credentials) +> +> 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 + +```typescript +Affise.module.getStatus(AffiseModules.STATUS, (response) => { + // handle status response +}); +``` + +#### Module Subscription + +Get products by ids: + +```typescript +const ids = ["exampple.product.id_1", "exampple.product.id_2"]; + +Affise.module.fetchProducts(ids, (result) => { + if (result.isSuccess) { + const value = result.asSuccess; + const products: AffiseProduct[] = value.products; + const invalidIds: string[] = value.invalidIds; + } else { + const error: string = result.asFailure; + } +}); +``` + +Purchase product: + +```typescript +// Specify product type for correct affise event +Affise.module.purchase(product, AffiseProductType.CONSUMABLE, (result) => { + if (result.isSuccess) { + const purchasedInfo: AffisePurchasedInfo = result.asSuccess; + } else { + const error: string = result.asFailure; + } +}); +``` + +##### AffiseProductType + +- `CONSUMABLE` +- `NON_CONSUMABLE` +- `RENEWABLE_SUBSCRIPTION` +- `NON_RENEWABLE_SUBSCRIPTION` + ### Initialize After dependency is added, and project is sync with `npm install` and initialize. @@ -244,6 +308,18 @@ Check if library is initialized Affise.isInitialized(); ``` +#### Before application is published + +> **Warning** +> +> 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 +> +> Please make sure your credentials are valid +> +> Visit section [validation credentials](#validate-credentials) +> +> 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 + #### Domain Set SDK server domain: @@ -1180,6 +1256,16 @@ In examples above `ReferrerKey.CLICK_ID` is used, but many others is available: ## Get module state +> **Warning** +> +> 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 +> +> If `getStatus` return an error or working more than 2 minutes +> +> Please see section [validation credentials](#validate-credentials) +> +> 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 + ```typescript Affise.module.getStatus(AffiseModules.STATUS, (response) => { // handle status response diff --git a/affise-attribution-native.podspec b/affise-attribution-native.podspec index ade55c7..ce29d18 100644 --- a/affise-attribution-native.podspec +++ b/affise-attribution-native.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,mm,swift}" s.dependency "React-Core" - s.dependency 'AffiseInternal', '1.6.39' + s.dependency 'AffiseInternal', '1.6.40' # Don't install the dependencies when we run `pod install` in the old architecture. if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then diff --git a/android/build.gradle b/android/build.gradle index 5a25b2e..6f568e2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,7 @@ buildscript { // Buildscript is evaluated before everything else so we can't use getExtOrDefault def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["AffiseAttributionNative_kotlinVersion"] ext { - affise_version = '1.6.42' + affise_version = '1.6.44' agp_version = '7.2.2' } diff --git a/android/src/main/java/com/affise/attribution/react/AffiseAttributionNativeModule.kt b/android/src/main/java/com/affise/attribution/react/AffiseAttributionNativeModule.kt index 977c2f6..05c8f69 100644 --- a/android/src/main/java/com/affise/attribution/react/AffiseAttributionNativeModule.kt +++ b/android/src/main/java/com/affise/attribution/react/AffiseAttributionNativeModule.kt @@ -22,6 +22,7 @@ class AffiseAttributionNativeModule( init { (reactContext.applicationContext as? Application)?.let { app -> apiWrapper = AffiseApiWrapper(app) + updateActivity() apiWrapper?.react() apiWrapper?.setCallback { name, map -> val data = Arguments.createMap().apply { @@ -43,8 +44,17 @@ class AffiseAttributionNativeModule( return NAME } + private fun updateActivity() { + apiWrapper?.let { + if (it.activity == null) { + it.activity = currentActivity + } + } + } + @ReactMethod fun invokeMethod(apiName: String, data: ReadableMap, result: Promise) { + updateActivity() apiWrapper?.call(AffiseApiMethod.from(apiName), data.toHashMap(), ResultWrapper(result)) } diff --git a/android/src/main/java/com/affise/attribution/react/ResultWrapper.kt b/android/src/main/java/com/affise/attribution/react/ResultWrapper.kt index 5122493..7b9fc26 100644 --- a/android/src/main/java/com/affise/attribution/react/ResultWrapper.kt +++ b/android/src/main/java/com/affise/attribution/react/ResultWrapper.kt @@ -1,10 +1,10 @@ package com.affise.attribution.react -import com.affise.attribution.internal.callback.AffiseResult +import com.affise.attribution.internal.callback.InternalResult import com.facebook.react.bridge.Arguments import com.facebook.react.bridge.Promise -class ResultWrapper(private val promise: Promise) : AffiseResult { +class ResultWrapper(private val promise: Promise) : InternalResult { override fun success(data: Any?) { promise.resolve(data?.asNativeData()) } diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 63e5274..6bda0a8 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -248,7 +248,7 @@ android { } } -final affise_version = '1.6.42' +final affise_version = '1.6.44' dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) @@ -260,6 +260,7 @@ dependencies { implementation "com.affise:module-network:$affise_version" implementation "com.affise:module-phone:$affise_version" implementation "com.affise:module-status:$affise_version" + implementation "com.affise:module-subscription:$affise_version" //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules diff --git a/example/ios/AffiseAttributionLibExample.xcodeproj/project.pbxproj b/example/ios/AffiseAttributionLibExample.xcodeproj/project.pbxproj index 96f0142..ea6aab8 100644 --- a/example/ios/AffiseAttributionLibExample.xcodeproj/project.pbxproj +++ b/example/ios/AffiseAttributionLibExample.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; + 2BD048D22C905E06004AF20C /* DemoStore.storekit in Resources */ = {isa = PBXBuildFile; fileRef = 2BD048D12C905E06004AF20C /* DemoStore.storekit */; }; 7699B88040F8A987B510C191 /* libPods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests.a */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ @@ -37,6 +38,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = AffiseAttributionLibExample/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = AffiseAttributionLibExample/main.m; sourceTree = ""; }; 19F6CBCC0A4E27FBF8BF4A61 /* libPods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2BD048D12C905E06004AF20C /* DemoStore.storekit */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DemoStore.storekit; path = AffiseAttributionLibExample/DemoStore.storekit; sourceTree = ""; }; 3B4392A12AC88292D35C810B /* Pods-AffiseAttributionLibExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AffiseAttributionLibExample.debug.xcconfig"; path = "Target Support Files/Pods-AffiseAttributionLibExample/Pods-AffiseAttributionLibExample.debug.xcconfig"; sourceTree = ""; }; 5709B34CF0A7D63546082F79 /* Pods-AffiseAttributionLibExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AffiseAttributionLibExample.release.xcconfig"; path = "Target Support Files/Pods-AffiseAttributionLibExample/Pods-AffiseAttributionLibExample.release.xcconfig"; sourceTree = ""; }; 5B7EB9410499542E8C5724F5 /* Pods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests.debug.xcconfig"; path = "Target Support Files/Pods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests/Pods-AffiseAttributionLibExample-AffiseAttributionLibExampleTests.debug.xcconfig"; sourceTree = ""; }; @@ -86,6 +88,7 @@ 13B07FAE1A68108700A75B9A /* AffiseAttributionLibExample */ = { isa = PBXGroup; children = ( + 2BD048D12C905E06004AF20C /* DemoStore.storekit */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.mm */, 13B07FB51A68108700A75B9A /* Images.xcassets */, @@ -242,6 +245,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2BD048D22C905E06004AF20C /* DemoStore.storekit in Resources */, 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); diff --git a/example/ios/AffiseAttributionLibExample.xcodeproj/xcshareddata/xcschemes/AffiseAttributionLibExample.xcscheme b/example/ios/AffiseAttributionLibExample.xcodeproj/xcshareddata/xcschemes/AffiseAttributionLibExample.xcscheme index afd7863..eb022f9 100644 --- a/example/ios/AffiseAttributionLibExample.xcodeproj/xcshareddata/xcschemes/AffiseAttributionLibExample.xcscheme +++ b/example/ios/AffiseAttributionLibExample.xcodeproj/xcshareddata/xcschemes/AffiseAttributionLibExample.xcscheme @@ -67,6 +67,9 @@ isEnabled = "YES"> + + { // Initialize https://github.com/affise/sdk-react#initialize @@ -56,18 +59,27 @@ export default function App() { return ( - +