






target 'XXX' dopod 'MpAccSDK', :podspec => 'https://mpspeedr-online-1258344699.cos.ap-guangzhou.myqcloud.com/go/ios/2.9.8.0/MpAccSDK.podspec'end



target 'XXX' dopod 'MpAccSDK', :podspec => 'https://mpspeedr-online-1258344699.cos.ap-guangzhou.myqcloud.com/go/ios/2.9.8.0/MpAccSDK.podspec'end


class VPNViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad()// If the SDK is in single vpn mode, you do not need to configure this parameter.MpAccClient.shared.accType = .vpn// You only need to configure either device-based integration or application-based integration.// Device-based integrationMpAccClient.shared.setupDatakey(datakey: "xxxxx",deviceId: "xxxxx")// Application-based integration// MpAccClient.shared.setSign(appId:"xxx", sign:"xxx")// Register callbackMpAccClient.shared.registerAccCallback(self)// Attempt to restore VPNMpAccClient.shared.resumeVpn()}//Start accelerationfunc startAcc() {let config = AccConfig()config.accMode = .Redundant // Acceleration mode 1: Aggregation 2: Dual-send 3: rtcconfig.pingInterval = 2config.groupId = "com.xxxx" // AppGroupconfig.vpnName = "XXXXXX" // VPN name// Start VPNMpAccClient.shared.start(config: config)}//Stop accelerationfunc stopAcc() {MpAccClient.shared.stop()}}extension VPNViewController: AccCallback {func onAccSuccess(ip: String, port: Int) -> Void { }func onAccFail(_ error: NSError?) -> Void { }func onAccDataUpdate(tRx: Int64, tTx: Int64, pathDetails: [MpPathDetail]) -> Void { }func onSummaryInfoUpdate(_ summaryInfo: String) -> Void { }func onNetworkStateChanged(_ type: MpInterfaceType, available: Bool, ip: String) -> Void { }}
@interface ViewController () <AccCallback>@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];// If it is a single vpn mode SDK, this parameter does not need to be configuredMpAccClient.shared.accType = AccTypeVpn;// Do any additional setup after loading the view.[MpAccClient.shared registerAccCallback:self];// You only need to configure either device-based integration or application-based integration.// Device-based integration[MpAccClient.shared setupDatakey:@"xxxxxxx"deviceId:@"xxxxxxx"];// Application-based integration// MpAccClient.shared.setSign(appId:"xxx", sign:"xxx")[MpAccClient.shared resumeVpn];}- (void)startVpn {AccConfig *config = [AccConfig new];/// Acceleration mode 1: Aggregation 2: Dual-send 3: rtcconfig.accMode = AccModeRedundant;config.pingInterval = 2;config.congrestionMode = MpCongrestionModeBBR;config.groupId = @"group.xxxxxxxx";config.vpnName = @"Test_name3";config.whiteList = @[];config.blackList = @[];[MpAccClient.shared startWithConfig:config];}- (void)stopAcc {[MpAccClient.shared stop];}// AccCallback- (void)onAccSuccessWithIp:(NSString *)ip port:(NSInteger)port {}- (void)onAccFail:(NSError *)error {}- (void)onAccDataUpdateWithTRx:(int64_t)tRx tTx:(int64_t)tTx pathDetails:(NSArray<MpPathDetail *> *)pathDetails {}- (void)onSummaryInfoUpdate:(NSString *)summaryInfo {}- (void)onNetworkStateChanged:(enum MpInterfaceType)type available:(BOOL)available ip:(NSString *)ip {}@end
class PacketTunnelProvider: NEPacketTunnelProvider {var tunnelManager: MpPacketTunnelManager = MpPacketTunnelManager()override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {//Call the startTunnel method of the SDKtunnelManager.startTunnel(packetTunnel: self, options: options, completionHandler: completionHandler);}override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {//Call the stopTunnel method of the SDKtunnelManager.stopTunnel()completionHandler()}override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)?) {//Call the handleAppMessage method of the SDKtunnelManager.handleAppMessage(messageData, completionHandler: completionHandler);}}
@interface PacketTunnelProvider() {MpPacketTunnelManager *tunnelManager;}@end@implementation PacketTunnelProvider- (id)init {self = [super init];if (self != NULL) {tunnelManager = [[MpPacketTunnelManager alloc] init];}return self;}- (void)startTunnelWithOptions:(NSDictionary *)options completionHandler:(void (^)(NSError *))completionHandler {//Call the startTunnel method of the SDK[tunnelManager startTunnelWithPacketTunnel:self options:options completionHandler:completionHandler];}- (void)stopTunnelWithReason:(NEProviderStopReason)reason completionHandler:(void (^)(void))completionHandler {//Call the stopTunnel method of the SDK[tunnelManager stopTunnel];completionHandler();}- (void)handleAppMessage:(NSData *)messageData completionHandler:(void (^)(NSData *))completionHandler {//Call the handleAppMessage method of the SDK[tunnelManager handleAppMessage:messageData completionHandler:completionHandler];}@end
import Alamofireclass Socks5ViewController: UIViewController {private var afs: Session = AF//Start accelerationfunc startAcc() {//Acceleration method. If it's a single SOCKS5_SDK, ignore it.MpAccClient.shared.accType = .socks5;let config = AccConfig()config.socksProxyPort = xxx// Start socks5MpAccClient.shared.start(config: config)}}extension Socks5ViewController: AccCallback {func onAccSuccess(ip: String, port: Int) -> Void {// Traffic switchover requiredlet sessionConfig = URLSessionConfiguration.defaultsessionConfig.connectionProxyDictionary = [kCFStreamPropertySOCKSProxyHost : "127.0.0.1",// config.socksProxyPortkCFStreamPropertySOCKSProxyPort : "xxxxxx",]afs = Session(configuration: sessionConfig)}}
@interface ViewController () <AccCallback>@end@implementation ViewController- (void)startVpn {// If it's a single SOCKS5_SDK, skip this fieldMpAccClient.shared.accType = AccTypeSocks5;AccConfig *config = [AccConfig new];// Set parameters[MpAccClient.shared startWithConfig:config];}// AccCallback- (void)onAccSuccessWithIp:(NSString *)ip port:(NSInteger)port {// Traffic switchover required// AFNetworking settings are similar to Alamofire}@end
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback