react-native-purchases 7.3.0 → 7.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,6 @@ Pod::Spec.new do |spec|
24
24
  ]
25
25
 
26
26
  spec.dependency "React-Core"
27
- spec.dependency "PurchasesHybridCommon", '7.3.0'
28
- spec.swift_version = '5.0'
27
+ spec.dependency "PurchasesHybridCommon", '7.4.0-beta.1'
28
+ spec.swift_version = '5.7'
29
29
  end
@@ -29,7 +29,7 @@ android {
29
29
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
30
30
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
31
31
  versionCode 1
32
- versionName '7.3.0'
32
+ versionName '7.4.0-beta.1'
33
33
  }
34
34
 
35
35
  buildTypes {
@@ -121,6 +121,8 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
121
121
  dependencies {
122
122
  //noinspection GradleDynamicVersion
123
123
  api 'com.facebook.react:react-native:+'
124
- implementation 'com.revenuecat.purchases:purchases-hybrid-common:7.3.0'
124
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:7.4.0-beta.1'
125
125
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
126
+ implementation 'androidx.compose.ui:ui-android:1.5.4'
127
+ implementation "androidx.appcompat:appcompat:1.6.1"
126
128
  }
@@ -0,0 +1,33 @@
1
+ package com.revenuecat.purchases.react
2
+
3
+ import android.app.PendingIntent.getActivity
4
+ import android.content.Context
5
+ import android.util.AttributeSet
6
+ import android.widget.ImageView
7
+ import androidx.compose.runtime.Composable
8
+ import androidx.compose.runtime.getValue
9
+ import androidx.compose.runtime.mutableStateOf
10
+ import androidx.compose.runtime.setValue
11
+ import androidx.compose.ui.platform.AbstractComposeView
12
+ import com.facebook.react.ReactActivity
13
+ import com.facebook.react.ReactActivityDelegate
14
+ import com.facebook.react.uimanager.SimpleViewManager
15
+ import com.revenuecat.purchases.ui.revenuecatui.ExperimentalPreviewRevenueCatUIPurchasesAPI
16
+ import com.revenuecat.purchases.ui.revenuecatui.Paywall
17
+ import com.revenuecat.purchases.ui.revenuecatui.PaywallOptions
18
+
19
+ internal class Paywall @JvmOverloads constructor(
20
+ context: Context,
21
+ attrs: AttributeSet? = null,
22
+ ) : AbstractComposeView(context, attrs) {
23
+ @OptIn(ExperimentalPreviewRevenueCatUIPurchasesAPI::class)
24
+ @Composable
25
+ override fun Content() {
26
+ Paywall(
27
+ PaywallOptions.Builder(
28
+ dismissRequest = {}
29
+ )
30
+ .build()
31
+ )
32
+ }
33
+ }
@@ -0,0 +1,22 @@
1
+ package com.revenuecat.purchases.react;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.uimanager.SimpleViewManager;
6
+ import com.facebook.react.uimanager.ThemedReactContext;
7
+
8
+ public class RNPaywallManager extends SimpleViewManager<Paywall> {
9
+ public static final String REACT_CLASS = "RNPaywall";
10
+
11
+ @NonNull
12
+ @Override
13
+ public String getName() {
14
+ return REACT_CLASS;
15
+ }
16
+
17
+ @NonNull
18
+ @Override
19
+ protected Paywall createViewInstance(@NonNull ThemedReactContext themedReactContext) {
20
+ return new Paywall(themedReactContext);
21
+ }
22
+ }
@@ -0,0 +1,58 @@
1
+ package com.revenuecat.purchases.react;
2
+
3
+ import static com.revenuecat.purchases.hybridcommon.PaywallHelpersKt.presentPaywallFromFragment;
4
+
5
+ import android.app.Activity;
6
+
7
+ import androidx.annotation.NonNull;
8
+ import androidx.annotation.Nullable;
9
+ import androidx.annotation.OptIn;
10
+ import androidx.fragment.app.FragmentActivity;
11
+
12
+ import com.facebook.react.bridge.ReactApplicationContext;
13
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
14
+ import com.facebook.react.bridge.ReactMethod;
15
+ import com.revenuecat.purchases.ui.revenuecatui.ExperimentalPreviewRevenueCatUIPurchasesAPI;
16
+
17
+ @OptIn(markerClass = ExperimentalPreviewRevenueCatUIPurchasesAPI.class)
18
+ public class RNPaywallsModule extends ReactContextBaseJavaModule {
19
+ public RNPaywallsModule(ReactApplicationContext reactContext) {
20
+ super(reactContext);
21
+ }
22
+
23
+ @NonNull
24
+ @Override
25
+ public String getName() {
26
+ return "RNPaywalls";
27
+ }
28
+
29
+ @ReactMethod
30
+ public void presentPaywall() {
31
+ presentPaywall(null);
32
+ }
33
+
34
+ @ReactMethod
35
+ public void presentPaywallIfNeeded(final String requiredEntitlementIdentifier) {
36
+ presentPaywall(requiredEntitlementIdentifier);
37
+ }
38
+
39
+ private void presentPaywall(final @Nullable String requiredEntitlementIdentifier) {
40
+ final FragmentActivity fragment = getCurrentActivityFragment();
41
+ if (fragment == null) {
42
+ // TODO: log
43
+ return;
44
+ }
45
+
46
+ presentPaywallFromFragment(fragment, requiredEntitlementIdentifier);
47
+ }
48
+
49
+ private @Nullable FragmentActivity getCurrentActivityFragment() {
50
+ final Activity activity = getCurrentActivity();
51
+
52
+ if (activity instanceof FragmentActivity) {
53
+ return (FragmentActivity) activity;
54
+ } else {
55
+ return null;
56
+ }
57
+ }
58
+ }
@@ -45,7 +45,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
45
45
  private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
46
46
  private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
47
47
  public static final String PLATFORM_NAME = "react-native";
48
- public static final String PLUGIN_VERSION = "7.3.0";
48
+ public static final String PLUGIN_VERSION = "7.4.0-beta.1";
49
49
 
50
50
  private final ReactApplicationContext reactContext;
51
51
 
@@ -18,7 +18,10 @@ public class RNPurchasesPackage implements ReactPackage {
18
18
  @NonNull
19
19
  @Override
20
20
  public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
21
- return Arrays.<NativeModule>asList(new RNPurchasesModule(reactContext));
21
+ return Arrays.<NativeModule>asList(
22
+ new RNPurchasesModule(reactContext),
23
+ new RNPaywallsModule(reactContext)
24
+ );
22
25
  }
23
26
 
24
27
  // Deprecated from RN 0.47
@@ -29,6 +32,8 @@ public class RNPurchasesPackage implements ReactPackage {
29
32
  @NonNull
30
33
  @Override
31
34
  public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
32
- return Collections.emptyList();
35
+ return Arrays.asList(
36
+ new RNPaywallManager()
37
+ );
33
38
  }
34
39
  }
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './errors';
4
4
  export * from './customerInfo';
5
5
  export * from './purchases';
6
6
  export * from './offerings';
7
+ export * from './paywalls';
package/dist/index.js CHANGED
@@ -23,3 +23,4 @@ __exportStar(require("./errors"), exports);
23
23
  __exportStar(require("./customerInfo"), exports);
24
24
  __exportStar(require("./purchases"), exports);
25
25
  __exportStar(require("./offerings"), exports);
26
+ __exportStar(require("./paywalls"), exports);
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export default class PaywallView extends React.Component {
3
+ render(): React.JSX.Element;
4
+ }
5
+ export declare function presentPaywall(): void;
6
+ export declare function presentPaywallIfNeeded(requiredEntitlementIdentifier: String): void;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.presentPaywallIfNeeded = exports.presentPaywall = void 0;
33
+ var react_native_1 = require("react-native");
34
+ var react_native_2 = require("react-native");
35
+ var react_1 = __importDefault(require("react"));
36
+ var RNPaywall = (0, react_native_1.requireNativeComponent)('RNPaywall');
37
+ var RNPaywalls = react_native_2.NativeModules.RNPaywalls;
38
+ var PaywallView = /** @class */ (function (_super) {
39
+ __extends(PaywallView, _super);
40
+ function PaywallView() {
41
+ return _super !== null && _super.apply(this, arguments) || this;
42
+ }
43
+ PaywallView.prototype.render = function () {
44
+ return (
45
+ // TODO: check iOS version to fail if < 15
46
+ react_1.default.createElement(RNPaywall, __assign({}, this.props)));
47
+ };
48
+ return PaywallView;
49
+ }(react_1.default.Component));
50
+ exports.default = PaywallView;
51
+ function presentPaywall() {
52
+ // TODO: check iOS/Android version
53
+ RNPaywalls.presentPaywall();
54
+ }
55
+ exports.presentPaywall = presentPaywall;
56
+ function presentPaywallIfNeeded(requiredEntitlementIdentifier) {
57
+ // TODO: check iOS/Android version
58
+ RNPaywalls.presentPaywallIfNeeded(requiredEntitlementIdentifier);
59
+ }
60
+ exports.presentPaywallIfNeeded = presentPaywallIfNeeded;
@@ -0,0 +1,17 @@
1
+ //
2
+ // RNPaywallManager.h
3
+ // RNPurchases
4
+ //
5
+ // Created by Nacho Soto on 11/1/23.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import <React/RCTViewManager.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface RNPaywallManager : RCTViewManager
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,27 @@
1
+ //
2
+ // RNPaywallManager.m
3
+ // RNPurchases
4
+ //
5
+ // Created by Nacho Soto on 11/1/23.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ #import "RNPaywallManager.h"
10
+ @import PurchasesHybridCommon;
11
+
12
+ @implementation RNPaywallManager
13
+
14
+ RCT_EXPORT_MODULE(RNPaywall)
15
+
16
+ - (UIView *)view
17
+ {
18
+ if (@available(iOS 15.0, *)) {
19
+ PaywallProxy *proxy = [[PaywallProxy alloc] init];
20
+ return proxy.vc.view;
21
+ } else {
22
+ // TODO: log something
23
+ return nil;
24
+ }
25
+ }
26
+
27
+ @end
@@ -0,0 +1,13 @@
1
+ //
2
+ // Created by RNPaywalls.
3
+ // Copyright © 2023 RevenueCat. All rights reserved.
4
+ //
5
+
6
+ #import <React/RCTEventEmitter.h>
7
+
8
+ @import PurchasesHybridCommon;
9
+ @import RevenueCat;
10
+
11
+ @interface RNPaywalls : RCTEventEmitter <RCTBridgeModule>
12
+
13
+ @end
@@ -0,0 +1,29 @@
1
+
2
+ //
3
+ // Created by RevenueCat.
4
+ // Copyright © 2023 RevenueCat. All rights reserved.
5
+ //
6
+
7
+ #import "RNPaywalls.h"
8
+
9
+ @implementation RNPaywalls
10
+
11
+ RCT_EXPORT_MODULE();
12
+
13
+ RCT_EXPORT_METHOD(presentPaywall) {
14
+ if (@available(iOS 15.0, *)) {
15
+ [PaywallProxy presentPaywall];
16
+ } else {
17
+ // TODO: log
18
+ }
19
+ }
20
+
21
+ RCT_EXPORT_METHOD(presentPaywallIfNeeded:(NSString *)requiredEntitlementIdentifier) {
22
+ if (@available(iOS 15.0, *)) {
23
+ [PaywallProxy presentPaywallIfNeededWithRequiredEntitlementIdentifier:requiredEntitlementIdentifier];
24
+ } else {
25
+ // TODO: log
26
+ }
27
+ }
28
+
29
+ @end
package/ios/RNPurchases.m CHANGED
@@ -470,7 +470,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
470
470
  }
471
471
 
472
472
  - (NSString *)platformFlavorVersion {
473
- return @"7.3.0";
473
+ return @"7.4.0-beta.1";
474
474
  }
475
475
 
476
476
  @end
@@ -10,6 +10,8 @@
10
10
  3552B97D252CF5900098008A /* PurchasesPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3552B97C252CF5900098008A /* PurchasesPlugin.swift */; };
11
11
  35BFF4DC247DDAD3008B64DA /* PurchasesHybridCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 35BFF4DB247DDAD3008B64DA /* PurchasesHybridCommon.framework */; };
12
12
  35D0736B20AD0F740012EB8C /* Purchases.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 35D0736A20AD0F740012EB8C /* Purchases.framework */; };
13
+ 4F72072A2AF30E7E0017395F /* RNPaywallManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F7207292AF30E7E0017395F /* RNPaywallManager.m */; };
14
+ 4F7D88D52AF9666800855875 /* RNPaywalls.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F7D88D32AF9666800855875 /* RNPaywalls.m */; };
13
15
  B3E7B58A1CC2AC0600A0062D /* RNPurchases.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNPurchases.m */; };
14
16
  /* End PBXBuildFile section */
15
17
 
@@ -31,6 +33,10 @@
31
33
  3552B97C252CF5900098008A /* PurchasesPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchasesPlugin.swift; sourceTree = "<group>"; };
32
34
  35BFF4DB247DDAD3008B64DA /* PurchasesHybridCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = PurchasesHybridCommon.framework; sourceTree = "<group>"; };
33
35
  35D0736A20AD0F740012EB8C /* Purchases.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Purchases.framework; sourceTree = SOURCE_ROOT; };
36
+ 4F7207282AF30E7E0017395F /* RNPaywallManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNPaywallManager.h; sourceTree = "<group>"; };
37
+ 4F7207292AF30E7E0017395F /* RNPaywallManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNPaywallManager.m; sourceTree = "<group>"; };
38
+ 4F7D88D32AF9666800855875 /* RNPaywalls.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNPaywalls.m; sourceTree = "<group>"; };
39
+ 4F7D88D42AF9666800855875 /* RNPaywalls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNPaywalls.h; sourceTree = "<group>"; };
34
40
  B3E7B5881CC2AC0600A0062D /* RNPurchases.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNPurchases.h; sourceTree = "<group>"; };
35
41
  B3E7B5891CC2AC0600A0062D /* RNPurchases.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNPurchases.m; sourceTree = "<group>"; };
36
42
  /* End PBXFileReference section */
@@ -71,6 +77,10 @@
71
77
  35BFF4DB247DDAD3008B64DA /* PurchasesHybridCommon.framework */,
72
78
  B3E7B5881CC2AC0600A0062D /* RNPurchases.h */,
73
79
  B3E7B5891CC2AC0600A0062D /* RNPurchases.m */,
80
+ 4F7207282AF30E7E0017395F /* RNPaywallManager.h */,
81
+ 4F7207292AF30E7E0017395F /* RNPaywallManager.m */,
82
+ 4F7D88D42AF9666800855875 /* RNPaywalls.h */,
83
+ 4F7D88D32AF9666800855875 /* RNPaywalls.m */,
74
84
  134814211AA4EA7D00B7C361 /* Products */,
75
85
  35493AC8202D4BCD004DFA39 /* Frameworks */,
76
86
  3552B97B252CF5900098008A /* RNPurchases-Bridging-Header.h */,
@@ -136,8 +146,10 @@
136
146
  isa = PBXSourcesBuildPhase;
137
147
  buildActionMask = 2147483647;
138
148
  files = (
149
+ 4F7D88D52AF9666800855875 /* RNPaywalls.m in Sources */,
139
150
  B3E7B58A1CC2AC0600A0062D /* RNPurchases.m in Sources */,
140
151
  3552B97D252CF5900098008A /* PurchasesPlugin.swift in Sources */,
152
+ 4F72072A2AF30E7E0017395F /* RNPaywallManager.m in Sources */,
141
153
  );
142
154
  runOnlyForDeploymentPostprocessing = 0;
143
155
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-purchases",
3
3
  "title": "React Native Purchases",
4
- "version": "7.3.0",
4
+ "version": "7.4.0-beta.1",
5
5
  "description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -95,6 +95,6 @@
95
95
  ]
96
96
  },
97
97
  "dependencies": {
98
- "@revenuecat/purchases-typescript-internal": "7.3.0"
98
+ "@revenuecat/purchases-typescript-internal": "7.3.1"
99
99
  }
100
100
  }
@@ -2,7 +2,7 @@
2
2
  <!DOCTYPE html>
3
3
  <html>
4
4
  <head>
5
- <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/7.3.0/" />
5
+ <meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/7.4.0-beta.1/" />
6
6
  </head>
7
7
  <body>
8
8
  </body>