Instagram

The code  snippet below demonstrates Instagram posting example:

SPInstagram.instance.Share(imageForPosting);

//Or with text
SPInstagram.instance.Share(imageForPosting, "I am posting from my app");

We can also find out posting result by subscribing to the OnPostingCompleteAction action. 

SPInstagram.instance.OnPostingCompleteAction += OnPostingCompleteAction;

void OnPostingCompleteAction (InstagramPostResult result) {
	if(result == InstagramPostResult.RESULT_OK) {
		Debug.Log("Posting Successful");
	} else {
		Debug.Log("Posting failed with error code " + result.ToString());
	}
}

Available result codes:

public enum InstagramPostResult  {

	RESULT_OK,	
	NO_APPLICATION_INSTALLED,
	USER_CANCELLED,
	SYSTEM_VERSION_ERROR,
	INTERNAL_EXCEPTION
}

Note: Since we do not use OAuth authorisation for this feature, it means that we cannot retrieve the user's action inside the Instagram app. We are not able to  get his id, or find out if he has done post after switching to the Instagram app or not. That's why we will get action result almost immediately, And  RESULT_OK means that we transferred image and message to Instagram app successfully.

IOS limitations

Note: The Instagram posting is using URL Scheme API. That's why it hit some limitation from IOS9 release. iOS 9 has made a small change to the handling of URL scheme. You must give whitelist to the URL's that your app will call out to using the LSApplicationQueriesSchemes key in your Info.plist. Long story short, if you want to use Instagram with IOS 9 Open Info.plist  in the Xcode project and add instagram to the LSApplicationQueriesSchemes​ array, as showed on the picture below.

In the future version we will try to make this process automatic, but so far, you need to do this manually.

If you want to learn more about the new Apple limitation, please, see the post here.

Note: With the latest Instagram app the image caption will be ignored. Instagram provides documentation on iOS hooks. That documentation does not make any mention of a caption parameter. It means that this doesn't seem to be an officially-supported use case. But caption parameter was working correctly with the previous Instagram app version. Now probably they are sticking with the same policy as Facebook. "Users should share only own thoughts"  and any text provided by a developer will be ignored. However we can always put some text on the image we are sharing :) This behavior may change in future, so keep your sharing text.