Share to Instagram
Stanislav Osipov edited this page Apr 1, 2020
·
1 revision
Starting with the iOS 13 default method that was used by the majority of iOS developers is no longer working.
The new approach is to use a URL scheme to share the image. The issue is that this image has to be added to the user photo library. The code below demonstrates how you can do that with the iOS Native plugin:
using SA.iOS.Photos;
using SA.iOS.UIKit;
...
var myImageToShare = GetMyImage();
ISN_PhotoAlbum.UIImageWriteToSavedPhotosAlbum(sampleRedTexture, (result) =>
{
if (result.HasError)
{
Debug.LogError(result.Error.FullMessage);
return;
}
var fetchOptions = new ISN_PHFetchOptions();
fetchOptions.SortDescriptor = new ISN_NSSortDescriptor("creationDate", false);
fetchOptions.FetchLimit = 1;
var fetchResult = ISN_PHAsset.FetchAssetsWithOptions(fetchOptions);
var lastAsset = fetchResult.FirstObject;
var url = "instagram://library?LocalIdentifier=" + lastAsset.LocalIdentifier;
if (ISN_UIApplication.CanOpenURL(url))
ISN_UIApplication.OpenURL(url);
else
Debug.LogError("Instagram application is not installed!");
});
Reliable and high-quality Unity Development service. Let's Talk!
Website | AssetStore | LinkedIn | Youtube | Scripting Reference
- Getting Started
- Authentication
- Game Center UI
- Leaderboards
- Default Leaderboard
- Achievements
- Saving A Game
- Access Point
- iTunes Connect Setup
- StoreKit Initialization
- Purchase flow
- Receipt Validation
- Store Review Controller
- Storefront API
- Subscription Offers