- This module brings Social Share functionaliy into the mobile apps for titanium app developers.
- Set the
<module>
element in tiapp.xml, such as this:
<modules>
<module platform="ios">appcelerator.socialshare</module>
</modules>
- To access this module from JavaScript, you would do the following:
var socialshare = require("appcelerator.socialshare");
The socialshare
variable is a reference to the Module object.
- Use
createActivityItemProvider
to create item provider
const itemProvider = socialshare.createActivityItemProvider({
contentType: socialshare.Content_Type_String,
placeHolder: 'placeholder'
});
- Set
fetchItem
foritemProvider
status
itemProvider.fetchItem = function () {
return 'This is Text To Share';
};
- Set
activityType
foritemProvider
status
itemProvider.activityType = socialshare.Activity_Type_Message;
- Set
activityType
foritemProvider
status
itemProvider.activityType = socialshare.Activity_Type_Message;
- create
customActivity
usingcreateCustomActivity
if custom activity is required
const customActivity = socialshare.createCustomActivity({
category: socialshare.Activity_Category_Share,
title: 'url share',
});
- call
shareWithItems
for share the content status
socialshare.shareWithItems({
activityItems: [ itemProvider ],
activities: [ customActivity ],
completionWithItemsHandler: function (e) {
if (e.errorCode !== null || e.errorDomain !== null || e.errorDescription !== null) {
alert('Error Occured: ' + e.errorDescription);
return;
}
}
});
- Use
createActivityItemSource
to create item source
const itemSource = socialshare.createActivityItemSource({
contentType: socialshare.Content_Type_String
});
- Set
fetchItem
foritemSource
status
itemSource.fetchItem = function () {
return 'This is Text To Share';
};
- Set
fetchPlaceholderItem
foritemSource
status
itemSource.fetchPlaceholderItem = function () {
return 'This is Text To Share';
};
- create
customActivity
usingcreateCustomActivity
if custom activity is required
const customActivity = socialshare.createCustomActivity({
category: socialshare.Activity_Category_Share,
title: 'url share',
});
- call
shareWithItems
for share the content status
socialshare.shareWithItems({
activityItems: [ itemSource ],
activities: [ customActivity ],
completionWithItemsHandler: function (e) {
if (e.errorCode !== null || e.errorDomain !== null || e.errorDescription !== null) {
alert('Error Occured: ' + e.errorDescription);
return;
}
}
});
- Please see the
example/
folder.
Simply run appc run -p ios --build-only
which will compile and package your module.
Copy the module zip file into the root folder of your Titanium application or in the Titanium system folder (e.g. /Library/Application Support/Titanium).
Axway
Copyright (c) 2020 by Axway, Inc. Please see the LICENSE file for further details.