Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{com.facebook.sdk:FBSDKErrorArgumentNameKey=videoURL, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Must refer to an asset file., com.facebook.sdk:FBSDKErrorArgumentValueKey=/var/mobile/Media/DCIM/100APPLE/IMG_0201.MOV} #2466

Open
5 tasks done
fengpuchao opened this issue Aug 14, 2024 · 1 comment

Comments

@fengpuchao
Copy link

Checklist before submitting a bug report

Xcode version

15.3

Facebook iOS SDK version

v17.0.3

Dependency Manager

Prebuilt Binaries

SDK Framework

Share

Goals

我想通过这三个任意的属性将视频分享到Facebook里面
/// The raw video data.
@Property (nonatomic, copy) NSData * _Nullable data;
/// The representation of the video in the Photos library.
@Property (nonatomic, strong) PHAsset * _Nullable videoAsset;
/// The file URL to the video.
@Property (nonatomic, copy) NSURL * _Nullable videoURL;

Expected results

将选中的视频分享到Facebook

Actual results

Error Domain=com.facebook.sdk.share Code=2 "(null)" UserInfo={com.facebook.sdk:FBSDKErrorArgumentNameKey=videoURL, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Must refer to an asset file., com.facebook.sdk:FBSDKErrorArgumentValueKey=/var/mobile/Media/DCIM/100APPLE/IMG_0201.MOV}

Steps to reproduce

用这三方都无法实现视频的分享
/// The raw video data.
@Property (nonatomic, copy) NSData * _Nullable data;
/// The representation of the video in the Photos library.
@Property (nonatomic, strong) PHAsset * _Nullable videoAsset;
/// The file URL to the video.
@Property (nonatomic, copy) NSURL * _Nullable videoURL;

Code samples & details

我是这样实现的   
 PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
    fetchOptions.predicate = [NSPredicate predicateWithFormat:@"mediaType == %d", PHAssetMediaTypeVideo];
    fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
    PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithOptions:fetchOptions];
    PHAsset *asset = [assets firstObject];
    if (asset) {
        PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
        options.networkAccessAllowed = false;
        [[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset * _Nullable avAsset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
            if ([avAsset isKindOfClass:[AVURLAsset class]]) {
                AVURLAsset *urlAsset = (AVURLAsset *)avAsset;
                NSURL *videoURL = urlAsset.URL;
                id<FBSDKSharingContent> shareContent;
                FBSDKShareVideo *video = [FBSDKShareVideo alloc];
                video.videoURL = videoURL;
                FBSDKShareVideoContent *videoContent = [[FBSDKShareVideoContent alloc] init];
                videoContent.video = video;
                shareContent = videoContent;
                dispatch_async(dispatch_get_main_queue(), ^{
                    [FBSDKShareDialog showFromViewController:[UIApplication sharedApplication].delegate.window.rootViewController withContent:shareContent delegate:self];
                });
            }
        }];
    }
@kross51
Copy link

kross51 commented Nov 4, 2024

I'm having the exact same issue (Must refer to an asset file.). All was previously working with ALAsset then stopped working (I'm not sure when). Running on latest 17.4.0 framework. Tried to change over to PHAsset and same issue. Then tried passing local file and same issue. Passing NSData has never worked. I am really surprised more people aren't elevating this. Please expedite fixing!!! Thank you :)

Maybe part of the issue is in the following not accounting for newer ph:// schema: https://raw.githubusercontent.com/facebook/facebook-ios-sdk/refs/heads/main/FBSDKShareKit/FBSDKShareKit/Content/ShareVideo.swift

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@fengpuchao @kross51 and others