diff --git a/RNPurchases.podspec b/RNPurchases.podspec index b09d8efa..3ecb1566 100644 --- a/RNPurchases.podspec +++ b/RNPurchases.podspec @@ -24,6 +24,6 @@ Pod::Spec.new do |spec| ] spec.dependency "React-Core" - spec.dependency "PurchasesHybridCommon", '7.4.0-beta.1' + spec.dependency "PurchasesHybridCommon", '7.4.0-beta.3' spec.swift_version = '5.7' end diff --git a/android/build.gradle b/android/build.gradle index 96e7b776..8ab6101c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -121,7 +121,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion') dependencies { //noinspection GradleDynamicVersion api 'com.facebook.react:react-native:+' - implementation 'com.revenuecat.purchases:purchases-hybrid-common:7.4.0-beta.1' + implementation 'com.revenuecat.purchases:purchases-hybrid-common:7.4.0-beta.3' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.compose.ui:ui-android:1.5.4' implementation "androidx.appcompat:appcompat:1.6.1" diff --git a/ios/RNPaywallManager.m b/ios/RNPaywallManager.m index f0acc3fc..3c7e1be0 100644 --- a/ios/RNPaywallManager.m +++ b/ios/RNPaywallManager.m @@ -17,9 +17,9 @@ - (UIView *)view { if (@available(iOS 15.0, *)) { PaywallProxy *proxy = [[PaywallProxy alloc] init]; - return proxy.vc.view; + return [proxy createPaywallView].view; } else { - // TODO: log something + NSLog(@"Error: attempted to present paywalls on unsupported iOS version."); return nil; } } diff --git a/ios/RNPaywalls.m b/ios/RNPaywalls.m index 06a4325a..d72c6072 100644 --- a/ios/RNPaywalls.m +++ b/ios/RNPaywalls.m @@ -6,10 +6,44 @@ #import "RNPaywalls.h" +@interface RNPaywalls () + +@property (nonatomic, strong) id paywallProxy; + +@end + @implementation RNPaywalls RCT_EXPORT_MODULE(); +- (instancetype)initWithDisabledObservation +{ + if ((self = [super initWithDisabledObservation])) { + [self initializePaywalls]; + } + + return self; +} + +- (instancetype)init +{ + if (([super init])) { + [self initializePaywalls]; + } + return self; +} + +// `RCTEventEmitter` does not implement designated iniitializers correctly so we have to duplicate the call in both constructors. +- (void)initializePaywalls { + if (@available(iOS 15.0, *)) { + self.paywallProxy = [PaywallProxy new]; + } else { + self.paywallProxy = nil; + } +} + +// MARK: - + - (NSArray *)supportedEvents { return @[]; } @@ -18,20 +52,30 @@ - (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); } +- (PaywallProxy *)paywalls API_AVAILABLE(ios(15.0)){ + return self.paywallProxy; +} + +// MARK: - + RCT_EXPORT_METHOD(presentPaywall) { if (@available(iOS 15.0, *)) { - [PaywallProxy presentPaywall]; + [self.paywalls presentPaywall]; } else { - // TODO: log + [self logPaywallsUnsupportedError]; } } RCT_EXPORT_METHOD(presentPaywallIfNeeded:(NSString *)requiredEntitlementIdentifier) { if (@available(iOS 15.0, *)) { - [PaywallProxy presentPaywallIfNeededWithRequiredEntitlementIdentifier:requiredEntitlementIdentifier]; + [self.paywalls presentPaywallIfNeededWithRequiredEntitlementIdentifier:requiredEntitlementIdentifier]; } else { - // TODO: log + [self logPaywallsUnsupportedError]; } } +- (void)logPaywallsUnsupportedError { + NSLog(@"Error: attempted to present paywalls on unsupported iOS version."); +} + @end