InstagramPlugin
InstagramPlugin copied to clipboard
Share Video feature
Is there any chance at sharing videos to instagram.
Only on Android at this time.
ios implementation https://github.com/vstirbu/InstagramPlugin/pull/60
Hoping to implement this as soon as it is merged!
As you can see this feature require additional testing and maybe some changes, could you please do it if you can
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.
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.
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?
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.
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?
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.
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?
Hi, any updates on this one?
Also, how did you guys get the local identifier string from the File ?