CNBBASMJumpService.m 2.42 KB
//
//  CNBBASMJumpService.m
//  AFNetworking
//
//  Created by CNLive on 2021/11/2.
//

#import "CNBBASMJumpService.h"
#import <CNLiveEnvironment/CNLiveEnvironment.h>
#import <BBAMNP/BBASMManager.h>
#import <BBAMNP/BBAMNP.h>
#import <BainuoCashierSDK/BDNCashierSDK.h>
#import <CNLiveBeeHive/BHRouter.h>

@interface CNBBASMJumpService()<BHModuleProtocol>

@end
//主要的跳转类型
static NSString *const CNLiveBBASMRouterWithMainkey = @"com.cnlive.CNLiveNetAdd://call.service.beehive/CNLiveBBASMModuleService.CNliveBBASMModuleProtocol.";
//分享
static NSString *const CNLiveBBASMShareMethod = @"shareBBASMWithParams:";
//获取zip
static NSString *const CNLiveBBASMGetPluginDesC = @"getPluginDescriptionPath";

//注册协议
@BeeHiveService(CNBBASMJumpProtocol, CNBBASMJumpService)
@implementation CNBBASMJumpService

-(void)modSetUp:(BHContext *)context
{
    //增加主工程交互类
    [[BHRouter globalRouter] addPathComponent:@"CNLiveBBASMModuleService" forClass:NSClassFromString(@"CNLiveBBASMModuleService")];
    //增加组件内交互类
    [[BHRouter globalRouter] addPathComponent:@"CNBBASMJumpService" forClass:NSClassFromString(@"CNBBASMJumpService")];
}
- (void)registerBBASMManager:(NSDictionary *)launchOptions
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [BBASMManager registerAppLaunchOptions:launchOptions];
    });
}
- (void)openBBASMModule:(NSString *)urlStr
{
    if ([urlStr containsString:@"://swan/"] ||
           [urlStr containsString:@"://swangame/"]) {
           [Pyramid.bba_smManager openAppUrl:urlStr];
       }
}
- (BOOL)cashierHandleOpenUrl:(NSURL *)url
{
    BOOL result = [BDNCashierSDK handleOpenURL:url];
    return result;
}

- (void)accountLogout
{
    [Pyramid.bba_MNP removeAllLocalServicesInHistory];
    [Pyramid.bba_MNP unionAccountLogOut];
}
+ (void)shareBBASMWithParams:(NSDictionary *)params
{
    NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",CNLiveBBASMRouterWithMainkey,CNLiveBBASMShareMethod]];
    [BHRouter openURL:url withParams:@{@"CNLiveBBASMModuleService":@{@"params":params}}];
}
+ (NSString *)getPluginDescriptionPath{
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",CNLiveBBASMRouterWithMainkey,CNLiveBBASMGetPluginDesC]];
   __block NSString *pluginDes = nil;
    [BHRouter openURL:url withParams:nil andThen:^(NSString *pathComponentKey, id obj, id returnValue) {
        pluginDes = returnValue;
    }];
    return pluginDes;
}
@end