Last active
September 14, 2018 16:36
-
-
Save ewieberappc/cd79eb35dc615dd5f118bec6d51de395 to your computer and use it in GitHub Desktop.
A basic Share Extension Test created by combining two simple test cases. Contains the ShareViewController for the extension and the index controller and view for the Titanium Project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var appGroupId = 'group.com.YourGroupId'; | |
var props = Ti.App.iOS.createUserDefaults({ | |
suiteName: appGroupId | |
}); | |
var score = props.getInt('score'); | |
if (!score) | |
score = 1; | |
props.setInt('score', score); | |
// Get the shared container path | |
var sharedPath = Ti.Filesystem.directoryForSuite(appGroupId); | |
// Copy a file from the application to the shared container | |
var appFile = Ti.Filesystem.getFile(sharedPath, 'somesharefile.txt'); | |
Ti.API.error(appFile); | |
function doClick(e) { | |
score = props.getInt('score'); | |
Ti.API.error("++++++++++ score was: "+score); | |
score += 1; | |
props.setInt('score', score); | |
Ti.API.error("++++++++++ score is: "+props.getInt('score')); | |
if (appFile.createFile()) | |
appFile.write("Hello"); | |
Ti.API.error("++++++++++ data was: "+appFile.read()); | |
appFile.write($.text.value); | |
Ti.API.error("++++++++++ data is: "+appFile.read()); | |
} | |
function getImages(e) { | |
var dir = Ti.Filesystem.getFile(sharedPath); | |
var dir_files = dir.getDirectoryListing(); | |
var views = []; | |
for (var i=0;i<dir_files.length;i++){ | |
if (dir_files[i].indexOf("image") == -1) | |
continue; | |
var view = Ti.UI.createImageView({ | |
image: Ti.Filesystem.getFile(sharedPath, dir_files[i]) | |
}); | |
views.push(view); | |
} | |
$.scroll.views = views; | |
} | |
$.index.open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Window class="container"> | |
<TextField id="text" borderColor="black" top="30%" value="This is from the app" /> | |
<Button onClick="doClick" top="40%">OK</Button> | |
<Button onClick="getImages" top="50%">Get Images</Button> | |
<ScrollableView id="scroll" showPagingControl="true" top="60%" height="40%"/> | |
</Window> | |
</Alloy> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Replace items in [] --> | |
<ios> | |
<team-id>[TEAM ID HERE]</team-id> | |
<capabilities> | |
<app-groups> | |
<group>[group.com.YourGroupId]</group> | |
</app-groups> | |
</capabilities> | |
<extensions> | |
<extension projectPath="[Path to extension's .xcodeproj]"> | |
<target name="[Target Name]"> | |
<provisioning-profiles> | |
<device>[Device-UDID]</device> | |
<dist-appstore/> | |
<dist-adhoc/> | |
</provisioning-profiles> | |
</target> | |
</extension> | |
</extensions> | |
<key>NSExtensionAttributes</key> | |
<dict> | |
<key>NSExtensionActivationRule</key> | |
<dict> | |
<key>NSExtensionActivationSupportsImageWithMaxCount</key> | |
<integer>10</integer> | |
<key>NSExtensionActivationSupportsMovieWithMaxCount</key> | |
<integer>1</integer> | |
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key> | |
<integer>1</integer> | |
</dict> | |
</dict> | |
<plist> | |
<dict> | |
<key>CFBundleURLTypes</key> | |
<array> | |
<dict> | |
<key>CFBundleTypeRole</key> | |
<string>Editor</string> | |
<key>CFBundleURLName</key> | |
<string>[com.Your.AppId]</string> | |
</dict> | |
</array> | |
</dict> | |
</plist> | |
</ios> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great. Would have been good if tiapp.xml was included too.