Default Sharing Dialog
- Make sure That Social API is enabled under the plugin editor settings.
- Make sure, that Texture2D you trying to share is Readable.
The ISN_UIActivityViewController is a view controller that you use to offer standard services from your app.
The system provides several standard services, such as copying items to the pasteboard, posting content to social media sites, sending items via email or SMS, and more. Apps can also define custom services.
Your app is responsible for configuring, presenting, and dismissing this view controller. Configuration for the view controller involves specifying the data objects on which the view controller should act.
The code snippet below will demonstrate how you configure and present the view controller. Few notes about the example below:
- Image to share that I will use in this example was retrieved via our custom screenshot tool the SA_ScreenUtil. But you may use any approach to get the Readable Texture2D object you want to share.
- You may also add multiple images if you wish.
- Option to print an image or assign to contacts will be excluded. This is not a requirement, you may exclude any option you want, or not exclude any options at all. The system available options are listed with ISN_UIActivityType class.
using SA.iOS.Social;
...
SA_ScreenUtil.TakeScreenshot((screenshot) => {
ISN_UIActivityViewController controller = new ISN_UIActivityViewController();
controller.SetText("share text");
controller.AddImage(screenshot);
controller.ExcludedActivityTypes.Add(ISN_UIActivityType.Print);
controller.ExcludedActivityTypes.Add(ISN_UIActivityType.AssignToContact);
controller.Present((result) => {
if(result.IsSucceeded) {
Debug.Log("Completed: " + result.Completed);
Debug.Log("ActivityType: " + result.ActivityType);
} else {
Debug.Log("ISN_UIActivityViewController error: " + result.Error.FullMessage);
}
SetAPIResult(result);
});
});
Also, the most simple and most commonly used way of sharing and image will only take 3 lines of code:
using SA.iOS.Social;
...
ISN_UIActivityViewController controller = new ISN_UIActivityViewController();
controller.AddImage((Texture2D)m_currentTexture.texture);
controller.Present((result) => { });
The operation result will be similar to the picture below:
For the non-image sharing (video, pdf, files), you can save the file on the disc and then assign file URL using the AddUrl method of the ISN_UIActivityViewController
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