CNBBASMShareImpl.m 2.45 KB
//
//  CNBBASMShareImpl.m
//  CNLiveNetAdd
//
//  Created by CNLive on 2021/10/16.
//  Copyright © 2021 cnlive. All rights reserved.
//

#import "CNBBASMShareImpl.h"
#import <CNLiveEnvironment/CNLiveEnvironment.h>
#import "CNBBASMJumpService.h"

static NSString * const CNShareVideoImplementKeyVideoPath    = @"videoPath";
static NSString * const CNShareVideoImplementFrameKeyTitle   = @"title";
static NSString * const CNShareVideoImplementFrameKeyAppId   = @"appId";
@implementation CNBBASMShareImpl
#pragma mark - Protocol Method
RegisterBBASMAdapter()

+ (void)shareContent:(NSDictionary *)content
            callback:(void (^)(NSString * _Nonnull, NSString * _Nonnull))callback {
    // 1.先获取分享的相关内容
    // 分享标题
    NSString *title = content[@"title"];
    // 分享内容
    NSString *sharecontent = content[@"content"];
    // 分享图标
    NSString *iconUrl = content[@"iconUrl"];
    // 小程序页面链接
    NSString *path = content[@"linkUrl"];
    NSDictionary *categoryInfo = content[@"categoryInfo"];
    
    path = [NSString stringWithFormat:@"%@/smartappLandingpage.html?title=%@&content=%@&imageUrl=%@&swanId=%@&type=smartapp",WjjH5_Host,title,sharecontent,iconUrl,[NSString stringWithFormat:@"%@/%@",categoryInfo[@"source2"],content[@"path"]]];

    
    NSString *mediaType = content[@"mediaType"];
    NSDictionary *params = nil;
    if (mediaType) {
        params = @{
            @"title":title,
            @"shareDesc":sharecontent,
            @"shareUrl":[path stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]],
            @"shareImage":iconUrl,
            @"shareType":mediaType,
        };
    }else{
        params = @{
            @"title":title,
            @"shareDesc":sharecontent,
            @"shareUrl":[path stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]],
            @"shareImage":iconUrl,
        };
    }
    
    [CNBBASMJumpService shareBBASMWithParams:params];
}

+ (void)shareGameVideoWithDict:(NSDictionary *)dict
                    completion:(void (^)(NSDictionary * _Nonnull, BBASMShareResult resultType))completion {
    // 处理参数
//    NSString *videoPath = [dict bba_stringValueForKey:CNShareVideoImplementKeyVideoPath];
//    NSString *title = [dict bba_stringValueForKey:CNShareVideoImplementFrameKeyTitle];
//    NSString *appId = [dict bba_stringValueForKey:CNShareVideoImplementFrameKeyAppId];

}

@end