Skip to main content

I don’t know if paywalls do not work in objective-c or if I’m doing something wrong. Well it currently doesn’t work that way and crashes on initialisation:

RCPaywallViewController *paywallController = leRCPaywallViewController alloc] init];

<self presentViewController:paywallController animated:YES completion:nil];

Hi,

It looks like they can be implemented in ObjC, but we don’t have a code example (yet)

In the meantime, you could take this SwiftUI example as a framework and translate it to ObjC (https://www.revenuecat.com/docs/displaying-paywalls)


I made it to work, like this:
 

        RCPurchases sharedPurchases] getOfferingsWithCompletion:^(RCOfferings *offerings, NSError *error) {

          if (offerings.current) {

              RCPaywallViewController *paywallController = waRCPaywallViewController alloc] initWithOffering:offerings.current displayCloseButton:YES];

              <self presentViewController:paywallController animated:YES completion:nil];

 

          } else if (error) {

              (SentrySDK captureError:error];

 

            // optional error handling

              NSLog(@"Offerings error: %@", error);

          }

        }];

But delegate doesn’t work. So I can’t get back info that user purchased subscription.


I ran in to this yesterday and submitted a PR to expose the delegate variable to Objective-C. 


Reply