iOS支付宝H5支付无法返回APP解决方案这篇文章中,使用的是富文本编辑,粘贴的代码很丑,在这篇文章中使用Markdown编辑器把代码又粘贴了一遍。
代码如下:
/**
* 支付接口
*
* @param orderStr 订单信息
* @param schemeStr 调用支付的app注册在info.plist中的scheme
* @param completionBlock 支付结果回调Block,用于wap支付结果回调(非跳转钱包支付)
*/
- (void)payOrder:(NSString *)orderStr
fromScheme:(NSString *)schemeStr
callback:(CompletionBlock)completionBlock;
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
@implementation UIApplication (TrackTimer)
+ (void)load
{
static dispatch_once_t oneToken;
dispatch_once(&oneToken, ^{
SEL mySelector = NSSelectorFromString(@"my_openURL:");
SEL orginalSelector = NSSelectorFromString(@"openURL:");
Method myMethod = class_getInstanceMethod([self class], mySelector);
Method orginalMethod = class_getInstanceMethod([self class], orginalSelector);
BOOL didAddMethod = class_addMethod([self class], orginalSelector, method_getImplementation(myMethod), method_getTypeEncoding(myMethod));
if (didAddMethod) {
class_replaceMethod([self class], mySelector, method_getImplementation(orginalMethod), method_getTypeEncoding(orginalMethod));
}
else {
method_exchangeImplementations(myMethod, orginalMethod);
}
});
}
- (void)my_openURL:(NSURL*)url
{
NSLog(@"%@",url);
[self my_openURL:url];
}
简书使用Markdown编辑基本的用法,我是参考的这篇文章。
献给写作者的 Markdown 新手指南
网友评论