SharingBinding.shareItems method. This lets you share text, screenshots and links using the iOS native accounts setup in the Settings.app. If you want a bit more control using the iOS native accounts you can utilize the other SharingBeinding methods described below. They let you access Facebook, Twitter, SinaWeibo, TencentWeibo and LinkedIn all with the same API.
FacebookBinding and TwitterBinding classes. Going this route gains you access to the Facebook SDK directly so you can use their different dialogs if desired. See the Facebook and Twitter sections below for more details.
TwitterBinding.init method with your Twitter app details is required for Twitter usage for example. To register an app with Twitter, visit dev.twitter.com and click the "Register an app" link. For Facebook, you will need to setup your app at developers.facebook.com.
FacebookBinding.init before any other methods. The latest version of the Facebook SDK uses their single sign-on system. This requires you to setup a URL scheme in your Info.plist file. We provided a way to make this much more painless for everyone. If you want more information on the single sign on system and what manual setup requires check out the Authentication and Authorization section on the Facebook SDK page.
exactly as it appears in the Facebook developer portal in the FacebookDisplayName fieldshowFacebookComposer and showFacebookShareDialog. For any more advanced Facebook integrations you will want to log the user in so that you can access the Graph API. You do that by calling loginWithReadPermissions or loginWithPublishPermissions.
Facebook.instance.postMessage or Facebook.instance.postMessageWithLink. You can also post images to the user's wall using Facebook.instance.postImage. Note: Facebook messages are limited to 420 characters and posting does require the publish_actions permission.
Facebook.instance.graphRequest method to access almost anything available. The HTTPVerb parameter should be either GET or POST depending on the Graph API method you are calling. All requests accept as a parameter the completion handler which returns two objects: a string (error) and an object. The string will be an error message if an error occurred or null if no error occurred. The object will be either a Dictionary<string,object> or a List<object>. Please refer the Facebook Graph API documentation for more information on the available methods and what they return.
FacebookBinding.cs methods:
void init()
Initializes the Facebook plugin for your application
string getAppLaunchUrl()
Gets the url used to launch the application. If no url was used returns string.Empty
void setSessionLoginBehavior( FacebookSessionLoginBehavior loginBehavior )
Sets the login behavior. Must be called before any login calls! Understand what the login behaviors are and how they work before using this!
void renewCredentialsForAllFacebookAccounts()
iOS 6+ only. Renews the credentials that iOS stores for any native Facebook accounts. You can safely call this at app launch or when logging a user out.
bool isSessionValid()
Checks to see if the current session is valid
string getAccessToken()
Gets the current access token
List<object> getSessionPermissions()
Gets the permissions granted to the current access token
void login()
Opens the Facebook single sign on login in Safari, the official Facebook app or uses iOS 6 Accounts if available
void loginWithReadPermissions( string[] permissions )
Shows the native authorization dialog, opens the Facebook single sign on login in Safari or the official Facebook app with the requested read (not publish!) permissions. Results in the sessionOpenedEvent or loginFailedEvent firing.
void loginWithPublishPermissions( string[] permissions )
Authenticates/reauthorizes with the requested publish permissions. Results in the sessionOpenedEvent or loginFailedEvent firing.
void logout()
Logs the user out and invalidates the token
void graphRequest( string graphPath, string httpMethod, Dictionary<string,object> keyValueHash )
Allows you to use any available Facebook Graph API method
void showFacebookShareDialog( FacebookShareContent parameters )
Shows the Facebook share dialog. Results in the shareDialogSucceeded/FailedEvent firing.
void showFacebookShareDialogWithImage( string imagePath, string caption = "" )
Shows the Facebook share dialog. Results in the shareDialogSucceeded/FailedEvent firing.
void showGameRequestDialog( FacebookGameRequestContent content )
void showAppInviteDialog( string appLinkUrl, string previewImageUrl = null )
Shows the Facebook game request dialog. Note that Facebook has lots of rules about the combination of data sent so be sure to read up on it: https://developers.facebook.com/docs/reference/ios/current/class/FBSDKGameRequestDialog/ Results in the gameDialogSucceeded/FailedEvent firing.
void logEvent( string eventName, Dictionary<string,object> parameters = null )
Logs an event with optional parameters
void logPurchaseEvent( double amount, string currency )
logs a purchase event
void logEvent( string eventName, double valueToSum, Dictionary<string,object> parameters = null )
Logs an event, valueToSum and optional parameters
TwitterBinding.init method before you can do anything else with Twitter. To login a user, call TwitterBinding.showLoginDialog. The loginSucceededEvent event on the TwitterManager class will get fired once a user is successfully logged in. The plugin will handle keeping the users access token for future posts until the TwitterBinding.logout method is called.
showLoginDialog method will end up showing the Twitter web page in an in app browser or Twitter.app. Make sure you set it up on the Twitter website as a browser app! You do this by entering a callback url when registering. It will not be used but it still needs to be there for authentication to work. The redirect url you put in does not matter as it will not get used. Using whatever you set as your callback url is perfectly fine.
TwitterBinding.cs methods:
void init( string consumerKey, string consumerSecret )
Initializes the Twitter plugin and sets up the required oAuth information. You must call this before any other methods are used!
bool isLoggedIn()
Checks to see if there is a currently logged in user
string loggedInUsername()
Retuns the currently logged in user's username
void showLoginDialog()
Shows the login dialog via the Twitter app or in-app browser
void logout()
Logs out the current user
void postStatusUpdate( string status )
Posts the status text. Be sure status text is less than 140 characters!
void postStatusUpdateWithVideoOrGif( string status, string videoPath )
Posts the status text and a video or gif file. Note that this method requires that a native iOS twitter account is being used.
void postStatusUpdate( string status, string pathToImage )
Posts the status text and an image. Note that the url will be appended onto the tweet so you don't have the full 140 characters
void postStatusUpdate( string status, byte[] imageData )
Posts the status text and an image. Note that the url will be appended onto the tweet so you don't have the full 140 characters
void getHomeTimeline()
Receives tweets from the users home timeline
void performRequest( string methodType, string path, Dictionary<string, string> parameters )
Performs a request for any available Twitter API methods. methodType must be either "get" or "post". path is the url fragment from the API docs (excluding https:///api.twitter.com) and parameters is a dictionary of key/value pairs for the given method. Path must request .json! See Twitter's API docs for all available methods.
void sendDirectMessage( string to, string message )
sends a direct message
void showTweetComposer( string status, string pathToImage = null, string link = null )
Shows the tweet composer with the status message and optional image and link
void showTweetComposerViewController( string status, string imagePath = null, string videoPath = null )
Shows the tweet composer view controller. Note that only an image OR a video can be included, not both.