Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Application tried to present a nil modal view controller on target in React Native Objective-C extension

$
0
0

I am trying to port an iOS app over to React Native.

In this iOS app, one of the functions that needs to be done is to integrate it with a PayPal library (which is currently deprecated - we want to move away from it at some point later this year, but do not have the resources to do so now).

All we're doing with this library is obtaining a unique code from PayPal - that requires a View Controller to pop up, accept client credentials and return a code giving access.

I am extremely new to Objective-C.

I've got this so far (note: I have not included all the methods/properties but can include any missing):

@implementation PaypalSdk- (IBAction)obtainConsent {  // Choose whichever scope-values apply in your case. See `PayPalOAuthScopes.h` for a complete list of available scope-values.  NSSet *scopeValues = [NSSet setWithArray:@[kPayPalOAuth2ScopeOpenId, kPayPalOAuth2ScopeEmail, kPayPalOAuth2ScopeAddress, kPayPalOAuth2ScopePhone]];  PayPalProfileSharingViewController *psViewController;  psViewController = [[PayPalProfileSharingViewController alloc] initWithScopeValues:scopeValues                                                                       configuration:self.payPalConfig                                                                            delegate:self];  // Present the PayPalProfileSharingViewController  [self presentViewController:psViewController animated:YES completion:nil];}RCT_EXPORT_MODULE()RCT_EXPORT_METHOD(generateCode: (RCTResponseSenderBlock)callback) {    [PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction : @"PRODUCTIONKEYHERE",                                                           PayPalEnvironmentSandbox : @"SANDBOXKEYHERE"}];    [self obtainConsent];    // TODO: eventually pass correctly generated code here    callback(@[[NSNull null], @"code"]);}@end

I am basing this off of this library:

https://github.com/paypal/PayPal-iOS-SDK/blob/master/SampleApp/PayPal-iOS-SDK-Sample-App/ZZMainViewController.m

And this documentation:

https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/profile_sharing_mobile.md

However when trying what I am above, I get the following error:

React Native error screen

How exactly should I resolve this? It seems to need a View Controller but I'm not totally sure how to launch one from React Native in this context.

All we're trying to get is the shared profile information.

And just for reference, this is my .h file:

#import "RCTBridgeModule.h"@interface PaypalSdk : UIViewController <RCTBridgeModule, PayPalProfileSharingDelegate>@property(nonatomic, strong, readwrite) NSString *environment;@property(nonatomic, strong, readwrite) NSString *resultText;@end

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>