Skip to content

Commit

Permalink
Update PHC
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto committed Nov 23, 2023
1 parent 61b833d commit 2c29bc6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
2 changes: 1 addition & 1 deletion RNPurchases.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions ios/RNPaywallManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
52 changes: 48 additions & 4 deletions ios/RNPaywalls.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSString *> *)supportedEvents {
return @[];
}
Expand All @@ -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

0 comments on commit 2c29bc6

Please sign in to comment.