iOS经验总结

iOS 分享照片和视频到抖音

2020-04-10  本文已影响0人  New_卡迪熊

前期准备

分享网络地址图片

// 通用参数设置----图片分享可以使用相册地址、沙盒路径、网络图片地址
NSString *imageURL = @"http://img.hb.aicdn.com/28a4962c297205e0868cdb45bb527e2bc5319f08f019-l7N1A3_fw658";
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters SSDKSetupShareParamsByText:nil
images:@[imageURL]
url:nil
title:nil
type:SSDKContentTypeImage];

[ShareSDK share:SSDKPlatformTypeDouyin parameters:shareParams onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
if (state == SSDKResponseStateSuccess) {
NSLog(@"成功!");
}else{
NSLog(@"%@",error);
}
}];

分享APP本地图片

、、、
[parameters SSDKSetupDouyinParamesByAssetLocalIds:@[self.model.asset.localIdentifier] //设备唯一标识符
hashtag:nil
extraInfo:nil
type:SSDKContentTypeImage];

    [ShareSDK share:SSDKPlatformTypeDouyin parameters:shareParams onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
if (state == SSDKResponseStateSuccess) {
    NSLog(@"成功!");
}else{
    NSLog(@"%@",error);
}

}];
、、、

分享视频
、、、
// 通用参数设置----视频分享可以使用相册地址、沙盒路径,不支持网络视频,如果使用网络视频请先下载放到沙盒目录下或相册里
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"cat" ofType:@"mp4"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters SSDKSetupShareParamsByText:nil
images:nil
url:[NSURL URLWithString:videoPath]
title:nil
type:SSDKContentTypeVideo];

[ShareSDK share:SSDKPlatformTypeDouyin parameters:parameters onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
    if (state == SSDKResponseStateSuccess) {
        NSLog(@"成功!");
    }else{
        NSLog(@"%@",error);
    }
}];

、、、

分享APP本地视频
、、、
AVURLAsset *urlAsset = (AVURLAsset *)asset;
NSURL *url = urlAsset.URL; //视频路径
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters SSDKSetupShareParamsByText:nil
images:nil
url:url
title:nil
type:SSDKContentTypeVideo];
[ShareSDK share:SSDKPlatformTypeDouyin parameters:parameters onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
if (state == SSDKResponseStateSuccess) {
NSLog(@"成功!");
}else{
NSLog(@"%@",error);
}
}];
、、、

目前我之做了分享单张照片和单个视频的功能 ,多张图 和多个视频 因为项目不需要 暂时没有去研究。大家有兴趣可以去研究研究。

上一篇下一篇

猜你喜欢

热点阅读