我有一个反应原生的模块,并在这个问题的标题中抛出错误。这是模块的代码,我不知道swift或objective-c,所以我需要你解释我像“swift for idiots”
#import "CheckoutMercadoPagoModule.h"
#import "AppDelegate.h"
@import MercadoPagoSDK;
@implementation CheckoutMercadoPagoModule
RCT_EXPORT_MODULE()
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
RCT_EXPORT_METHOD(startCheckout:(NSString *)publicKey:(NSString *)prefId:(RCTPromiseResolveBlock)resolve:(RCTPromiseRejectBlock)reject) {
[MercadoPagoContext setPublicKey: publicKey];
[MercadoPagoContext setSiteID:@"MLA"];
UINavigationController *checkoutFlow = [MPFlowBuilder startCheckoutViewController:prefId callback:^(Payment *payment) {
NSDictionary *dictionary = @{@"id": payment._id, @"status": payment.status};
resolve(dictionary);
} callbackCancel:nil];
AppDelegate *share = (AppDelegate *)[UIApplication sharedApplication].delegate;
UINavigationController *nav = (UINavigationController *) share.window.rootViewController;
[nav presentViewController:checkoutFlow animated:YES completion:^{}];
}
@end
答案 0 :(得分:0)
尝试使用Window本身而不是rootviewcontroller
[share.window presentViewController:checkoutFlow animated:YES completion:^{}];
}