1、導(dǎo)入頭文件
#import <JavaScriptCore/JavaScriptCore.h>
2帚豪、獲取本地bundle js 文件
NSString *scriptPath = [[NSBundle mainBundle] pathForResource:@"common" ofType:@"js"];
NSString *scriptString = [NSString stringWithContentsOfFile:scriptPath encoding:NSUTF8StringEncoding error:nil];
JSContext *context = [[JSContext alloc] init];
[context evaluateScript:scriptString];
//調(diào)用js 方法
JSValue *function = context[@"uc_authcode"];
//傳參->返回token
JSValue *token = [function callWithArguments:@[@"ayqCtCTXtacYzpiu",@"ENCODE",@"cQnGW9Qmhqq5Qhq9"]];
LOG(@"token = %@",token);
來(lái)者即是緣份,請(qǐng)幫忙點(diǎn)個(gè)贊吧~