【发布时间】:2017-06-16 15:18:18
【问题描述】:
我有一个关于 react native 的模块,并在这个问题的标题中抛出错误。这是模块的代码,我不知道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
【问题讨论】:
-
这是 React 生成的代码?
-
不,这是一些在 MercadoPago SDK 和 React Native 之间架起桥梁的人编写的代码
-
是的,但这并不能解决我的问题,谢谢
标签: ios objective-c swift xcode react-native