Tap into the new iOS6 Social.framework
[http://wiki.appcelerator.org/display/tis/Using+Titanium+Modules]()
To use this module since version 1.0 you must be using at least Xcode 4.5 with iOS SDK 6.0 or later.
See here
To access this module from JavaScript, you would do the following:
var Social = require("com.0x82.social");
The Social variable is a reference to the Module object.
This is an iOS6 module only! If you try to require it on an iOS < = 5 device, it will throw an exception. So you should include some sort of code on your application to check in which version of iOS are you running, and then decide to use or not use this module
function isiOS6Plus()
{
// add iphone specific tests
if (Titanium.Platform.name == 'iPhone OS')
{
var version = Titanium.Platform.version.split(".");
var major = parseInt(version[0],10);
if (major >= 6)
{
return true;
}
}
return false;
}
Please visit the following links to see the different classes of the application:
This method allows you to access the iOS6+ UIActivityViewController
. The
UIActivityViewController
class is a standard view controller that you can use
to offer various services from your application. 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.
On the iPad you can optionaly show the controller in a popover. Otherwise, it is presented modally.
The method takes the following arguments:
String
or TiBlob
objectsThe following options are only valid on the iPad:
{x:0, y:0, width:0, height:0}
Example:
Social.showActivityItems({
activityItems: ["This is a text to share"],
excludedActivityTypes: [Social.UIActivityTypePostToWeibo]
});
This method fires the following two events:
Example:
Social.addEventListener('activityWindowClosed', function(e) {
alert("activity was completed? " + e.completed);
});
The 'update' event is fired on the Social module eveytime something changes about a social network authentication. The event is sent with the following param:
availability: an object with the following key / values. Each value is a boolean value true
or false
indicating if you are able to send messages to the specified social network.
Example usage:
Social.addEventListener('update', function(e) {
if(e.twitter) { Ti.API.warn("Can post to Twitter"); }
if(e.facebook) { Ti.API.warn("Can post to Facebook"); }
if(e.sinaweibo) { Ti.API.warn("Can post to Sinaweibo"); }
});
Used when the ComposerView finished sending a tweet.
Used on Request to specify the type of request to be made to the social network
Used everytime we need to specify which social networking we are working, except when we dealing with account objects (account store, account credentials, account). For that, use the constants bellow.
Used everytime we need to speicify which social networking we are working when dealing with account objects (account store, account credentials, account).
Used to specify Facebook options when creating or accessing the Facebook account store. The last
key FACEBOOK_AUDIENCE
accepts one of the following:
Used when renewing account credentials on the AccountStore
Please see the example directory, since it contains several examples of all the API.
Rúben Fonseca, (C) 2012