InstagramPlugin icon indicating copy to clipboard operation
InstagramPlugin copied to clipboard

Share Video feature

Open westonganger opened this issue 10 years ago • 12 comments
trafficstars

Is there any chance at sharing videos to instagram.

westonganger avatar Sep 22 '15 19:09 westonganger

Only on Android at this time.

vstirbu avatar Sep 28 '15 21:09 vstirbu

ios implementation https://github.com/vstirbu/InstagramPlugin/pull/60

sky-code avatar Feb 27 '16 22:02 sky-code

Hoping to implement this as soon as it is merged!

MT-- avatar Mar 04 '16 17:03 MT--

As you can see this feature require additional testing and maybe some changes, could you please do it if you can

sky-code avatar Mar 05 '16 00:03 sky-code

I can do some testing when I am ready to test my new project on iOS. I am currently just developing on Android, but I will be sure to work this out when I get to that point.

MT-- avatar Mar 05 '16 19:03 MT--

when #60 will be merged, sharing video will be posible on ios 8+ based on Photos Framework and PHAsset. I use this feature on my project, as example:

    func saveVideoToPhotoLibrary(command: CDVInvokedUrlCommand) {
        NSLog("CDVMediaKit#saveVideoToPhotoLibrary()")
        let filePath = String(command.argumentAtIndex(0) as! NSString)
        NSLog(filePath)

        if filePath.isEmpty{
            NSLog("error filePath is empty")
        }

        var fileURL = NSURL(string: filePath)!

        if !fileURL.fileURL {
            fileURL = NSURL(fileURLWithPath: filePath)
        }

        var localIdentifier:String? = nil
        PHPhotoLibrary.sharedPhotoLibrary().performChanges({ () -> Void in

            let createAssetRequest: PHAssetChangeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(fileURL)!
            let placeholder = createAssetRequest.placeholderForCreatedAsset
            localIdentifier = placeholder?.localIdentifier
        }, completionHandler: { (success, error) -> Void in
            if success {
                let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsString: localIdentifier);
                self.commandDelegate!.sendPluginResult(pluginResult, callbackId: command.callbackId);
            }
            else {
                let pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAsString: error?.localizedDescription);
                self.commandDelegate!.sendPluginResult(pluginResult, callbackId: command.callbackId);
            }
        })

    }

This func take a path to video in my application tmp folder, save it to sharedPhotoLibrary and return local identifier string, which is similar to "24320B60-1F52-46AC-BE4C-1202F02B9D00/L0/001", when you have local identifier pass it to Instagram.shareAsset and you will see Instagram app with pre selected video. If you pass empty string or invalid local identifier Instagram will be opened without any errors but nothing will be selected.

sky-code avatar Jun 08 '16 19:06 sky-code

I see that iOS now has the method shareAsset which enables video upload. We should get this implemented in Android too. We have the documentation for the intent, would that be similar to what iOS does?

westonganger avatar May 15 '17 23:05 westonganger

We could add a shareVideo method for sharing the video which accepts an url to the video file. Instagram app for Android supports that feature.

vstirbu avatar May 16 '17 08:05 vstirbu

Would love this. You are suggesting seperate methods for iOS and Android. Would it not be better to unify the JS API across both platforms with one method name or are they going to behave very differently?

westonganger avatar May 16 '17 15:05 westonganger

It might work with only one method.

In the long term the API needs to be reworked as so many things are not supported anymore by Instagram.

vstirbu avatar May 16 '17 16:05 vstirbu

Sorry if I missed this, but according to the documentation video sharing is only available via iOS via the shareAsset method. Will this also work with Android as long as the video is local?

albertleao avatar Nov 16 '17 20:11 albertleao

Hi, any updates on this one?

Also, how did you guys get the local identifier string from the File ?

ejlocop avatar Sep 03 '18 03:09 ejlocop