├── metadata.json ├── Classes ├── .gitignore ├── DkNappSocialModuleAssets.h ├── NappItemProvider.h ├── NappImageProvider.h ├── DkNappSocialModuleAssets.m ├── NappCustomActivity.h ├── NappItemProvider.m ├── DkNappSocialModule.h ├── NappImageProvider.m ├── NappCustomActivity.m └── DkNappSocialModule.m ├── documentation └── index.md ├── example ├── pin.png ├── Safari.png ├── Safari@2x.png ├── follow_on_twitter.js └── app.js ├── DkNappSocial_Prefix.pch ├── module.xcconfig ├── dist ├── dk.napp.social-iphone-1.0.zip ├── dk.napp.social-iphone-1.2.zip ├── dk.napp.social-iphone-1.3.zip ├── dk.napp.social-iphone-1.4.zip ├── dk.napp.social-iphone-1.5.1.zip ├── dk.napp.social-iphone-1.5.2.zip ├── dk.napp.social-iphone-1.5.3.zip ├── dk.napp.social-iphone-1.5.4.zip ├── dk.napp.social-iphone-1.5.5.zip ├── dk.napp.social-iphone-1.5.zip ├── dk.napp.social-iphone-1.6.0.zip ├── dk.napp.social-iphone-1.6.1.zip ├── dk.napp.social-iphone-1.6.2.zip ├── dk.napp.social-iphone-1.6.3.zip ├── dk.napp.social-iphone-1.7.0.zip ├── dk.napp.social-iphone-1.7.1.zip ├── dk.napp.social-iphone-1.7.2.zip ├── dk.napp.social-iphone-1.7.3.zip ├── dk.napp.social-iphone-1.7.4.zip ├── dk.napp.social-iphone-1.7.5.zip ├── dk.napp.social-iphone-1.7.6.zip ├── dk.napp.social-iphone-1.7.7.zip ├── dk.napp.social-iphone-1.7.8.zip ├── dk.napp.social-iphone-1.7.9.zip ├── dk.napp.social-iphone-1.8.0.zip ├── dk.napp.social-iphone-1.8.1.zip ├── dk.napp.social-iphone-1.8.2.zip ├── dk.napp.social-iphone-1.8.3.zip ├── dk.napp.social-iphone-1.8.4.zip ├── dk.napp.social-iphone-2.0.0.zip ├── dk.napp.social-iphone-2.0.1.zip ├── dk.napp.social-iphone-2.0.2.zip └── dk.napp.social-iphone-1.7.10.zip ├── .settings └── com.aptana.editor.common.prefs ├── social.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcuserdata │ │ └── madsmoller.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ ├── WorkspaceSettings.xcsettings │ │ └── social.xccheckout ├── xcuserdata │ └── madsmoller.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ ├── social.xcscheme │ │ └── Build & Test.xcscheme └── project.pbxproj ├── .gitignore ├── assets └── README ├── timodule.xml ├── manifest ├── titanium.xcconfig ├── .project ├── LICENSE ├── .clang-format └── README.md /metadata.json: -------------------------------------------------------------------------------- 1 | {"exports":[]} -------------------------------------------------------------------------------- /Classes/.gitignore: -------------------------------------------------------------------------------- 1 | DkNappSocial.h 2 | DkNappSocial.m 3 | -------------------------------------------------------------------------------- /documentation/index.md: -------------------------------------------------------------------------------- 1 | # TiSocial.Framework Module 2 | 3 | -------------------------------------------------------------------------------- /example/pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/example/pin.png -------------------------------------------------------------------------------- /example/Safari.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/example/Safari.png -------------------------------------------------------------------------------- /DkNappSocial_Prefix.pch: -------------------------------------------------------------------------------- 1 | 2 | #ifdef __OBJC__ 3 | #import 4 | #endif 5 | -------------------------------------------------------------------------------- /example/Safari@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/example/Safari@2x.png -------------------------------------------------------------------------------- /module.xcconfig: -------------------------------------------------------------------------------- 1 | 2 | 3 | OTHER_LDFLAGS=$(inherited) -weak_framework Social -weak_framework Accounts 4 | -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.0.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.2.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.3.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.4.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.5.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.5.1.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.5.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.5.2.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.5.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.5.3.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.5.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.5.4.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.5.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.5.5.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.5.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.6.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.6.0.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.6.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.6.1.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.6.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.6.2.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.6.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.6.3.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.0.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.1.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.2.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.3.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.4.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.5.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.6.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.7.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.7.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.8.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.8.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.9.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.9.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.8.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.8.0.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.8.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.8.1.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.8.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.8.2.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.8.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.8.3.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.8.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.8.4.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-2.0.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-2.0.0.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-2.0.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-2.0.1.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-2.0.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-2.0.2.zip -------------------------------------------------------------------------------- /dist/dk.napp.social-iphone-1.7.10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/dist/dk.napp.social-iphone-1.7.10.zip -------------------------------------------------------------------------------- /.settings/com.aptana.editor.common.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | selectUserAgents=com.appcelerator.titanium.mobile.module.nature\:iphone 3 | -------------------------------------------------------------------------------- /Classes/DkNappSocialModuleAssets.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a generated file. Do not edit or your changes will be lost 3 | */ 4 | 5 | @interface DkNappSocialModuleAssets : NSObject { 6 | } 7 | - (NSData *)moduleAsset; 8 | @end 9 | -------------------------------------------------------------------------------- /social.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /social.xcodeproj/project.xcworkspace/xcuserdata/madsmoller.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viezel/TiSocial.Framework/HEAD/social.xcodeproj/project.xcworkspace/xcuserdata/madsmoller.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | tmp 3 | bin 4 | build 5 | Index 6 | .apt_generated 7 | build.properties 8 | .svn 9 | .settings 10 | *.pyc 11 | *~.nib/ 12 | *.pbxuser 13 | *.perspective 14 | *.perspectivev3 15 | *.xcworkspace/ 16 | xcuserdata 17 | *.xcuserstate 18 | *.xcuserdata* 19 | -------------------------------------------------------------------------------- /Classes/NappItemProvider.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NappItemProvider : UIActivityItemProvider 4 | @property (nonatomic, strong) NSString *customText; 5 | @property (nonatomic, strong) NSString *customHtmlText; 6 | @property (nonatomic, strong) NSString *customTwitterText; 7 | @end -------------------------------------------------------------------------------- /assets/README: -------------------------------------------------------------------------------- 1 | Place your assets like PNG files in this directory and they will be packaged with your module. 2 | 3 | If you create a file named dk.napp.social.js in this directory, it will be 4 | compiled and used as your module. This allows you to run pure Javascript 5 | modules that are pre-compiled. 6 | 7 | -------------------------------------------------------------------------------- /social.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /social.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /Classes/NappImageProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // DkNappSocialImageProvider.h 3 | // social 4 | // 5 | // Created by João Paulo Pinheiro Teixeira on 25/09/14. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface NappImageProvider : UIActivityItemProvider 12 | 13 | @property (nonatomic, strong) NSString *facebookImage; 14 | @property (nonatomic, strong) NSString *twitterImage; 15 | @property (nonatomic, strong) NSString *defaultImage; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /timodule.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 6.0 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Classes/DkNappSocialModuleAssets.m: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a generated file. Do not edit or your changes will be lost 3 | */ 4 | #import "DkNappSocialModuleAssets.h" 5 | 6 | extern NSData* filterDataInRange(NSData* thedata, NSRange range); 7 | 8 | @implementation DkNappSocialModuleAssets 9 | 10 | - (NSData *)moduleAsset 11 | { 12 | 13 | 14 | return nil; 15 | } 16 | 17 | - (NSData *)resolveModuleAsset:(NSString *)path 18 | { 19 | 20 | 21 | return nil; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Classes/NappCustomActivity.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Module developed by Napp CMS 3 | * Mads Møller 4 | * 5 | * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. 6 | * and licensed under the Apache Public License (version 2) 7 | */ 8 | #import "TiModule.h" 9 | #import 10 | 11 | @interface NappCustomActivity : UIActivity 12 | 13 | - (UIViewController *)performWithActivityItems:(NSArray *)activityItems; 14 | - (id)initWithSettings:(NSDictionary *)dict; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /manifest: -------------------------------------------------------------------------------- 1 | # 2 | # this is your module manifest and used by Titanium 3 | # during compilation, packaging, distribution, etc. 4 | # 5 | version: 2.0.2 6 | apiversion: 2 7 | description: Social.Framework Module 8 | author: Mads Møller 9 | license: MIT license 10 | copyright: Copyright (c) 2004-present by Napp ApS 11 | 12 | # these should not be edited 13 | name: social 14 | moduleid: dk.napp.social 15 | guid: 8152d7fc-6edb-4c40-8d6f-bc2cef87bc1a 16 | platform: iphone 17 | minsdk: 6.3.0 18 | architectures: armv7 i386 x86_64 arm64 19 | -------------------------------------------------------------------------------- /titanium.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // CHANGE THESE VALUES TO REFLECT THE VERSION (AND LOCATION IF DIFFERENT) 4 | // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR 5 | // 6 | // 7 | TI_SDK_VERSION = 8.0.1.GA 8 | 9 | // 10 | // THESE SHOULD BE OK GENERALLY AS-IS 11 | // 12 | TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TI_SDK_VERSION) 13 | TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" 14 | TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" 15 | HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) 16 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(TITANIUM_SDK)/iphone/Frameworks" 17 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | TiSocial.Framework 4 | 5 | 6 | 7 | 8 | 9 | com.appcelerator.titanium.core.builder 10 | 11 | 12 | 13 | 14 | com.aptana.ide.core.unifiedBuilder 15 | 16 | 17 | 18 | 19 | 20 | com.appcelerator.titanium.mobile.module.nature 21 | com.aptana.projects.webnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /social.xcodeproj/xcuserdata/madsmoller.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Build & Test.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | social.xcscheme 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 24416B8111C4CA220047AFDD 21 | 22 | primary 23 | 24 | 25 | D2AAC07D0554694100DB518D 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Mads Møller 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Classes/NappItemProvider.m: -------------------------------------------------------------------------------- 1 | #import "NappItemProvider.h" 2 | 3 | @implementation NappItemProvider 4 | @synthesize customText = _customText; 5 | @synthesize customHtmlText = _customHtmlText; 6 | 7 | - (void)dealloc { 8 | [_customText release]; 9 | [_customHtmlText release]; 10 | [_customTwitterText release]; 11 | 12 | [super dealloc]; 13 | } 14 | 15 | - (id)initWithPlaceholderItem:(id)placeholderItem { 16 | return [super initWithPlaceholderItem:placeholderItem]; 17 | } 18 | 19 | - (id)item { 20 | return @""; 21 | } 22 | 23 | - (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType { 24 | if ([activityType isEqualToString:UIActivityTypeMail]) { 25 | NSString *text = [NSString stringWithFormat:@"%@%@%@", @"", _customHtmlText, @""]; 26 | NSLog(@"[INFO] Sharing the following as HTML %@", text); 27 | 28 | return text; 29 | } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) { 30 | NSString *customTwitterText = [NSString stringWithFormat:@"%@", _customTwitterText]; 31 | return customTwitterText; 32 | } else { 33 | NSString *nonhtmltext = [NSString stringWithFormat:@"%@", _customText]; 34 | return nonhtmltext; 35 | } 36 | 37 | return @""; 38 | } 39 | 40 | - (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController { 41 | return @""; 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /social.xcodeproj/project.xcworkspace/xcshareddata/social.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | AA3C83A3-0F9A-46C6-B20B-614054A3AA43 9 | IDESourceControlProjectName 10 | social 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 92A904948F96E190AC535D2917B454E3B04951D8 14 | github.com:joseandro/TiSocial.Framework.git 15 | 16 | IDESourceControlProjectPath 17 | social.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 92A904948F96E190AC535D2917B454E3B04951D8 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:joseandro/TiSocial.Framework.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 92A904948F96E190AC535D2917B454E3B04951D8 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 92A904948F96E190AC535D2917B454E3B04951D8 36 | IDESourceControlWCCName 37 | TiSocial.Framework 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Classes/DkNappSocialModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Module developed by Napp CMS 3 | * Mads Møller 4 | * 5 | * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. 6 | * and licensed under the Apache Public License (version 2) 7 | */ 8 | #import "TiModule.h" 9 | #import "TiViewController.h" 10 | #import 11 | 12 | @interface DkNappSocialModule : TiModule { 13 | ACAccountStore *accountStore; 14 | CGRect popoverRect; 15 | UIPopoverController *popoverController; 16 | UIViewController *viewController; 17 | id senderButton; 18 | } 19 | 20 | @property (nonatomic, readonly) NSString *ACTIVITY_FACEBOOK; 21 | @property (nonatomic, readonly) NSString *ACTIVITY_TWITTER; 22 | @property (nonatomic, readonly) NSString *ACTIVITY_WEIBO; 23 | @property (nonatomic, readonly) NSString *ACTIVITY_MESSAGE; 24 | @property (nonatomic, readonly) NSString *ACTIVITY_MAIL; 25 | @property (nonatomic, readonly) NSString *ACTIVITY_PRINT; 26 | @property (nonatomic, readonly) NSString *ACTIVITY_COPY; 27 | @property (nonatomic, readonly) NSString *ACTIVITY_ASSIGN_CONTACT; 28 | @property (nonatomic, readonly) NSString *ACTIVITY_SAVE_CAMERA; 29 | @property (nonatomic, readonly) NSString *ACTIVITY_READING_LIST; 30 | @property (nonatomic, readonly) NSString *ACTIVITY_FLICKR; 31 | @property (nonatomic, readonly) NSString *ACTIVITY_VIMEO; 32 | @property (nonatomic, readonly) NSString *ACTIVITY_AIRDROP; 33 | @property (nonatomic, readonly) NSString *ACTIVITY_TENCENT_WEIBO; 34 | @property (nonatomic, readonly) NSString *ACTIVITY_OPEN_IN_IBOOKS; 35 | @property (nonatomic, readonly) NSString *ACTIVITY_MARKUP_AS_PDF; 36 | @property (nonatomic, readonly) NSString *ACTIVITY_CUSTOM; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /social.xcodeproj/xcuserdata/madsmoller.xcuserdatad/xcschemes/social.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Classes/NappImageProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // DkNappSocialImageProvider.m 3 | // social 4 | // 5 | // Created by João Paulo Pinheiro Teixeira on 25/09/14. 6 | // 7 | // 8 | 9 | #import "NappImageProvider.h" 10 | 11 | @implementation NappImageProvider 12 | @synthesize facebookImage = _facebookImage; 13 | @synthesize twitterImage = _twitterImage; 14 | @synthesize defaultImage = _defaultImage; 15 | 16 | - (void)dealloc { 17 | [_facebookImage release]; 18 | [_twitterImage release]; 19 | [_defaultImage release]; 20 | 21 | [super dealloc]; 22 | } 23 | 24 | - (id)activityViewController:(UIActivityViewController *)activityViewController 25 | itemForActivityType:(NSString *)activityType { 26 | 27 | if ([activityType isEqualToString:UIActivityTypePostToFacebook]) { 28 | NSLog(@"%@", _facebookImage); 29 | return [self findImage:_facebookImage]; 30 | } 31 | if ([activityType isEqualToString:UIActivityTypePostToTwitter] && _twitterImage) { 32 | return [self findImage:_twitterImage]; 33 | } 34 | 35 | return [self findImage:_defaultImage]; 36 | } 37 | 38 | - (id)item { 39 | return @""; 40 | } 41 | - (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController { 42 | return @""; 43 | } 44 | 45 | - (UIImage *)findImage:(NSString *)imagePath { 46 | if (imagePath != nil) { 47 | UIImage *image = nil; 48 | 49 | // Load the image from the application assets 50 | NSString *fileNamePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:imagePath]; 51 | ; 52 | image = [UIImage imageWithContentsOfFile:fileNamePath]; 53 | if (image != nil) { 54 | return image; 55 | } 56 | 57 | //Load local image by extracting the filename without extension 58 | NSString *newImagePath = [[imagePath lastPathComponent] stringByDeletingPathExtension]; 59 | image = [UIImage imageNamed:newImagePath]; 60 | if (image != nil) { 61 | return image; 62 | } 63 | 64 | //image from URL 65 | image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]]]; 66 | if (image != nil) { 67 | return image; 68 | } 69 | 70 | //load remote image 71 | image = [UIImage imageWithContentsOfFile:imagePath]; 72 | if (image != nil) { 73 | return image; 74 | } 75 | NSLog(@"image NOT found"); 76 | } 77 | return nil; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /social.xcodeproj/xcuserdata/madsmoller.xcuserdatad/xcschemes/Build & Test.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Classes/NappCustomActivity.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Module developed by Napp CMS 3 | * Mads Møller 4 | * 5 | * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. 6 | * and licensed under the Apache Public License (version 2) 7 | */ 8 | 9 | #import "NappCustomActivity.h" 10 | 11 | @interface NappCustomActivity () 12 | 13 | @property (copy, nonatomic) NSArray *activityItems; 14 | @property (strong, nonatomic) NSString *title; 15 | @property (strong, nonatomic) NSString *type; 16 | @property (strong, nonatomic) UIImage *image; 17 | @property (strong, nonatomic) TiModule *module; 18 | @property (strong, nonatomic) KrollCallback *callback; 19 | 20 | @end 21 | 22 | @implementation NappCustomActivity 23 | 24 | - (void)dealloc { 25 | [_activityItems release]; 26 | [_title release]; 27 | [_type release]; 28 | [_image release]; 29 | [_module release]; 30 | [_callback release]; 31 | 32 | [super dealloc]; 33 | } 34 | 35 | #pragma mark - Hierarchy 36 | #pragma mark UIActivity 37 | 38 | - (NSString *)activityType { 39 | return self.type; 40 | } 41 | 42 | - (NSString *)activityTitle { 43 | return self.title; 44 | } 45 | 46 | - (void)prepareWithActivityItems:(NSArray *)activityItems { 47 | self.activityItems = activityItems; 48 | } 49 | 50 | - (BOOL)canPerformWithActivityItems:(NSArray *)activityItems { 51 | return YES; 52 | } 53 | 54 | - (UIImage *)activityImage { 55 | return self.image; 56 | } 57 | 58 | - (UIViewController *)activityViewController { 59 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:self.title, @"title", self.type, @"type", self.type, @"activityName", nil]; 60 | 61 | [self.module fireEvent:@"customActivity" withObject:event]; 62 | if (self.callback) { 63 | NSArray *array = [NSArray arrayWithObjects:event, nil]; 64 | 65 | [self.callback call:array thisObject:nil]; 66 | } 67 | [self activityDidFinish:YES]; 68 | return nil; 69 | } 70 | 71 | #pragma mark - Self 72 | #pragma mark NappCustomActivity 73 | 74 | - (UIViewController *)performWithActivityItems:(NSArray *)activityItems { 75 | [self activityDidFinish:YES]; 76 | } 77 | 78 | - (id)initWithSettings:(NSDictionary *)dict { 79 | self = [super init]; 80 | if (self) { 81 | self.type = [dict objectForKey:@"type"]; 82 | self.title = [dict objectForKey:@"title"]; 83 | self.image = [dict objectForKey:@"image"]; 84 | self.module = [dict objectForKey:@"module"]; 85 | self.callback = [dict objectForKey:@"callback"]; 86 | } 87 | return (self); 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # BasedOnStyle: WebKit 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: DontAlign 5 | AlignConsecutiveAssignments: false 6 | AlignConsecutiveDeclarations: false 7 | AlignEscapedNewlinesLeft: false 8 | AlignOperands: false 9 | AlignTrailingComments: false 10 | AllowAllParametersOfDeclarationOnNextLine: true 11 | AllowShortBlocksOnASingleLine: false 12 | AllowShortCaseLabelsOnASingleLine: false 13 | AllowShortFunctionsOnASingleLine: All 14 | AllowShortIfStatementsOnASingleLine: false 15 | AllowShortLoopsOnASingleLine: false 16 | AlwaysBreakAfterDefinitionReturnType: None 17 | AlwaysBreakAfterReturnType: None 18 | AlwaysBreakBeforeMultilineStrings: false 19 | AlwaysBreakTemplateDeclarations: false 20 | BinPackArguments: true 21 | BinPackParameters: true 22 | BraceWrapping: 23 | AfterClass: false 24 | AfterControlStatement: false 25 | AfterEnum: false 26 | AfterFunction: true 27 | AfterNamespace: false 28 | AfterObjCDeclaration: false 29 | AfterStruct: false 30 | AfterUnion: false 31 | BeforeCatch: false 32 | BeforeElse: false 33 | IndentBraces: false 34 | BreakBeforeBinaryOperators: All 35 | BreakBeforeBraces: WebKit 36 | BreakBeforeTernaryOperators: true 37 | BreakConstructorInitializersBeforeComma: true 38 | BreakAfterJavaFieldAnnotations: false 39 | BreakStringLiterals: true 40 | ColumnLimit: 0 41 | CommentPragmas: '^ IWYU pragma:' 42 | BreakBeforeInheritanceComma: false 43 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 44 | ConstructorInitializerIndentWidth: 4 45 | ContinuationIndentWidth: 4 46 | Cpp11BracedListStyle: false 47 | DerivePointerAlignment: false 48 | DisableFormat: false 49 | ExperimentalAutoDetectBinPacking: false 50 | FixNamespaceComments: false 51 | ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] 52 | IncludeCategories: 53 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 54 | Priority: 2 55 | - Regex: '^(<|"(gtest|isl|json)/)' 56 | Priority: 3 57 | - Regex: '.*' 58 | Priority: 1 59 | IncludeIsMainRegex: '$' 60 | IndentCaseLabels: false 61 | IndentWidth: 2 62 | IndentWrappedFunctionNames: false 63 | JavaScriptQuotes: Leave 64 | JavaScriptWrapImports: true 65 | KeepEmptyLinesAtTheStartOfBlocks: true 66 | MacroBlockBegin: '' 67 | MacroBlockEnd: '' 68 | MaxEmptyLinesToKeep: 1 69 | NamespaceIndentation: Inner 70 | ObjCBlockIndentWidth: 2 71 | ObjCSpaceAfterProperty: true 72 | ObjCSpaceBeforeProtocolList: true 73 | PenaltyBreakBeforeFirstCallParameter: 19 74 | PenaltyBreakComment: 300 75 | PenaltyBreakFirstLessLess: 120 76 | PenaltyBreakString: 1000 77 | PenaltyExcessCharacter: 1000000 78 | PenaltyReturnTypeOnItsOwnLine: 60 79 | PointerAlignment: Right 80 | ReflowComments: true 81 | SortIncludes: true 82 | SpaceAfterCStyleCast: false 83 | SpaceAfterTemplateKeyword: true 84 | SpaceBeforeAssignmentOperators: true 85 | SpaceBeforeParens: ControlStatements 86 | SpaceInEmptyParentheses: false 87 | SpacesBeforeTrailingComments: 1 88 | SpacesInAngles: false 89 | SpacesInContainerLiterals: true 90 | SpacesInCStyleCastParentheses: false 91 | SpacesInParentheses: false 92 | SpacesInSquareBrackets: false 93 | Standard: Cpp11 94 | TabWidth: 8 95 | UseTab: Never 96 | ... 97 | -------------------------------------------------------------------------------- /example/follow_on_twitter.js: -------------------------------------------------------------------------------- 1 | /* 2 | By @dan_tamas. 3 | 4 | You will need the TiSocial.Framework module found here: https://github.com/viezel/TiSocial.Framework 5 | 6 | tw_apps taken from here: https://github.com/chrismaddern/Follow-Me-On-Twitter-iOS-Button/blob/master/FollowMeButton.m by Chris Maddern. 7 | 8 | 9 | Example: 10 | 11 | var follow_tw = Titanium.UI.createButton({ 12 | title:'Following ?', 13 | top:310, 14 | width:200, 15 | height:40, 16 | enabled:false 17 | }); 18 | 19 | 20 | require('/backend/follow_on_twitter')({ 21 | button:follow_tw, 22 | twitter_account:'dan_tamas', 23 | onFollow:function() { 24 | follow_tw.title = "Thnx for Following!"; 25 | follow_tw.enabled = false; 26 | }, 27 | onNotFollow: function() { 28 | follow_tw.enabled = true; 29 | follow_tw.title = 'Follow Me!' 30 | }, 31 | onError: function(err) { 32 | if (err == 'No account') { 33 | follow_tw.enabled = false; 34 | follow_tw.title = 'No Account Set' 35 | } 36 | else { 37 | alert(err); 38 | } 39 | } 40 | }); 41 | 42 | 43 | */ 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | var tw_apps = [ 52 | 'twitter://user?screen_name={handle}', // Twitter 53 | 'tweetbot:///user_profile/{handle}', // TweetBot 54 | 'twitterrific:///profile?screen_name={handle}', // Twitteriffic 55 | 'echofon:///user_timeline?{handle}', // Echofon 56 | 'twit:///user?screen_name={handle}', // Twittelator Pro 57 | 'x-seesmic://twitter_profile?twitter_screen_name={handle}', // Seesmic 58 | 'x-birdfeed://user?screen_name={handle}', // Birdfeed 59 | 'tweetings:///user?screen_name={handle}', // Tweetings 60 | 'simplytweet:?link=http://twitter.com/{handle}', // SimplyTweet 61 | 'icebird://user?screen_name={handle}', // IceBird 62 | 'fluttr://user/{handle}', // Fluttr 63 | 'http://twitter.com/{handle}' 64 | ]; 65 | 66 | exports = function(params) { 67 | /* 68 | params.button - the button that will do the following 69 | params.twitter_account - the twitter account to be followed eg dan_tamas (without @ in front) 70 | params.onFollow - callback to execute on following the user or if is already followed. This will trigger on iOS6 only 71 | params.onNotFollow - callback to execute if the user is not followed. This will trigger on iOS6 only 72 | params.onError - callback in case of an error. This will trigger on iOS6 only 73 | 74 | On iOS6 the button will have in fact 3 states: fetching follow status, following, not following 75 | On iOS5 the button will be "not following" only and will try to open a twitter application on the device 76 | */ 77 | 78 | var Social = require('dk.napp.social'); 79 | 80 | if (Social.isTwitterSupported() && Social.isRequestTwitterSupported()) { //min iOS6 required 81 | Social.addEventListener("getFollow", function(e) { //default callback 82 | if (e.success && e.response[0] && e.response[0].connections.indexOf('following') > -1) { 83 | params.onFollow(); 84 | } else { 85 | params.onNotFollow(); 86 | } 87 | }); 88 | 89 | Social.addEventListener("followMe", function(e) { //default callback 90 | if (e.success && e.response.following) { 91 | params.onFollow(); 92 | } else { 93 | params.onNotFollow(); 94 | } 95 | }); 96 | 97 | Social.addEventListener("error", function(e){ 98 | params.onError(e.status); 99 | }); 100 | 101 | 102 | Social.requestTwitter({ 103 | requestType:"GET", 104 | callbackEvent:'getFollow', 105 | url:"https://api.twitter.com/1.1/friendships/lookup.json" 106 | }, { 107 | 'screen_name': params.twitter_account 108 | }); 109 | 110 | Ti.API.info(97); 111 | 112 | 113 | } 114 | else { 115 | params.onNotFollow(); 116 | } 117 | 118 | 119 | params.button.addEventListener('click', function(){ 120 | if (Social.isRequestTwitterSupported()) { //min iOS6 required 121 | Social.requestTwitter({ 122 | requestType:"POST", 123 | callbackEvent:'followMe', 124 | url:"https://api.twitter.com/1/friendships/create.json" 125 | }, { 126 | 'screen_name': params.twitter_account 127 | }); 128 | } 129 | else { 130 | for (var i=0; i < tw_apps.length; i++) { 131 | var url = tw_apps[i].replace('{handle}',params.twitter_account); 132 | if (Ti.Platform.canOpenURL(url) ) { 133 | Ti.Platform.openURL(url); 134 | break; 135 | } 136 | }; 137 | } 138 | }); 139 | }; 140 | -------------------------------------------------------------------------------- /example/app.js: -------------------------------------------------------------------------------- 1 | var win = Ti.UI.createWindow({ 2 | backgroundColor:'white', 3 | layout: "vertical" 4 | }); 5 | 6 | var btnContainer = Ti.UI.createScrollView(); 7 | 8 | 9 | 10 | var activityPopoverBtn = Ti.UI.createButton({ 11 | width:100, 12 | left: 50, 13 | height:35, 14 | top:115, 15 | bubble: false, 16 | title:"Activity PopOver (iPad)" 17 | }); 18 | btnContainer.add(activityPopoverBtn); 19 | var activityPopoverBtnTwo = Ti.UI.createButton({ 20 | width:100, 21 | right: 50, 22 | height:35, 23 | top:115, 24 | bubble: false, 25 | title:"Activity PopOver (iPad)" 26 | }); 27 | btnContainer.add(activityPopoverBtnTwo); 28 | 29 | var seperatorView = Ti.UI.createView({ 30 | height: 250, 31 | backgroundColor: "red" 32 | }); 33 | 34 | var view = Ti.UI.createView({ 35 | height: Ti.UI.SIZE, 36 | layout:"vertical" 37 | }); 38 | view.add(btnContainer); 39 | 40 | win.add(seperatorView); 41 | win.add(view); 42 | 43 | //iOS only module 44 | 45 | var Social = require('dk.napp.social'); 46 | Ti.API.info("module is => " + Social); 47 | 48 | Ti.API.info("Facebook available: " + Social.isFacebookSupported()); 49 | Ti.API.info("Twitter available: " + Social.isTwitterSupported()); 50 | Ti.API.info("SinaWeibo available: " + Social.isSinaWeiboSupported()); 51 | 52 | // find all Twitter accounts on this phone 53 | if(Social.isRequestTwitterSupported()){ //min iOS6 required 54 | var accounts = []; 55 | Social.addEventListener("accountList", function(e){ 56 | Ti.API.info("Accounts:"); 57 | accounts = e.accounts; //accounts 58 | Ti.API.info(accounts); 59 | }); 60 | 61 | Social.twitterAccountList(); 62 | } 63 | 64 | 65 | Social.addEventListener("facebookAccount", function(e){ 66 | Ti.API.info("facebookAccount: "+e.success); 67 | fbAccount = e.account; 68 | Ti.API.info(e); 69 | }); 70 | 71 | var popover = Ti.UI.iPad.createPopover({ 72 | contentView: Ti.UI.createLabel({ 73 | text: 'Hello World!', 74 | font: { 75 | fontSize: 40 76 | } 77 | }) 78 | }); 79 | 80 | 81 | activityPopoverBtnTwo.addEventListener("click", function(e){ 82 | 83 | Ti.API.info("e.source.rect.x:: " + e.source.rect.x); 84 | Ti.API.info("e.source.rect.y:: " + e.source.rect.y); 85 | 86 | 87 | Ti.API.info("e.x:: " + e.x); 88 | Ti.API.info("e.y:: " + e.y); 89 | 90 | 91 | Ti.API.info("e.activityPopoverBtn.rect.x:: " + activityPopoverBtn.rect.x); 92 | Ti.API.info("e.activityPopoverBtn.rect.y:: " + activityPopoverBtn.rect.y); 93 | 94 | popover.show({ 95 | view: e.source, 96 | animated: false, 97 | arrowDirection: Ti.UI.iPad.POPOVER_ARROW_DIRECTION_DOWN 98 | }); 99 | 100 | }); 101 | activityPopoverBtn.addEventListener("click", function(e){ 102 | Ti.API.info("E:: " + JSON.stringify(e)); 103 | if(Social.isActivityViewSupported()){ //min iOS6 required 104 | 105 | Ti.API.info("e.source.rect.x:: " + e.source.rect.x); 106 | Ti.API.info("e.source.rect.y:: " + e.source.rect.y); 107 | 108 | 109 | Ti.API.info("e.x:: " + e.x); 110 | Ti.API.info("e.y:: " + e.y); 111 | 112 | 113 | Ti.API.info("e.activityPopoverBtn.rect.x:: " + activityPopoverBtn.rect.x); 114 | Ti.API.info("e.activityPopoverBtn.rect.y:: " + activityPopoverBtn.rect.y); 115 | 116 | 117 | Social.activityPopover({ 118 | text:"share like a king!", 119 | image:"pin.png", 120 | removeIcons:"print,sms,copy,contact,camera,mail", 121 | view: e.source //source button 122 | }); 123 | } else { 124 | //implement fallback sharing.. 125 | } 126 | }); 127 | 128 | 129 | Social.addEventListener("twitterRequest", function(e){ //default callback 130 | Ti.API.info("twitterRequest: "+e.success); 131 | Ti.API.info(e.response); //json 132 | Ti.API.info(e.rawResponse); //raw data - this is a string 133 | }); 134 | 135 | 136 | 137 | Social.addEventListener("facebookRequest", function(e){ //default callback 138 | Ti.API.info("facebookRequest: "+e.success); 139 | Ti.API.info(e); 140 | }); 141 | 142 | Social.addEventListener("facebookProfile", function(e){ 143 | Ti.API.info("facebook profile: "+e.success); 144 | Ti.API.info(e.response); //json 145 | }); 146 | 147 | Social.addEventListener("complete", function(e){ 148 | Ti.API.info("complete: " + e.success); 149 | console.log(e); 150 | 151 | if (e.platform == "activityView" || e.platform == "activityPopover") { 152 | switch (e.activity) { 153 | case Social.ACTIVITY_TWITTER: 154 | Ti.API.info("User is shared on Twitter"); 155 | break; 156 | 157 | case Social.ACTIVITY_CUSTOM: 158 | Ti.API.info("This is a customActivity: " + e.activityName); 159 | break; 160 | } 161 | } 162 | }); 163 | 164 | Social.addEventListener("error", function(e){ 165 | Ti.API.info("error:"); 166 | Ti.API.info(e); 167 | }); 168 | 169 | Social.addEventListener("cancelled", function(e){ 170 | Ti.API.info("cancelled:"); 171 | Ti.API.info(e); 172 | }); 173 | 174 | 175 | Social.addEventListener("customActivity", function(e){ 176 | Ti.API.info("customActivity"); 177 | Ti.API.info(e); 178 | 179 | }); 180 | 181 | win.open(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TiSocial.Framework Module 2 | 3 | ## Description 4 | 5 | The TiSocial.Framework Module extends the Appcelerator Titanium Mobile framework with the iOS6 social.framework. This enables sharing content to Facebook, Twitter and other platforms. 6 | 7 | The module is licensed under the MIT license. 8 | 9 | 10 | ![SLComposeViewController](http://s7.postimage.org/tjrcwqtdn/SLCompose_View_Controller.png) 11 | ![UIActivityViewController](http://s14.postimage.org/y85v7ev1t/UIActivity_View_Controller.png) 12 | 13 | 14 | 15 | ## Referencing the module in your Titanium Mobile application ## 16 | 17 | Simply add the following lines to your `tiapp.xml` file: 18 | 19 | 20 | dk.napp.social 21 | 22 | 23 | 24 | ## Reference 25 | 26 | For more detailed code examples take a look into the example app 27 | 28 | ## Twitter 29 | 30 | ### Social.isTwitterSupported() 31 | Returns *true* or *false*. 32 | false if no account has been defined (true in the 6.0 simulator) or the iOS Version doesn't support the Social Framework. 33 | 34 | ### Social.twitter(*{Object} options*) 35 | `options` can have the following keys: 36 | 37 | * *text* - the status message 38 | * *image* - a local/remote path to an image you want to share 39 | * *url* - a url you want to share 40 | 41 | Each of these options is optional 42 | 43 | ### Social.twitterRequest(*{Object} options [, {Object} requestParameter]*) 44 | `options`has the following keys: 45 | 46 | * *requestType* - can be *GET*, *POST* or *DELETE* 47 | * *url* - the url you want to request 48 | * *callbackEvent* - optional - default: *twitterRequest* - how is the event called that is fired after request has succeeded? 49 | * *accountWithIdentifier* - Identifier to select which account to request twitter with. 50 | 51 | `requestParameter` is optional, but is build like this: 52 | 53 | { 54 | 'screen_name': 'CBeloch' 55 | } 56 | 57 | So *screen_name* is the parameter name / key and *CBeloch* is the value of the parameter 58 | 59 | ### Social.twitterAccountList() 60 | Returns a list of twiiter accounts. use the EventListener `accountList` to capture this list. 61 | 62 | ```javascript 63 | Social.addEventListener("accountList", function(e){ 64 | Ti.API.info("Accounts:"); 65 | accounts = e.accounts; //accounts 66 | Ti.API.info(accounts); 67 | }); 68 | Social.twitterAccountList(); 69 | ``` 70 | 71 | ## Facebook 72 | 73 | ### Social.isFacebookSupported() 74 | Returns *true* or *false*. 75 | false if no account has been defined (true in the 6.0 simulator) or the iOS Version doesn't support the Social Framework. 76 | 77 | ### Social.facebook(*{Object} options*) 78 | `options` can have the following keys: 79 | 80 | * *text* - the status message 81 | * *image* - a local/remote path to an image you want to share 82 | * *url* - a url you want to share 83 | 84 | Each of these options is optional 85 | 86 | ### Social.facebookRequest(*{Object} options [, {Object} requestParameter]*) 87 | `options` has the following keys: 88 | 89 | * *requestType* - can be *GET*, *POST* or *DELETE* 90 | * *url* - the url you want to request 91 | * *appIdKey* - the appid of your facebook app 92 | * *permissionsKey* - optional - a comma seperated string that contains the required permissions 93 | * *callbackEvent* - optional - default: *facebookRequest* - how is the event called that is fired after request has succeeded? 94 | 95 | `requestParameter` is optional, but is build like this: 96 | 97 | { 98 | fields: 'id,name,devices' 99 | } 100 | 101 | So *fields* is the parameter name / key and *id,name,devices* is the value of the parameter 102 | 103 | ### Social.grantFacebookPermissions 104 | Before you can send request to the Facebook API, you start by getting the users permissions. 105 | 106 | ```javascript 107 | var fbAccount; 108 | Social.grantFacebookPermissions({ 109 | appIdKey:"YOUR_FB_APP_ID", 110 | permissionsKey: "email" //FB docs: https://developers.facebook.com/docs/reference/login/extended-permissions/ 111 | }); 112 | Social.addEventListener("facebookAccount", function(e){ 113 | fbAccount = e.account; //now you have stored the FB account. You can then request facebook using the below method 114 | }); 115 | ``` 116 | 117 | ### Social.requestFacebookWithIdentifier(*{Object} options [, {Object} requestParameter]*) 118 | 119 | Request Facebook with a specific account. 120 | 121 | ```javascript 122 | Social.requestFacebookWithIdentifier({ 123 | requestType:"GET", 124 | accountWithIdentifier: fbAccount["identifier"], //start by granting facebook permissions 125 | url:"https://graph.facebook.com/me", 126 | callbackEvent: "facebookProfile", 127 | }, { 128 | fields: 'id,name,location' 129 | }); 130 | ``` 131 | 132 | ### Social.renewFacebookAccessToken 133 | 134 | The accessToken will eventually be invalid, if you store the FB acccount in a App property or storage of some kind. This method can renew the accessToken, and make you able to request Facebook again. 135 | This method rely on the same *facebookAccount* eventlistener, as `grantFacebookPermissions`. 136 | 137 | ```javascript 138 | Social.renewFacebookAccessToken(); 139 | ``` 140 | 141 | ## Sina Weibo 142 | 143 | ### Social.isSinaWeiboSupported() 144 | Returns *true* or *false*. 145 | false if no account has been defined (true in the 6.0 simulator) or the iOS Version doesn't support the Social Framework. 146 | 147 | ### Social.sinaweibo(*{Object} options*) 148 | `options` can have the following keys: 149 | 150 | * *text* - the status message 151 | * *image* - a local/remote path to an image you want to share 152 | * *url* - a url you want to share 153 | 154 | Each of these options is optional 155 | 156 | ## UIActivityViewController 157 | 158 | ### Constants 159 | 160 | * **ACTIVITY_FACEBOOK**: UIActivityTypePostToFacebook 161 | * **ACTIVITY_TWITTER**: UIActivityTypePostToTwitter 162 | * **ACTIVITY_WEIBO**: UIActivityTypePostToWeibo 163 | * **ACTIVITY_MESSAGE**: UIActivityTypeMessage 164 | * **ACTIVITY_MAIL**: UIActivityTypeMail 165 | * **ACTIVITY_PRINT**: UIActivityTypePrint 166 | * **ACTIVITY_COPY**: UIActivityTypeCopyToPasteboard 167 | * **ACTIVITY_ASSIGN_CONTATCT**: UIActivityTypeAssignToContact 168 | * **ACTIVITY_SAVE_CAMERA**: UIActivityTypeSaveToCameraRoll 169 | * **ACTIVITY_READING_LIST**: UIActivityTypeAddToReadingList 170 | * **ACTIVITY_FLICKR**: UIActivityTypePostToFlickr 171 | * **ACTIVITY_VIMEO**: UIActivityTypePostToVimeo 172 | * **ACTIVITY_AIRDROP**: UIActivityTypeAirDrop 173 | * **ACTIVITY_TENCENT_WEIBO**: UIActivityTypePostToTencentWeibo 174 | * **ACTIVITY_CUSTOM**: Custom Activities 175 | 176 | ### Events 177 | 178 | * **complete**: Fired when the user completes using an Activity. Here, you can verify which activity the user has selected by checking the *activity* event property. When dealing with customActivities, you can get the *activityName* property. 179 | * **cancelled**: Fired when user did not complete the request. 180 | 181 | ### Social.activityView() 182 | The first required `options` argument can have the following keys: 183 | 184 | * *text* - the status message 185 | * *htmlText* - html message to use in the e-mail activity (requires emailIsHTML = true). If null will use the "text" message 186 | * *url* - a url you want to share 187 | * *image* - a local/remote path to an image you want to share 188 | * *removeIcons* - customise the dialog by removing unwanted icons. 189 | * *emailIsHTML* - Optional boolean flag that tells if email content should be in html format. 190 | * *subject* - a subject to be used when sharing through email 191 | 192 | The second optional argument is an array with objects. Use this to create custom UIActivities. 193 | The posibilties are almost endless. have a look at: *http://uiactivities.com* for inspiration. 194 | 195 | ```javascript 196 | Social.activityView({ 197 | text:"share like a king!", 198 | subject:"I would like to share this with you", 199 | image:"pin.png", 200 | removeIcons:"print,sms,copy,contact,camera,mail", 201 | emailIsHTML : false 202 | },[ 203 | { 204 | title:"Custom Share", 205 | type:"hello.world", 206 | image:"pin.png", 207 | callback: function(e) { 208 | alert("You chose me!"); 209 | } 210 | }, 211 | { 212 | title:"Open in Safari", 213 | type:"open.safari", 214 | image:"safari.png" 215 | } 216 | ]); 217 | ``` 218 | 219 | ### Social.activityPopover() (iPad only) 220 | The first required `options` argument can have the following keys: 221 | 222 | * *text* - the status message 223 | * *htmlText* - html message to use in the e-mail activity (requires emailIsHTML = true). If null will use the "text" message 224 | * *url* - a url you want to share 225 | * *image* - a local/remote path to an image you want to share 226 | * *removeIcons* - customise the dialog by removing unwanted icons. 227 | * *view* - the source button 228 | * *emailIsHTML* - Optional boolean flag that tells if email content should be in html format. 229 | * *subject* - a subject to be used when sharing through email 230 | 231 | The second optional argument is an array with objects. Use this to create custom UIActivities. 232 | 233 | See `Social.activityView()`. 234 | 235 | ## Example of usage 236 | 237 | ### FollowMe Button 238 | `example/follow_on_twitter.js` contains an example on how to implement a "Follow Me" button. 239 | It takes an account the os version and for iOS 5 will try to open the profile page in another application that exits on the device. 240 | 241 | Please check the *Example* section in the file. 242 | 243 | 244 | 245 | ## Changelog 246 | 247 | ***v.1.8.2*** 248 | 249 | * Support HTML text for email and plain text for other activities 250 | 251 | ***v.1.8.1*** 252 | 253 | * Added support for iOS8 Popover (@adesugbaa) 254 | 255 | ***v.1.8.0*** 256 | 257 | * Avoiding conflict with new Facebook module (#129) 258 | 259 | ***v.1.7.10*** 260 | 261 | * Added missing URL option to iPad activity sheet 262 | * Added subject for email as mentioned in #112 263 | * Fixed a potential memory leak 264 | 265 | ***v.1.7.9*** 266 | 267 | * Fixed issue with popover not showing on iPad 268 | 269 | ***v1.7.8*** 270 | 271 | * Added support for 64-bit. Previous attempt was incorrect. 272 | 273 | ***v1.7.7*** 274 | 275 | * Added support for email only html customization 276 | 277 | ***v1.7.6*** 278 | 279 | * Added support for 64-bit 280 | 281 | **v1.7.5** 282 | 283 | * Built with SDK 3.4.0, works on iOS 8. Changed project to use ARC, removed iOS 5 support (some deprecated stuff) 284 | 285 | **v1.7.4** 286 | 287 | * Remove iOS8- specific build flags 288 | 289 | **v1.7.3** 290 | 291 | * Bugfix for unsupported iOS6 sharing types 292 | 293 | **v1.7.2** 294 | 295 | * Added url property for activityView to support Reading List 296 | * fixed image sharing 297 | 298 | **v1.7.1** 299 | 300 | * Added new activities in iOS7: `ACTIVITY_READING_LIST`, `ACTIVITY_FLICKR`, `ACTIVITY_VIMEO`, `ACTIVITY_AIRDROP ` & `ACTIVITY_TENCENT_WEIBO` 301 | * Added callback on custom activities 302 | 303 | **v1.7.0** 304 | 305 | * Added support iOS7 306 | 307 | **v1.6.2** 308 | 309 | * Added support to verify what activity was choiced by user in *complete* event 310 | * Create constants to each default activity 311 | * Documentation changes 312 | 313 | **v1.6.1** 314 | 315 | * Added userId to `twitterAccountList()` 316 | * Bugfix for Twitter iOS5 error handling. 317 | 318 | **v1.6.0** 319 | 320 | * Added custom UIActivity. You can create your own sharing option for activityView in seconds. 321 | * Added `grantFacebookPermissions()`, `renewFacebookAccessToken()` and `requestFacebookWithIdentifier()` for giving you a greater control of when to promt the enduser with permissions. 322 | * Added platform property to objects returned to eventListeners. Twiiter, Facebook and activityView. 323 | 324 | **v1.5.5** 325 | 326 | * Added Facebook accessToken output on `requestFacebook()`. 327 | * Added better error handling. error eventListener return the reason as a string in e.message. 328 | 329 | **v1.5.4** 330 | 331 | * Added `twitterAccountList()` and `accountWithIdentifier`. 332 | 333 | **v1.5.3** 334 | 335 | * Added UIActivityViewController popOver for iPad use: `activityPopover()`. 336 | 337 | **v1.5.2** 338 | 339 | * Added raw data callback response for `requestTwitter()`. 340 | 341 | **v1.5.1** 342 | 343 | * Bugfixes. 344 | * Added `isRequestTwitterSupported()` for iOS6 check. 345 | 346 | **v1.5** 347 | 348 | * UIActivityViewController implemented. 349 | * Improved image filepath finder (bundle, data, remote, url) 350 | 351 | **v1.4** 352 | 353 | * Support for iOS5 Twiiter Framework. 354 | 355 | **v1.3** 356 | 357 | * Different parameter setup for `requestFacebook()` and `requestTwitter()`. 358 | * Now supporting Wall posting and more request parameter. 359 | 360 | **v1.2** 361 | 362 | * Added support to share image from downloaded remote images in cache or documents folders. 363 | * Added support to share image from image urls. 364 | 365 | **v1.1** 366 | 367 | * SLRequest methods implemented. `requestFacebook()` and `requestTwitter()`. 368 | 369 | **v1.0** 370 | 371 | * Initial Implementation of SLComposeViewController. 372 | 373 | 374 | ## Author 375 | 376 | **Mads Møller** 377 | web: http://www.napp.dk 378 | email: mm@napp.dk 379 | twitter: @nappdev 380 | 381 | ## Contributors 382 | 383 | **Christopher Beloch** 384 | twitter: @CBeloch 385 | 386 | **Jongeun Lee** 387 | twitter: @yomybaby 388 | 389 | **Daniel Tamas** 390 | twitter: @dan_tamas 391 | 392 | **Rafael Kellermann Streit** 393 | twitter: @rafaelks 394 | 395 | **Joseandro Luiz** 396 | twitter: @joseandroluiz 397 | 398 | **Carlos Zinato** 399 | twitter: @chmiiller 400 | 401 | **João Paulo** 402 | twitter: @juaumlol 403 | 404 | ## License 405 | 406 | Copyright (c) 2010-2013 Mads Møller 407 | 408 | Permission is hereby granted, free of charge, to any person obtaining a copy 409 | of this software and associated documentation files (the "Software"), to deal 410 | in the Software without restriction, including without limitation the rights 411 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 412 | copies of the Software, and to permit persons to whom the Software is 413 | furnished to do so, subject to the following conditions: 414 | 415 | The above copyright notice and this permission notice shall be included in 416 | all copies or substantial portions of the Software. 417 | 418 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 419 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 420 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 421 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 422 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 423 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 424 | THE SOFTWARE. 425 | -------------------------------------------------------------------------------- /social.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 24416B8111C4CA220047AFDD /* Build & Test */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 24416B8A11C4CA520047AFDD /* Build configuration list for PBXAggregateTarget "Build & Test" */; 13 | buildPhases = ( 14 | 24416B8011C4CA220047AFDD /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | 24416B8511C4CA280047AFDD /* PBXTargetDependency */, 18 | ); 19 | name = "Build & Test"; 20 | productName = "Build & test"; 21 | }; 22 | /* End PBXAggregateTarget section */ 23 | 24 | /* Begin PBXBuildFile section */ 25 | 24DD6CF91134B3F500162E58 /* DkNappSocialModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DD6CF71134B3F500162E58 /* DkNappSocialModule.h */; }; 26 | 24DD6CFA1134B3F500162E58 /* DkNappSocialModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* DkNappSocialModule.m */; }; 27 | 24DE9E1111C5FE74003F90F6 /* DkNappSocialModuleAssets.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DE9E0F11C5FE74003F90F6 /* DkNappSocialModuleAssets.h */; }; 28 | 24DE9E1211C5FE74003F90F6 /* DkNappSocialModuleAssets.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DE9E1011C5FE74003F90F6 /* DkNappSocialModuleAssets.m */; }; 29 | 69B6065A15A4DC5600AB991D /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69B6065715A4DC4800AB991D /* Social.framework */; }; 30 | AA747D9F0F9514B9006C5449 /* DkNappSocial_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* DkNappSocial_Prefix.pch */; }; 31 | AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; 32 | B603B54D1700E18B002E4196 /* NappCustomActivity.h in Headers */ = {isa = PBXBuildFile; fileRef = B603B54B1700E18B002E4196 /* NappCustomActivity.h */; }; 33 | B603B54E1700E18B002E4196 /* NappCustomActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = B603B54C1700E18B002E4196 /* NappCustomActivity.m */; }; 34 | B663690D17C29D03008AD704 /* Accounts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B66EFA9016137E8100A5A9B4 /* Accounts.framework */; }; 35 | DE2F4E581A41FA5B002B4204 /* NappItemProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2F4E561A41FA5B002B4204 /* NappItemProvider.m */; }; 36 | DE2F4E591A41FA5B002B4204 /* NappItemProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = DE2F4E571A41FA5B002B4204 /* NappItemProvider.h */; }; 37 | E8262CDE1D06718C00913482 /* NappImageProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E8262CDC1D06718C00913482 /* NappImageProvider.h */; }; 38 | E8262CDF1D06718C00913482 /* NappImageProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = E8262CDD1D06718C00913482 /* NappImageProvider.m */; }; 39 | /* End PBXBuildFile section */ 40 | 41 | /* Begin PBXContainerItemProxy section */ 42 | 24416B8411C4CA280047AFDD /* PBXContainerItemProxy */ = { 43 | isa = PBXContainerItemProxy; 44 | containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; 45 | proxyType = 1; 46 | remoteGlobalIDString = D2AAC07D0554694100DB518D; 47 | remoteInfo = social; 48 | }; 49 | /* End PBXContainerItemProxy section */ 50 | 51 | /* Begin PBXFileReference section */ 52 | 24DD6CF71134B3F500162E58 /* DkNappSocialModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DkNappSocialModule.h; path = Classes/DkNappSocialModule.h; sourceTree = ""; }; 53 | 24DD6CF81134B3F500162E58 /* DkNappSocialModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DkNappSocialModule.m; path = Classes/DkNappSocialModule.m; sourceTree = ""; }; 54 | 24DD6D1B1134B66800162E58 /* titanium.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = titanium.xcconfig; sourceTree = ""; }; 55 | 24DE9E0F11C5FE74003F90F6 /* DkNappSocialModuleAssets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DkNappSocialModuleAssets.h; path = Classes/DkNappSocialModuleAssets.h; sourceTree = ""; }; 56 | 24DE9E1011C5FE74003F90F6 /* DkNappSocialModuleAssets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DkNappSocialModuleAssets.m; path = Classes/DkNappSocialModuleAssets.m; sourceTree = ""; }; 57 | 69B6065715A4DC4800AB991D /* Social.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Social.framework; path = System/Library/Frameworks/Social.framework; sourceTree = SDKROOT; }; 58 | 8FE4A5C81ADE7CCD009C9EED /* module.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = module.xcconfig; sourceTree = ""; }; 59 | 8FE4A5C91ADE7CDB009C9EED /* manifest */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = manifest; sourceTree = ""; }; 60 | AA747D9E0F9514B9006C5449 /* DkNappSocial_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DkNappSocial_Prefix.pch; sourceTree = SOURCE_ROOT; }; 61 | AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 62 | B603B54B1700E18B002E4196 /* NappCustomActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NappCustomActivity.h; path = Classes/NappCustomActivity.h; sourceTree = ""; }; 63 | B603B54C1700E18B002E4196 /* NappCustomActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NappCustomActivity.m; path = Classes/NappCustomActivity.m; sourceTree = ""; }; 64 | B66EFA9016137E8100A5A9B4 /* Accounts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accounts.framework; path = System/Library/Frameworks/Accounts.framework; sourceTree = SDKROOT; }; 65 | D2AAC07E0554694100DB518D /* libDkNappSocial.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDkNappSocial.a; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | DE2F4E561A41FA5B002B4204 /* NappItemProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NappItemProvider.m; path = Classes/NappItemProvider.m; sourceTree = ""; }; 67 | DE2F4E571A41FA5B002B4204 /* NappItemProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NappItemProvider.h; path = Classes/NappItemProvider.h; sourceTree = ""; }; 68 | E8262CDC1D06718C00913482 /* NappImageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NappImageProvider.h; path = Classes/NappImageProvider.h; sourceTree = ""; }; 69 | E8262CDD1D06718C00913482 /* NappImageProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NappImageProvider.m; path = Classes/NappImageProvider.m; sourceTree = ""; }; 70 | /* End PBXFileReference section */ 71 | 72 | /* Begin PBXFrameworksBuildPhase section */ 73 | D2AAC07C0554694100DB518D /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */, 78 | B663690D17C29D03008AD704 /* Accounts.framework in Frameworks */, 79 | 69B6065A15A4DC5600AB991D /* Social.framework in Frameworks */, 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 034768DFFF38A50411DB9C8B /* Products */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | D2AAC07E0554694100DB518D /* libDkNappSocial.a */, 90 | ); 91 | name = Products; 92 | sourceTree = ""; 93 | }; 94 | 0867D691FE84028FC02AAC07 /* social */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 08FB77AEFE84172EC02AAC07 /* Classes */, 98 | 32C88DFF0371C24200C91783 /* Other Sources */, 99 | 0867D69AFE84028FC02AAC07 /* Frameworks */, 100 | 034768DFFF38A50411DB9C8B /* Products */, 101 | ); 102 | name = social; 103 | sourceTree = ""; 104 | }; 105 | 0867D69AFE84028FC02AAC07 /* Frameworks */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | B66EFA9016137E8100A5A9B4 /* Accounts.framework */, 109 | 69B6065715A4DC4800AB991D /* Social.framework */, 110 | AACBBE490F95108600F1A2B1 /* Foundation.framework */, 111 | ); 112 | name = Frameworks; 113 | sourceTree = ""; 114 | }; 115 | 08FB77AEFE84172EC02AAC07 /* Classes */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | DE2F4E561A41FA5B002B4204 /* NappItemProvider.m */, 119 | DE2F4E571A41FA5B002B4204 /* NappItemProvider.h */, 120 | 24DE9E0F11C5FE74003F90F6 /* DkNappSocialModuleAssets.h */, 121 | 24DE9E1011C5FE74003F90F6 /* DkNappSocialModuleAssets.m */, 122 | 24DD6CF71134B3F500162E58 /* DkNappSocialModule.h */, 123 | 24DD6CF81134B3F500162E58 /* DkNappSocialModule.m */, 124 | B603B54B1700E18B002E4196 /* NappCustomActivity.h */, 125 | B603B54C1700E18B002E4196 /* NappCustomActivity.m */, 126 | E8262CDC1D06718C00913482 /* NappImageProvider.h */, 127 | E8262CDD1D06718C00913482 /* NappImageProvider.m */, 128 | ); 129 | name = Classes; 130 | sourceTree = ""; 131 | }; 132 | 32C88DFF0371C24200C91783 /* Other Sources */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 8FE4A5C91ADE7CDB009C9EED /* manifest */, 136 | 8FE4A5C81ADE7CCD009C9EED /* module.xcconfig */, 137 | AA747D9E0F9514B9006C5449 /* DkNappSocial_Prefix.pch */, 138 | 24DD6D1B1134B66800162E58 /* titanium.xcconfig */, 139 | ); 140 | name = "Other Sources"; 141 | sourceTree = ""; 142 | }; 143 | /* End PBXGroup section */ 144 | 145 | /* Begin PBXHeadersBuildPhase section */ 146 | D2AAC07A0554694100DB518D /* Headers */ = { 147 | isa = PBXHeadersBuildPhase; 148 | buildActionMask = 2147483647; 149 | files = ( 150 | AA747D9F0F9514B9006C5449 /* DkNappSocial_Prefix.pch in Headers */, 151 | 24DD6CF91134B3F500162E58 /* DkNappSocialModule.h in Headers */, 152 | DE2F4E591A41FA5B002B4204 /* NappItemProvider.h in Headers */, 153 | 24DE9E1111C5FE74003F90F6 /* DkNappSocialModuleAssets.h in Headers */, 154 | E8262CDE1D06718C00913482 /* NappImageProvider.h in Headers */, 155 | B603B54D1700E18B002E4196 /* NappCustomActivity.h in Headers */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXHeadersBuildPhase section */ 160 | 161 | /* Begin PBXNativeTarget section */ 162 | D2AAC07D0554694100DB518D /* social */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "social" */; 165 | buildPhases = ( 166 | D2AAC07A0554694100DB518D /* Headers */, 167 | D2AAC07B0554694100DB518D /* Sources */, 168 | D2AAC07C0554694100DB518D /* Frameworks */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | ); 174 | name = social; 175 | productName = social; 176 | productReference = D2AAC07E0554694100DB518D /* libDkNappSocial.a */; 177 | productType = "com.apple.product-type.library.static"; 178 | }; 179 | /* End PBXNativeTarget section */ 180 | 181 | /* Begin PBXProject section */ 182 | 0867D690FE84028FC02AAC07 /* Project object */ = { 183 | isa = PBXProject; 184 | attributes = { 185 | LastUpgradeCheck = 1010; 186 | }; 187 | buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "social" */; 188 | compatibilityVersion = "Xcode 3.2"; 189 | developmentRegion = en; 190 | hasScannedForEncodings = 1; 191 | knownRegions = ( 192 | en, 193 | ja, 194 | de, 195 | fr, 196 | Base, 197 | ); 198 | mainGroup = 0867D691FE84028FC02AAC07 /* social */; 199 | productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; 200 | projectDirPath = ""; 201 | projectRoot = ""; 202 | targets = ( 203 | D2AAC07D0554694100DB518D /* social */, 204 | 24416B8111C4CA220047AFDD /* Build & Test */, 205 | ); 206 | }; 207 | /* End PBXProject section */ 208 | 209 | /* Begin PBXShellScriptBuildPhase section */ 210 | 24416B8011C4CA220047AFDD /* ShellScript */ = { 211 | isa = PBXShellScriptBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | ); 215 | inputPaths = ( 216 | ); 217 | outputPaths = ( 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | shellPath = /bin/sh; 221 | shellScript = "# shell script goes here\n\npython \"${TITANIUM_SDK}/titanium.py\" run --dir=\"${PROJECT_DIR}\"\nexit $?\n"; 222 | }; 223 | /* End PBXShellScriptBuildPhase section */ 224 | 225 | /* Begin PBXSourcesBuildPhase section */ 226 | D2AAC07B0554694100DB518D /* Sources */ = { 227 | isa = PBXSourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | 24DD6CFA1134B3F500162E58 /* DkNappSocialModule.m in Sources */, 231 | E8262CDF1D06718C00913482 /* NappImageProvider.m in Sources */, 232 | 24DE9E1211C5FE74003F90F6 /* DkNappSocialModuleAssets.m in Sources */, 233 | DE2F4E581A41FA5B002B4204 /* NappItemProvider.m in Sources */, 234 | B603B54E1700E18B002E4196 /* NappCustomActivity.m in Sources */, 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | }; 238 | /* End PBXSourcesBuildPhase section */ 239 | 240 | /* Begin PBXTargetDependency section */ 241 | 24416B8511C4CA280047AFDD /* PBXTargetDependency */ = { 242 | isa = PBXTargetDependency; 243 | target = D2AAC07D0554694100DB518D /* social */; 244 | targetProxy = 24416B8411C4CA280047AFDD /* PBXContainerItemProxy */; 245 | }; 246 | /* End PBXTargetDependency section */ 247 | 248 | /* Begin XCBuildConfiguration section */ 249 | 1DEB921F08733DC00010E9CD /* Debug */ = { 250 | isa = XCBuildConfiguration; 251 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 252 | buildSettings = { 253 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 254 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 255 | CLANG_ENABLE_OBJC_WEAK = YES; 256 | CODE_SIGN_IDENTITY = "iPhone Developer"; 257 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 258 | DSTROOT = /tmp/DkNappSocial.dst; 259 | GCC_C_LANGUAGE_STANDARD = c99; 260 | GCC_OPTIMIZATION_LEVEL = 0; 261 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 262 | GCC_PREFIX_HEADER = DkNappSocial_Prefix.pch; 263 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 264 | GCC_THUMB_SUPPORT = NO; 265 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 266 | GCC_VERSION = ""; 267 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 268 | GCC_WARN_MISSING_PARENTHESES = NO; 269 | GCC_WARN_SHADOW = NO; 270 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 271 | GCC_WARN_UNUSED_FUNCTION = YES; 272 | GCC_WARN_UNUSED_PARAMETER = NO; 273 | GCC_WARN_UNUSED_VALUE = NO; 274 | GCC_WARN_UNUSED_VARIABLE = NO; 275 | INSTALL_PATH = /usr/local/lib; 276 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 277 | LIBRARY_SEARCH_PATHS = ""; 278 | OTHER_CFLAGS = ( 279 | "-DDEBUG", 280 | "-DTI_POST_1_2", 281 | ); 282 | OTHER_LDFLAGS = "-ObjC"; 283 | PRODUCT_NAME = DkNappSocial; 284 | PROVISIONING_PROFILE = ""; 285 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 286 | RUN_CLANG_STATIC_ANALYZER = NO; 287 | SDKROOT = iphoneos; 288 | TITANIUM_SDK_VERSION = 3.1.1.GA; 289 | USER_HEADER_SEARCH_PATHS = ""; 290 | VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64"; 291 | }; 292 | name = Debug; 293 | }; 294 | 1DEB922008733DC00010E9CD /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 297 | buildSettings = { 298 | ALWAYS_SEARCH_USER_PATHS = NO; 299 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 300 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 301 | CLANG_ENABLE_OBJC_WEAK = YES; 302 | DSTROOT = /tmp/DkNappSocial.dst; 303 | GCC_C_LANGUAGE_STANDARD = c99; 304 | GCC_MODEL_TUNING = G5; 305 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 306 | GCC_PREFIX_HEADER = DkNappSocial_Prefix.pch; 307 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 308 | GCC_THUMB_SUPPORT = NO; 309 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 310 | GCC_VERSION = ""; 311 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 312 | GCC_WARN_MISSING_PARENTHESES = NO; 313 | GCC_WARN_SHADOW = NO; 314 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 315 | GCC_WARN_UNUSED_FUNCTION = YES; 316 | GCC_WARN_UNUSED_PARAMETER = NO; 317 | GCC_WARN_UNUSED_VALUE = NO; 318 | GCC_WARN_UNUSED_VARIABLE = NO; 319 | INSTALL_PATH = /usr/local/lib; 320 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 321 | "IPHONEOS_DEPLOYMENT_TARGET[sdk=iphoneos*]" = 7.0; 322 | LIBRARY_SEARCH_PATHS = ""; 323 | OTHER_CFLAGS = "-DTI_POST_1_2"; 324 | OTHER_LDFLAGS = "-ObjC"; 325 | PRODUCT_NAME = DkNappSocial; 326 | RUN_CLANG_STATIC_ANALYZER = NO; 327 | SDKROOT = iphoneos; 328 | TITANIUM_SDK_VERSION = 3.1.1.GA; 329 | USER_HEADER_SEARCH_PATHS = ""; 330 | VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64"; 331 | }; 332 | name = Release; 333 | }; 334 | 1DEB922308733DC00010E9CD /* Debug */ = { 335 | isa = XCBuildConfiguration; 336 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 337 | buildSettings = { 338 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 339 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 340 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 341 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 342 | CLANG_WARN_BOOL_CONVERSION = YES; 343 | CLANG_WARN_COMMA = YES; 344 | CLANG_WARN_CONSTANT_CONVERSION = YES; 345 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 346 | CLANG_WARN_EMPTY_BODY = YES; 347 | CLANG_WARN_ENUM_CONVERSION = YES; 348 | CLANG_WARN_INFINITE_RECURSION = YES; 349 | CLANG_WARN_INT_CONVERSION = YES; 350 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 351 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 352 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 353 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 354 | CLANG_WARN_STRICT_PROTOTYPES = NO; 355 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 356 | CLANG_WARN_UNGUARDED_AVAILABILITY = NO; 357 | CLANG_WARN_UNREACHABLE_CODE = YES; 358 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 359 | CODE_SIGN_IDENTITY = "iPhone Developer"; 360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 361 | DSTROOT = /tmp/DkNappSocial.dst; 362 | ENABLE_STRICT_OBJC_MSGSEND = YES; 363 | ENABLE_TESTABILITY = YES; 364 | GCC_C_LANGUAGE_STANDARD = c99; 365 | GCC_NO_COMMON_BLOCKS = YES; 366 | GCC_OPTIMIZATION_LEVEL = 0; 367 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 368 | GCC_PREFIX_HEADER = DkNappSocial_Prefix.pch; 369 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 370 | GCC_THUMB_SUPPORT = NO; 371 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 372 | GCC_VERSION = ""; 373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 374 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 375 | GCC_WARN_MISSING_PARENTHESES = NO; 376 | GCC_WARN_SHADOW = NO; 377 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 378 | GCC_WARN_UNDECLARED_SELECTOR = YES; 379 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 380 | GCC_WARN_UNUSED_FUNCTION = YES; 381 | GCC_WARN_UNUSED_PARAMETER = NO; 382 | GCC_WARN_UNUSED_VALUE = NO; 383 | GCC_WARN_UNUSED_VARIABLE = NO; 384 | INSTALL_PATH = /usr/local/lib; 385 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 386 | MACH_O_TYPE = staticlib; 387 | ONLY_ACTIVE_ARCH = YES; 388 | OTHER_CFLAGS = ( 389 | "-DDEBUG", 390 | "-DTI_POST_1_2", 391 | ); 392 | OTHER_LDFLAGS = "-ObjC"; 393 | PRODUCT_NAME = DkNappSocial; 394 | PROVISIONING_PROFILE = ""; 395 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; 396 | PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; 397 | RUN_CLANG_STATIC_ANALYZER = NO; 398 | SDKROOT = iphoneos; 399 | USER_HEADER_SEARCH_PATHS = ""; 400 | VALID_ARCHS = "arm64 armv7 armv7s i386"; 401 | }; 402 | name = Debug; 403 | }; 404 | 1DEB922408733DC00010E9CD /* Release */ = { 405 | isa = XCBuildConfiguration; 406 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 407 | buildSettings = { 408 | ALWAYS_SEARCH_USER_PATHS = NO; 409 | "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; 410 | "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; 411 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 412 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 413 | CLANG_WARN_BOOL_CONVERSION = YES; 414 | CLANG_WARN_COMMA = YES; 415 | CLANG_WARN_CONSTANT_CONVERSION = YES; 416 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 417 | CLANG_WARN_EMPTY_BODY = YES; 418 | CLANG_WARN_ENUM_CONVERSION = YES; 419 | CLANG_WARN_INFINITE_RECURSION = YES; 420 | CLANG_WARN_INT_CONVERSION = YES; 421 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 422 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 423 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 424 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 425 | CLANG_WARN_STRICT_PROTOTYPES = NO; 426 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 427 | CLANG_WARN_UNGUARDED_AVAILABILITY = NO; 428 | CLANG_WARN_UNREACHABLE_CODE = YES; 429 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 430 | DSTROOT = /tmp/DkNappSocial.dst; 431 | ENABLE_STRICT_OBJC_MSGSEND = YES; 432 | GCC_C_LANGUAGE_STANDARD = c99; 433 | GCC_MODEL_TUNING = G5; 434 | GCC_NO_COMMON_BLOCKS = YES; 435 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 436 | GCC_PREFIX_HEADER = DkNappSocial_Prefix.pch; 437 | GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; 438 | GCC_THUMB_SUPPORT = NO; 439 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; 440 | GCC_VERSION = ""; 441 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 442 | GCC_WARN_ABOUT_RETURN_TYPE = NO; 443 | GCC_WARN_MISSING_PARENTHESES = NO; 444 | GCC_WARN_SHADOW = NO; 445 | GCC_WARN_STRICT_SELECTOR_MATCH = NO; 446 | GCC_WARN_UNDECLARED_SELECTOR = YES; 447 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 448 | GCC_WARN_UNUSED_FUNCTION = YES; 449 | GCC_WARN_UNUSED_PARAMETER = NO; 450 | GCC_WARN_UNUSED_VALUE = NO; 451 | GCC_WARN_UNUSED_VARIABLE = NO; 452 | INSTALL_PATH = /usr/local/lib; 453 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 454 | MACH_O_TYPE = staticlib; 455 | OTHER_CFLAGS = "-DTI_POST_1_2"; 456 | OTHER_LDFLAGS = "-ObjC"; 457 | PRODUCT_NAME = DkNappSocial; 458 | PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; 459 | RUN_CLANG_STATIC_ANALYZER = NO; 460 | SDKROOT = iphoneos; 461 | USER_HEADER_SEARCH_PATHS = ""; 462 | VALID_ARCHS = "arm64 armv7 armv7s i386"; 463 | }; 464 | name = Release; 465 | }; 466 | 24416B8211C4CA220047AFDD /* Debug */ = { 467 | isa = XCBuildConfiguration; 468 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 469 | buildSettings = { 470 | CLANG_ENABLE_OBJC_WEAK = YES; 471 | COPY_PHASE_STRIP = NO; 472 | GCC_DYNAMIC_NO_PIC = NO; 473 | GCC_OPTIMIZATION_LEVEL = 0; 474 | GCC_THUMB_SUPPORT = NO; 475 | PRODUCT_NAME = "Build & test"; 476 | }; 477 | name = Debug; 478 | }; 479 | 24416B8311C4CA220047AFDD /* Release */ = { 480 | isa = XCBuildConfiguration; 481 | baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; 482 | buildSettings = { 483 | CLANG_ENABLE_OBJC_WEAK = YES; 484 | COPY_PHASE_STRIP = YES; 485 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 486 | GCC_THUMB_SUPPORT = NO; 487 | PRODUCT_NAME = "Build & test"; 488 | ZERO_LINK = NO; 489 | }; 490 | name = Release; 491 | }; 492 | /* End XCBuildConfiguration section */ 493 | 494 | /* Begin XCConfigurationList section */ 495 | 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "social" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 1DEB921F08733DC00010E9CD /* Debug */, 499 | 1DEB922008733DC00010E9CD /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "social" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | 1DEB922308733DC00010E9CD /* Debug */, 508 | 1DEB922408733DC00010E9CD /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | defaultConfigurationName = Release; 512 | }; 513 | 24416B8A11C4CA520047AFDD /* Build configuration list for PBXAggregateTarget "Build & Test" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 24416B8211C4CA220047AFDD /* Debug */, 517 | 24416B8311C4CA220047AFDD /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | /* End XCConfigurationList section */ 523 | }; 524 | rootObject = 0867D690FE84028FC02AAC07 /* Project object */; 525 | } 526 | -------------------------------------------------------------------------------- /Classes/DkNappSocialModule.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Module developed by Napp CMS 3 | * Mads Møller 4 | * 5 | * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. 6 | * and licensed under the Apache Public License (version 2) 7 | */ 8 | #import "DkNappSocialModule.h" 9 | #import "NappCustomActivity.h" 10 | #import "NappImageProvider.h" 11 | #import "NappItemProvider.h" 12 | #import "TiApp.h" 13 | #import "TiBase.h" 14 | #import "TiHost.h" 15 | #import "TiUtils.h" 16 | 17 | //include Social and Accounts Frameworks 18 | #import 19 | #import 20 | 21 | #import "TiUIViewProxy.h" 22 | 23 | static NSString *const CUSTOM_ACTIVITY = @"custom_activity"; 24 | 25 | @interface DkNappSocialModule() 26 | @property (nonatomic,readwrite) NSString *ACTIVITY_CUSTOM; 27 | @end 28 | @implementation DkNappSocialModule 29 | 30 | #pragma mark Activties 31 | 32 | MAKE_SYSTEM_STR(ACTIVITY_FACEBOOK, UIActivityTypePostToFacebook); 33 | MAKE_SYSTEM_STR(ACTIVITY_TWITTER, UIActivityTypePostToTwitter); 34 | MAKE_SYSTEM_STR(ACTIVITY_WEIBO, UIActivityTypePostToWeibo); 35 | MAKE_SYSTEM_STR(ACTIVITY_MESSAGE, UIActivityTypeMessage); 36 | MAKE_SYSTEM_STR(ACTIVITY_MAIL, UIActivityTypeMail); 37 | MAKE_SYSTEM_STR(ACTIVITY_PRINT, UIActivityTypePrint); 38 | MAKE_SYSTEM_STR(ACTIVITY_COPY, UIActivityTypeCopyToPasteboard); 39 | MAKE_SYSTEM_STR(ACTIVITY_ASSIGN_CONTACT, UIActivityTypeAssignToContact); 40 | MAKE_SYSTEM_STR(ACTIVITY_SAVE_CAMERA, UIActivityTypeSaveToCameraRoll); 41 | MAKE_SYSTEM_STR(ACTIVITY_READING_LIST, UIActivityTypeAddToReadingList); 42 | MAKE_SYSTEM_STR(ACTIVITY_FLICKR, UIActivityTypePostToFlickr); 43 | MAKE_SYSTEM_STR(ACTIVITY_VIMEO, UIActivityTypePostToVimeo); 44 | MAKE_SYSTEM_STR(ACTIVITY_AIRDROP, UIActivityTypeAirDrop); 45 | MAKE_SYSTEM_STR(ACTIVITY_TENCENT_WEIBO, UIActivityTypePostToTencentWeibo); 46 | MAKE_SYSTEM_STR(ACTIVITY_OPEN_IN_IBOOKS, UIActivityTypeOpenInIBooks); 47 | 48 | // Custom 49 | MAKE_SYSTEM_STR(ACTIVITY_CUSTOM, CUSTOM_ACTIVITY); 50 | 51 | #pragma mark Internal 52 | 53 | // this is generated for your module, please do not change it 54 | - (id)moduleGUID { 55 | return @"8152d7fc-6edb-4c40-8d6f-bc2cef87bc1a"; 56 | } 57 | 58 | // this is generated for your module, please do not change it 59 | - (NSString *)moduleId { 60 | return @"dk.napp.social"; 61 | } 62 | 63 | #pragma mark Lifecycle 64 | 65 | - (void)startup { 66 | // this method is called when the module is first loaded 67 | // you *must* call the superclass 68 | [super startup]; 69 | self.ACTIVITY_CUSTOM = CUSTOM_ACTIVITY; 70 | popoverController = nil; 71 | accountStore = nil; 72 | 73 | NSLog(@"[INFO] %@ loaded", self); 74 | } 75 | 76 | #pragma mark Public APIs 77 | 78 | - (BOOL)validateUrl:(NSString *)candidate { 79 | NSString *urlRegEx = @"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+"; 80 | NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx]; 81 | return [urlTest evaluateWithObject:candidate]; 82 | } 83 | 84 | - (NSNumber *)isNetworkSupported:(NSString *)service { 85 | BOOL available = NO; 86 | if (NSClassFromString(@"SLComposeViewController")) { 87 | if ([SLComposeViewController isAvailableForServiceType:service]) { 88 | available = YES; 89 | } 90 | } 91 | return NUMBOOL(available); //This can call this to let them know if this feature is supported 92 | } 93 | 94 | - (NSNumber *)isActivitySupported { 95 | BOOL available = NO; 96 | if (NSClassFromString(@"UIActivityViewController")) { 97 | available = YES; 98 | } 99 | return NUMBOOL(available); //This can call this to let them know if this feature is supported 100 | } 101 | 102 | - (NSNumber *)isTwitterSupported:(id)args { 103 | if (NSClassFromString(@"SLComposeViewController") != nil) { 104 | return [self isNetworkSupported:SLServiceTypeTwitter]; 105 | } else if (NSClassFromString(@"TWTweetComposeViewController") != nil) { 106 | return NUMBOOL(YES); 107 | } else { 108 | return NUMBOOL(NO); 109 | } 110 | } 111 | 112 | - (NSNumber *)isRequestTwitterSupported:(id)args { //for iOS6 twitter 113 | return [TiUtils isIOSVersionOrGreater:@"6.0"] ? [self isNetworkSupported:SLServiceTypeTwitter] : NUMBOOL(NO); 114 | } 115 | 116 | - (NSNumber *)isFacebookSupported:(id)args { 117 | return [TiUtils isIOSVersionOrGreater:@"6.0"] ? [self isNetworkSupported:SLServiceTypeFacebook] : NUMBOOL(NO); 118 | } 119 | 120 | - (NSNumber *)isSinaWeiboSupported:(id)args { 121 | return [TiUtils isIOSVersionOrGreater:@"6.0"] ? [self isNetworkSupported:SLServiceTypeSinaWeibo] : NUMBOOL(NO); 122 | } 123 | 124 | - (NSNumber *)isActivityViewSupported:(id)args { 125 | return [TiUtils isIOSVersionOrGreater:@"6.0"] ? [self isActivitySupported] : NUMBOOL(NO); 126 | } 127 | 128 | - (UIImage *)findImage:(NSString *)imagePath { 129 | if (imagePath != nil) { 130 | UIImage *image = nil; 131 | 132 | // Load the image from the application assets 133 | NSString *fileNamePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:imagePath]; 134 | ; 135 | image = [UIImage imageWithContentsOfFile:fileNamePath]; 136 | if (image != nil) { 137 | return image; 138 | } 139 | 140 | //Load local image by extracting the filename without extension 141 | NSString *newImagePath = [[imagePath lastPathComponent] stringByDeletingPathExtension]; 142 | image = [UIImage imageNamed:newImagePath]; 143 | if (image != nil) { 144 | return image; 145 | } 146 | 147 | //image from URL 148 | image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imagePath]]]; 149 | if (image != nil) { 150 | return image; 151 | } 152 | 153 | //load remote image 154 | image = [UIImage imageWithContentsOfFile:imagePath]; 155 | if (image != nil) { 156 | return image; 157 | } 158 | NSLog(@"image NOT found"); 159 | } 160 | return nil; 161 | } 162 | 163 | /* 164 | * Accounts 165 | */ 166 | - (void)twitterAccountList:(id)args { 167 | if (accountStore == nil) { 168 | accountStore = [[ACAccountStore alloc] init]; 169 | } 170 | ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 171 | 172 | // request access 173 | [accountStore requestAccessToAccountsWithType:accountType 174 | options:nil 175 | completion:^(BOOL granted, NSError *error) { 176 | if (granted == YES) { 177 | NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType]; 178 | [arrayOfAccounts retain]; 179 | 180 | NSMutableArray *accounts = [[NSMutableArray alloc] init]; 181 | NSMutableDictionary *dictAccounts = [[NSMutableDictionary alloc] init]; 182 | for (NSInteger i = 0; i < [arrayOfAccounts count]; i++) { 183 | ACAccount *account = [arrayOfAccounts objectAtIndex:i]; 184 | NSString *userID = [[account valueForKey:@"properties"] valueForKey:@"user_id"]; 185 | NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: 186 | userID, @"userId", 187 | [NSString stringWithString:account.username], @"username", 188 | [NSString stringWithString:account.identifier], @"identifier", 189 | nil]; 190 | [accounts addObject:dict]; 191 | } 192 | [dictAccounts setObject:accounts forKey:@"accounts"]; 193 | [self fireEvent:@"accountList" withObject:dictAccounts]; 194 | RELEASE_TO_NIL(accounts); 195 | RELEASE_TO_NIL(arrayOfAccounts); 196 | RELEASE_TO_NIL(dictAccounts); 197 | } else { 198 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"No account", @"status", [error localizedDescription], @"message", @"twitter", @"platform", nil]; 199 | [self fireEvent:@"error" withObject:event]; 200 | } 201 | }]; 202 | } 203 | 204 | - (void)shareToNetwork:(NSString *)service args:(id)args { 205 | ENSURE_SINGLE_ARG_OR_NIL(args, NSDictionary); 206 | 207 | NSString *platform = nil; 208 | 209 | if (service == SLServiceTypeFacebook) { 210 | platform = @"facebook"; 211 | } 212 | if (service == SLServiceTypeTwitter) { 213 | platform = @"twitter"; 214 | } 215 | 216 | SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:service]; 217 | SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result) { 218 | if (result == SLComposeViewControllerResultCancelled) { 219 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", platform, @"platform", nil]; 220 | [self fireEvent:@"cancelled" withObject:event]; 221 | } else { 222 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES), @"success", platform, @"platform", nil]; 223 | [self fireEvent:@"complete" withObject:event]; 224 | } 225 | [controller dismissViewControllerAnimated:YES completion:Nil]; 226 | }; 227 | controller.completionHandler = myBlock; 228 | 229 | //get the properties from javascript 230 | NSString *shareText = [TiUtils stringValue:@"text" properties:args def:nil]; 231 | NSString *shareUrl = [TiUtils stringValue:@"url" properties:args def:nil]; 232 | 233 | //added M Hudson 22/10/14 to allow for blob support 234 | //see if we passed in a string reference to the file or a TiBlob object 235 | 236 | id TiImageObject = [args objectForKey:@"image"]; 237 | 238 | if ([TiImageObject isKindOfClass:[TiBlob class]]) { 239 | NSLog(@"[INFO] Found an image", nil); 240 | UIImage *blobImage = [(TiBlob *)TiImageObject image]; 241 | if (blobImage != nil) { 242 | NSLog(@"[INFO] blob is not null", nil); 243 | [controller addImage:blobImage]; 244 | } 245 | } else { 246 | NSLog(@"[INFO] Think it is a string", nil); 247 | NSString *shareImage = [TiUtils stringValue:@"image" properties:args def:nil]; 248 | if (shareImage != nil) { 249 | [controller addImage:[self findImage:shareImage]]; 250 | } 251 | } 252 | 253 | BOOL animated = [TiUtils boolValue:@"animated" properties:args def:YES]; 254 | 255 | if (shareText != nil) { 256 | [controller setInitialText:shareText]; 257 | } 258 | 259 | if (shareUrl != nil) { 260 | [controller addURL:[NSURL URLWithString:shareUrl]]; 261 | } 262 | 263 | [[TiApp app] showModalController:controller animated:animated]; 264 | 265 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:platform, @"platform", nil]; 266 | [self fireEvent:@"dialogOpen" withObject:event]; 267 | } 268 | 269 | /* 270 | * Facebook 271 | */ 272 | 273 | - (void)facebook:(id)args { 274 | ENSURE_UI_THREAD(facebook, args); 275 | [self shareToNetwork:SLServiceTypeFacebook args:args]; 276 | } 277 | 278 | - (void)grantFacebookPermissions:(id)args { 279 | NSDictionary *arguments = [args objectAtIndex:0]; 280 | 281 | NSArray *permissionsArray = nil; 282 | 283 | if (accountStore == nil) { 284 | accountStore = [[ACAccountStore alloc] init]; 285 | } 286 | 287 | ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; 288 | 289 | NSString *appId = [arguments objectForKey:@"appIdKey"]; 290 | NSString *permissions = [arguments objectForKey:@"permissionsKey"]; 291 | 292 | // Append permissions 293 | if (permissions != nil) { 294 | permissionsArray = [permissions componentsSeparatedByString:@","]; 295 | } 296 | 297 | NSDictionary *options = @{ 298 | ACFacebookAppIdKey : appId, 299 | ACFacebookAudienceKey : ACFacebookAudienceEveryone, 300 | ACFacebookPermissionsKey : permissionsArray ?: @[] 301 | }; 302 | 303 | // request access 304 | [accountStore requestAccessToAccountsWithType:accountType 305 | options:options 306 | completion:^(BOOL granted, NSError *error) { 307 | if (granted == YES) { 308 | NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType]; 309 | 310 | if ([arrayOfAccounts count] > 0) { 311 | ACAccount *fbAccount = [arrayOfAccounts lastObject]; 312 | 313 | // Get the access token. It could be used in other scenarios 314 | ACAccountCredential *fbCredential = [fbAccount credential]; 315 | NSString *accessToken = [fbCredential oauthToken]; 316 | 317 | NSDictionary *account = [NSDictionary dictionaryWithObjectsAndKeys: 318 | [NSString stringWithString:fbAccount.username], @"username", 319 | [NSString stringWithString:fbAccount.identifier], @"identifier", 320 | [NSString stringWithString:accessToken], @"accessToken", 321 | nil]; 322 | 323 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES), @"success", account, @"account", @"facebook", @"platform", nil]; 324 | [self fireEvent:@"facebookAccount" withObject:event]; 325 | 326 | } else { 327 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"No account", @"status", @"facebook", @"platform", nil]; 328 | [self fireEvent:@"error" withObject:event]; 329 | } 330 | } else { 331 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"Permission denied", @"status", [error localizedDescription], @"message", @"facebook", @"platform", nil]; 332 | [self fireEvent:@"error" withObject:event]; 333 | } 334 | }]; 335 | } 336 | 337 | - (void)renewFacebookAccessToken:(id)args { 338 | if (accountStore == nil) { 339 | accountStore = [[ACAccountStore alloc] init]; 340 | } 341 | ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; 342 | NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType]; 343 | if ([arrayOfAccounts count] > 0) { 344 | ACAccount *fbAccount = [arrayOfAccounts lastObject]; 345 | [accountStore renewCredentialsForAccount:fbAccount 346 | completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) { 347 | if (error) { 348 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"renew failed", @"status", [error localizedDescription], @"message", @"facebook", @"platform", nil]; 349 | [self fireEvent:@"error" withObject:event]; 350 | } else { 351 | ACAccountCredential *fbCredential = [fbAccount credential]; 352 | NSString *accessToken = [fbCredential oauthToken]; 353 | NSDictionary *account = [NSDictionary dictionaryWithObjectsAndKeys: 354 | [NSString stringWithString:fbAccount.username], @"username", 355 | [NSString stringWithString:fbAccount.identifier], @"identifier", 356 | [NSString stringWithString:accessToken], @"accessToken", 357 | nil]; 358 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES), @"success", account, @"account", @"facebook", @"platform", nil]; 359 | [self fireEvent:@"facebookAccount" withObject:event]; 360 | } 361 | }]; 362 | } else { 363 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"No account", @"status", @"facebook", @"platform", nil]; 364 | [self fireEvent:@"error" withObject:event]; 365 | } 366 | } 367 | 368 | - (void)requestFacebookWithIdentifier:(id)args { 369 | NSDictionary *arguments = [args objectAtIndex:0]; 370 | 371 | // Defaults 372 | NSDictionary *requestParameter = nil; 373 | NSArray *permissionsArray = nil; 374 | 375 | if ([args count] > 1) { 376 | requestParameter = [args objectAtIndex:1]; 377 | } 378 | 379 | NSString *selectedAccount = [TiUtils stringValue:@"accountWithIdentifier" properties:arguments def:nil]; 380 | NSString *callbackEventName = [TiUtils stringValue:@"callbackEvent" properties:arguments def:@"facebookRequest"]; 381 | 382 | if (selectedAccount != nil) { 383 | //requestType: GET, POST, DELETE 384 | NSInteger facebookRequestMethod = SLRequestMethodPOST; 385 | NSString *requestType = [[TiUtils stringValue:@"requestType" properties:arguments def:@"POST"] uppercaseString]; 386 | 387 | if ([requestType isEqualToString:@"POST"]) { 388 | facebookRequestMethod = SLRequestMethodPOST; 389 | } else if ([requestType isEqualToString:@"GET"]) { 390 | facebookRequestMethod = SLRequestMethodGET; 391 | } else if ([requestType isEqualToString:@"DELETE"]) { 392 | facebookRequestMethod = SLRequestMethodDELETE; 393 | } else { 394 | NSLog(@"[Social] no valid request method found - using POST"); 395 | } 396 | 397 | //args 398 | NSString *requestURL = [arguments objectForKey:@"url"]; 399 | 400 | if (requestURL != nil) { 401 | SLRequest *fbRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:facebookRequestMethod URL:[NSURL URLWithString:requestURL] parameters:requestParameter]; 402 | [fbRequest setAccount:[accountStore accountWithIdentifier:selectedAccount]]; 403 | [fbRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 404 | NSNumber *isSuccess; 405 | 406 | if ([urlResponse statusCode] == 200) { 407 | isSuccess = NUMBOOL(YES); 408 | } else { 409 | isSuccess = NUMBOOL(NO); 410 | } 411 | 412 | NSArray *response = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error]; 413 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:isSuccess, @"success", response, @"response", @"facebook", @"platform", nil]; 414 | [self fireEvent:callbackEventName withObject:event]; 415 | }]; 416 | 417 | } else { 418 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"Missing arguments", @"status", @"facebook", @"platform", nil]; 419 | [self fireEvent:@"error" withObject:event]; 420 | } 421 | 422 | } else { 423 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"Missing arguments", @"status", @"facebook", @"platform", nil]; 424 | [self fireEvent:@"error" withObject:event]; 425 | } 426 | } 427 | 428 | - (void)requestFacebook:(id)args { 429 | NSDictionary *arguments = [args objectAtIndex:0]; 430 | 431 | // Defaults 432 | NSDictionary *requestParameter = nil; 433 | NSArray *permissionsArray = nil; 434 | 435 | if ([args count] > 1) { 436 | requestParameter = [args objectAtIndex:1]; 437 | } 438 | 439 | if (accountStore == nil) { 440 | accountStore = [[ACAccountStore alloc] init]; 441 | } 442 | 443 | ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; 444 | 445 | NSString *appId = [arguments objectForKey:@"appIdKey"]; 446 | NSString *permissions = [arguments objectForKey:@"permissionsKey"]; 447 | NSString *callbackEventName = [TiUtils stringValue:@"callbackEvent" properties:arguments def:@"facebookRequest"]; 448 | 449 | // Append permissions 450 | if (permissions != nil) { 451 | permissionsArray = [permissions componentsSeparatedByString:@","]; 452 | } 453 | 454 | NSDictionary *options = @{ 455 | ACFacebookAppIdKey : appId, 456 | ACFacebookAudienceKey : ACFacebookAudienceEveryone, 457 | ACFacebookPermissionsKey : permissionsArray ?: @[] 458 | }; 459 | 460 | [accountStore requestAccessToAccountsWithType:accountType 461 | options:options 462 | completion:^(BOOL granted, NSError *error) { 463 | if (granted) { 464 | NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType]; 465 | 466 | if ([arrayOfAccounts count] > 0) { 467 | ACAccount *fbAccount = [arrayOfAccounts lastObject]; 468 | 469 | // Get the access token. It could be used in other scenarios 470 | ACAccountCredential *fbCredential = [fbAccount credential]; 471 | NSString *accessToken = [fbCredential oauthToken]; 472 | 473 | //requestType: GET, POST, DELETE 474 | NSInteger facebookRequestMethod = SLRequestMethodPOST; 475 | NSString *requestType = [[TiUtils stringValue:@"requestType" properties:arguments def:@"POST"] uppercaseString]; 476 | 477 | if ([requestType isEqualToString:@"POST"]) { 478 | facebookRequestMethod = SLRequestMethodPOST; 479 | } else if ([requestType isEqualToString:@"GET"]) { 480 | facebookRequestMethod = SLRequestMethodGET; 481 | } else if ([requestType isEqualToString:@"DELETE"]) { 482 | facebookRequestMethod = SLRequestMethodDELETE; 483 | } else { 484 | NSLog(@"[Social] no valid request method found - using POST"); 485 | } 486 | 487 | //args 488 | NSString *requestURL = [arguments objectForKey:@"url"]; 489 | 490 | if (requestURL != nil) { 491 | 492 | SLRequest *fbRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook 493 | requestMethod:facebookRequestMethod 494 | URL:[NSURL URLWithString:requestURL] 495 | parameters:requestParameter]; 496 | 497 | [fbRequest setAccount:fbAccount]; 498 | 499 | [fbRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 500 | NSNumber *isSuccess; 501 | 502 | if ([urlResponse statusCode] == 200) { 503 | isSuccess = NUMBOOL(YES); 504 | } else { 505 | isSuccess = NUMBOOL(NO); 506 | } 507 | 508 | NSArray *response = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error]; 509 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:isSuccess, @"success", response, @"response", accessToken, @"accessToken", @"facebook", @"platform", nil]; 510 | [self fireEvent:callbackEventName withObject:event]; 511 | }]; 512 | 513 | } else { 514 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"Missing arguments", @"status", @"facebook", @"platform", nil]; 515 | [self fireEvent:@"error" withObject:event]; 516 | } 517 | } 518 | } else { 519 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"No account", @"status", [error localizedDescription], @"message", @"facebook", @"platform", nil]; 520 | [self fireEvent:@"error" withObject:event]; 521 | } 522 | }]; 523 | } 524 | 525 | /////////////////////////////////////////////////////////////////// 526 | /////////////////////////////////////////////////////////////////// 527 | // TWITTER API 528 | /////////////////////////////////////////////////////////////////// 529 | /////////////////////////////////////////////////////////////////// 530 | 531 | - (void)twitter:(id)args { 532 | ENSURE_UI_THREAD(twitter, args); 533 | 534 | if (NSClassFromString(@"SLComposeViewController") != nil) { 535 | [self shareToNetwork:SLServiceTypeTwitter args:args]; 536 | } 537 | } 538 | 539 | /** 540 | * args[0] - requestType, url, accountWithIdentifier 541 | * args[1] - requestParameter 542 | * 543 | */ 544 | - (void)requestTwitter:(id)args { 545 | NSDictionary *arguments = [args objectAtIndex:0]; 546 | 547 | // Defaults 548 | NSDictionary *requestParameter = nil; 549 | 550 | if ([args count] > 1) { 551 | requestParameter = [args objectAtIndex:1]; 552 | } 553 | 554 | if (accountStore == nil) { 555 | accountStore = [[ACAccountStore alloc] init]; 556 | } 557 | 558 | ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 559 | 560 | NSString *callbackEventName = [TiUtils stringValue:@"callbackEvent" properties:arguments def:@"twitterRequest"]; 561 | 562 | [accountStore requestAccessToAccountsWithType:accountType 563 | options:nil 564 | completion:^(BOOL granted, NSError *error) { 565 | if (granted == YES) { 566 | NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType]; 567 | 568 | if ([arrayOfAccounts count] > 0) { 569 | NSString *selectedAccount = [TiUtils stringValue:@"accountWithIdentifier" properties:arguments def:nil]; 570 | ACAccount *twitterAccount; 571 | if (selectedAccount != nil) { 572 | //user selected 573 | twitterAccount = [accountStore accountWithIdentifier:selectedAccount]; 574 | if (twitterAccount == nil) { 575 | //fallback 576 | NSLog(@"[ERROR] Account with identifier does not exist"); 577 | twitterAccount = [arrayOfAccounts lastObject]; 578 | } 579 | } else { 580 | //use last account in array 581 | twitterAccount = [arrayOfAccounts lastObject]; 582 | } 583 | 584 | //requestType: GET, POST, DELETE 585 | NSInteger requestMethod = SLRequestMethodPOST; 586 | NSString *requestType = [[TiUtils stringValue:@"requestType" properties:arguments def:@"POST"] uppercaseString]; 587 | 588 | if ([requestType isEqualToString:@"POST"]) { 589 | requestMethod = SLRequestMethodPOST; 590 | } else if ([requestType isEqualToString:@"GET"]) { 591 | requestMethod = SLRequestMethodGET; 592 | } else if ([requestType isEqualToString:@"DELETE"]) { 593 | requestMethod = SLRequestMethodDELETE; 594 | } else { 595 | NSLog(@"[Social] no valid request method found - using POST"); 596 | } 597 | 598 | //args 599 | NSString *requestURL = [TiUtils stringValue:@"url" properties:arguments def:nil]; 600 | 601 | if (requestURL != nil) { 602 | 603 | SLRequest *twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter 604 | requestMethod:requestMethod 605 | URL:[NSURL URLWithString:requestURL] 606 | parameters:requestParameter]; 607 | [twitterRequest setAccount:twitterAccount]; 608 | [twitterRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 609 | NSNumber *isSuccess; 610 | if ([urlResponse statusCode] == 200) { 611 | isSuccess = NUMBOOL(YES); 612 | } else { 613 | isSuccess = NUMBOOL(NO); 614 | } 615 | //NSString *response = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 616 | NSArray *response = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error]; 617 | NSString *rawData = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 618 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:isSuccess, @"success", response, @"response", rawData, @"rawResponse", @"twitter", @"platform", nil]; 619 | RELEASE_TO_NIL(rawData); 620 | [self fireEvent:callbackEventName withObject:event]; 621 | }]; 622 | 623 | } else { 624 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"Missing arguments", @"status", @"twitter", @"platform", nil]; 625 | [self fireEvent:@"error" withObject:event]; 626 | } 627 | } 628 | } else { 629 | NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(NO), @"success", @"No account", @"status", [error localizedDescription], @"message", @"twitter", @"platform", nil]; 630 | [self fireEvent:@"error" withObject:event]; 631 | } 632 | }]; 633 | } 634 | 635 | /* 636 | * Sina Weibo 637 | */ 638 | 639 | - (void)sinaweibo:(id)args { 640 | ENSURE_UI_THREAD(sinaweibo, args); 641 | [self shareToNetwork:SLServiceTypeSinaWeibo args:args]; 642 | } 643 | 644 | /////////////////////////////////////////////////////////////////// 645 | /////////////////////////////////////////////////////////////////// 646 | // UIActivityViewController 647 | /////////////////////////////////////////////////////////////////// 648 | /////////////////////////////////////////////////////////////////// 649 | 650 | - (void)activityView:(id)args { 651 | ENSURE_UI_THREAD(activityView, args); 652 | 653 | NSDictionary *arguments = nil; 654 | NSArray *customActivities = nil; 655 | 656 | if ([args count] > 1) { 657 | customActivities = [args objectAtIndex:1]; 658 | arguments = [args objectAtIndex:0]; 659 | } else { 660 | arguments = [args objectAtIndex:0]; 661 | } 662 | 663 | // Get Properties from JavaScript 664 | NSString *htmlshareText = [TiUtils stringValue:@"htmlText" properties:arguments def:nil]; 665 | NSString *shareText = [TiUtils stringValue:@"text" properties:arguments def:nil]; 666 | NSURL *shareURL = [NSURL URLWithString:[TiUtils stringValue:@"url" properties:arguments def:nil]]; 667 | NSString *removeIcons = [TiUtils stringValue:@"removeIcons" properties:arguments def:nil]; 668 | 669 | // Get custom attributes 670 | NSString *twitterText = [TiUtils stringValue:@"twitterText" properties:arguments def:nil]; 671 | NSString *twitterImage = [TiUtils stringValue:@"twitterImage" properties:arguments def:nil]; 672 | NSString *facebookImage = [TiUtils stringValue:@"facebookImage" properties:arguments def:nil]; 673 | 674 | NSMutableArray *activityItems = [[NSMutableArray alloc] init]; 675 | 676 | //added M Hudson 22/10/14 to allow for blob support 677 | // Image Provider 678 | id TiImageObject = [arguments objectForKey:@"image"]; 679 | if (TiImageObject != nil) { 680 | //see if we passed in a string reference to the file or a TiBlob object 681 | if ([TiImageObject isKindOfClass:[TiBlob class]]) { 682 | 683 | UIImage *image = [(TiBlob *)TiImageObject image]; 684 | if (image) { 685 | [activityItems addObject:image]; 686 | } 687 | 688 | } else { 689 | NappImageProvider *shareImageProvider = [[NappImageProvider alloc] initWithPlaceholderItem:@""]; 690 | 691 | NSString *shareImage = [TiUtils stringValue:@"image" properties:arguments def:nil]; 692 | shareImageProvider.defaultImage = shareImage; 693 | shareImageProvider.twitterImage = shareImage; 694 | shareImageProvider.facebookImage = shareImage; 695 | 696 | if (twitterImage) { 697 | shareImageProvider.twitterImage = twitterImage; 698 | } 699 | 700 | if (facebookImage && !shareURL) { 701 | shareImageProvider.facebookImage = facebookImage; 702 | } else if (shareURL) { 703 | shareImageProvider.facebookImage = nil; 704 | } 705 | 706 | [activityItems addObject:shareImageProvider]; 707 | RELEASE_TO_NIL(shareImageProvider); 708 | } 709 | } 710 | // End Image Provider 711 | 712 | if (shareText) { 713 | NappItemProvider *textItem = [[NappItemProvider alloc] initWithPlaceholderItem:@""]; 714 | textItem.customText = shareText; 715 | textItem.customHtmlText = shareText; 716 | textItem.customTwitterText = shareText; 717 | 718 | if (htmlshareText) { 719 | textItem.customHtmlText = htmlshareText; 720 | } 721 | 722 | if (twitterText) { 723 | textItem.customTwitterText = twitterText; 724 | } 725 | 726 | [activityItems addObject:textItem]; 727 | RELEASE_TO_NIL(textItem); 728 | } 729 | 730 | if (shareURL) { 731 | [activityItems addObject:shareURL]; 732 | } 733 | 734 | UIActivityViewController *avc; 735 | 736 | // Custom Activities 737 | if (customActivities != nil) { 738 | NSMutableArray *activities = [[NSMutableArray alloc] init]; 739 | for (NSInteger i = 0; i < [customActivities count]; i++) { 740 | NSDictionary *activityDictionary = [customActivities objectAtIndex:i]; 741 | NSString *activityImage = [TiUtils stringValue:@"image" properties:activityDictionary def:nil]; 742 | NSDictionary *activityStyling = [NSDictionary dictionaryWithObjectsAndKeys: 743 | [TiUtils stringValue:@"type" 744 | properties:activityDictionary 745 | def:@""], 746 | @"type", 747 | [TiUtils stringValue:@"title" 748 | properties:activityDictionary 749 | def:@""], 750 | @"title", 751 | [self findImage:activityImage], @"image", 752 | self, @"module", 753 | [activityDictionary objectForKey:@"callback"], @"callback", 754 | nil]; 755 | 756 | NappCustomActivity *nappActivity = [[NappCustomActivity alloc] initWithSettings:activityStyling]; 757 | [activities addObject:nappActivity]; 758 | RELEASE_TO_NIL(nappActivity); 759 | } 760 | 761 | avc = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:activities]; 762 | RELEASE_TO_NIL(activities); 763 | } else { 764 | avc = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil]; 765 | } 766 | 767 | RELEASE_TO_NIL(activityItems); 768 | 769 | NSString *subject = [TiUtils stringValue:@"subject" properties:arguments def:nil]; 770 | if (subject) { 771 | [avc setValue:subject forKey:@"subject"]; 772 | } 773 | 774 | // Custom Icons 775 | if (removeIcons != nil) { 776 | NSMutableArray *excludedIcons = [self activityIcons:removeIcons]; 777 | [avc setExcludedActivityTypes:excludedIcons]; 778 | } 779 | 780 | // Completion Block Handler 781 | [avc setCompletionWithItemsHandler:^(UIActivityType _Nullable activityType, BOOL completed, NSArray *_Nullable returnedItems, NSError *_Nullable activityError) { 782 | if (!completed) { 783 | NSDictionary *event = @{ 784 | @"success" : @NO, 785 | @"platform" : @"activityView" 786 | }; 787 | [self fireEvent:@"cancelled" withObject:event]; 788 | } else { 789 | // RKS NOTE: Here we must verify if is a CustomActivity or not 790 | // to returns ACTIVITY_CUSTOM constant 791 | NSString *activity = activityType; 792 | if ([activityType rangeOfString:@"com.apple.UIKit.activity"].location == NSNotFound) { 793 | activity = [self ACTIVITY_CUSTOM]; 794 | } 795 | 796 | NSDictionary *event = @{ 797 | @"success" : @YES, 798 | @"platform" : @"activityView", 799 | @"activity" : activity, 800 | @"activityName" : activityType 801 | }; 802 | [self fireEvent:@"complete" withObject:event]; 803 | } 804 | }]; 805 | 806 | // Show ActivityViewController 807 | [[TiApp app] showModalController:avc animated:YES]; 808 | } 809 | 810 | - (void)activityPopover:(id)args { 811 | if (![TiUtils isIPad]) { 812 | NSLog(@"[ERROR] activityPopover is an iPad Only feature"); 813 | return; 814 | } 815 | 816 | ENSURE_UI_THREAD(activityPopover, args); 817 | 818 | NSDictionary *arguments = nil; 819 | NSArray *customActivities = nil; 820 | if ([args count] > 1) { 821 | customActivities = [args objectAtIndex:1]; 822 | arguments = [args objectAtIndex:0]; 823 | } else { 824 | arguments = [args objectAtIndex:0]; 825 | } 826 | 827 | if (popoverController.popoverVisible) { 828 | [popoverController dismissPopoverAnimated:YES]; 829 | return; 830 | } 831 | 832 | // Get Properties from JavaScript 833 | NSString *htmlshareText = [TiUtils stringValue:@"htmlText" properties:arguments def:nil]; 834 | NSString *shareText = [TiUtils stringValue:@"text" properties:arguments def:@""]; 835 | NSURL *shareURL = [NSURL URLWithString:[TiUtils stringValue:@"url" properties:arguments def:nil]]; 836 | NSString *removeIcons = [TiUtils stringValue:@"removeIcons" properties:arguments def:nil]; 837 | NSArray *passthroughViews = [arguments objectForKey:@"passthroughViews"]; 838 | 839 | BOOL emailIsHTML = [TiUtils boolValue:@"emailIsHTML" properties:arguments def:NO]; 840 | 841 | senderButton = [arguments objectForKey:@"view"]; 842 | 843 | if (senderButton == nil) { 844 | NSLog(@"[ERROR] You must specify a source button - property: view"); 845 | return; 846 | } 847 | 848 | if ([arguments objectForKey:@"rect"]) { 849 | popoverRect = [TiUtils rectValue:[arguments objectForKey:@"rect"]]; 850 | } else { 851 | popoverRect = CGRectZero; 852 | } 853 | 854 | //NSLog(@"[INFO] Button Found", nil); 855 | 856 | // CGRect rect = [TiUtils rectValue: [(TiUIViewProxy*)senderButton view]]; 857 | //NSLog(@"[INFO] Size: x: %f,y: %f, width: %f, height: %f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); 858 | 859 | NSMutableArray *activityItems = [[NSMutableArray alloc] init]; 860 | 861 | if (shareText) { 862 | if (emailIsHTML) { 863 | NappItemProvider *textItem = [[NappItemProvider alloc] initWithPlaceholderItem:@""]; 864 | textItem.customText = shareText; 865 | textItem.customHtmlText = shareText; 866 | if (htmlshareText) { 867 | textItem.customHtmlText = htmlshareText; 868 | } 869 | [activityItems addObject:textItem]; 870 | RELEASE_TO_NIL(textItem); 871 | } else { 872 | [activityItems addObject:shareText]; 873 | } 874 | } 875 | 876 | if (shareURL) { 877 | [activityItems addObject:shareURL]; 878 | } 879 | 880 | id TiImageObject = [arguments objectForKey:@"image"]; 881 | if (TiImageObject != nil) { 882 | //see if we passed in a string reference to the file or a TiBlob object 883 | if ([TiImageObject isKindOfClass:[TiBlob class]]) { 884 | 885 | UIImage *image = [(TiBlob *)TiImageObject image]; 886 | if (image) { 887 | [activityItems addObject:image]; 888 | } 889 | 890 | } else { 891 | 892 | NSString *shareImage = [TiUtils stringValue:@"image" properties:arguments def:nil]; 893 | if (shareImage != nil) { 894 | UIImage *image = [self findImage:shareImage]; 895 | if (image) { 896 | [activityItems addObject:image]; 897 | } 898 | } 899 | } 900 | } 901 | 902 | NSMutableArray *activities = [NSMutableArray array]; 903 | 904 | // Custom Activities 905 | if (customActivities != nil) { 906 | for (NSInteger i = 0; i < [customActivities count]; i++) { 907 | NSDictionary *activityDictionary = [customActivities objectAtIndex:i]; 908 | NSString *activityImage = [TiUtils stringValue:@"image" properties:activityDictionary def:nil]; 909 | NSDictionary *activityStyling = [NSDictionary dictionaryWithObjectsAndKeys: 910 | [TiUtils stringValue:@"type" 911 | properties:activityDictionary 912 | def:@""], 913 | @"type", 914 | [TiUtils stringValue:@"title" 915 | properties:activityDictionary 916 | def:@""], 917 | @"title", 918 | [self findImage:activityImage], @"image", 919 | [activityDictionary objectForKey:@"callback"], @"callback", 920 | self, @"module", 921 | nil]; 922 | 923 | NappCustomActivity *nappActivity = [[NappCustomActivity alloc] initWithSettings:activityStyling]; 924 | [activities addObject:nappActivity]; 925 | RELEASE_TO_NIL(nappActivity); 926 | } 927 | } 928 | 929 | UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:activities]; 930 | RELEASE_TO_NIL(activityItems); 931 | 932 | NSString *subject = [TiUtils stringValue:@"subject" properties:arguments def:nil]; 933 | if (subject) { 934 | [avc setValue:subject forKey:@"subject"]; 935 | } 936 | 937 | // Custom Icons 938 | if (removeIcons != nil) { 939 | NSMutableArray *excludedIcons = [self activityIcons:removeIcons]; 940 | [avc setExcludedActivityTypes:excludedIcons]; 941 | } 942 | 943 | // iOS 8 and later should use the item handler instead 944 | if ([TiUtils isIOSVersionOrGreater:@"8.0"]) { 945 | [avc setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { 946 | [self fireActivityEventWithActivityType:activityType completed:completed]; 947 | [avc setCompletionWithItemsHandler:nil]; 948 | }]; 949 | } else { 950 | [avc setCompletionWithItemsHandler:^(UIActivityType _Nullable activityType, BOOL completed, NSArray *_Nullable returnedItems, NSError *_Nullable activityError) { 951 | [self fireActivityEventWithActivityType:activityType completed:completed]; 952 | [avc setCompletionWithItemsHandler:nil]; 953 | }]; 954 | } 955 | 956 | // popOver 957 | popoverController = [[UIPopoverController alloc] initWithContentViewController:avc]; 958 | 959 | if (passthroughViews != nil) { 960 | [self setPassthroughViews:passthroughViews]; 961 | } 962 | 963 | TiThreadPerformOnMainThread(^{ 964 | // Button in navigation bar 965 | if ([senderButton supportsNavBarPositioning] && [senderButton isUsingBarButtonItem]) { 966 | UIBarButtonItem *item = [senderButton barButtonItem]; 967 | [popoverController presentPopoverFromBarButtonItem:item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 968 | return; 969 | 970 | // Button /View inside window 971 | } else if ([TiUtils isIOSVersionOrGreater:@"8.0"]) { 972 | 973 | // iOS 8 and later 974 | [avc setModalPresentationStyle:UIModalPresentationPopover]; 975 | 976 | viewController = [[TiViewController alloc] initWithViewProxy:senderButton]; 977 | 978 | [avc setModalPresentationStyle:UIModalPresentationPopover]; 979 | UIPopoverPresentationController *presentationController = [avc popoverPresentationController]; 980 | presentationController.permittedArrowDirections = UIPopoverArrowDirectionAny; 981 | presentationController.delegate = self; 982 | 983 | [[TiApp app] showModalController:avc animated:YES]; 984 | 985 | } else { 986 | 987 | // iOS 7 and earlier 988 | UIView *sourceView = [senderButton view]; 989 | [popoverController presentPopoverFromRect:sourceView.frame inView:[[[TiApp controller] topPresentedController] view] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 990 | } 991 | }, 992 | YES); 993 | } 994 | 995 | - (void)setPassthroughViews:(id)args { 996 | NSMutableArray *views = [NSMutableArray arrayWithCapacity:[args count]]; 997 | for (TiViewProxy *proxy in args) { 998 | if (![proxy isKindOfClass:[TiViewProxy class]]) { 999 | [self throwException:[NSString stringWithFormat:@"Passed non-view object %@ as passthrough view", proxy] subreason:nil location:CODELOCATION]; 1000 | } 1001 | [views addObject:[proxy view]]; 1002 | } 1003 | [popoverController setPassthroughViews:views]; 1004 | } 1005 | 1006 | - (NSMutableArray *)activityIcons:(NSString *)removeIcons { 1007 | NSMutableDictionary *iconMapping = [[NSMutableDictionary alloc] initWithObjectsAndKeys: 1008 | UIActivityTypePostToTwitter, @"twitter", 1009 | UIActivityTypePostToFacebook, @"facebook", 1010 | UIActivityTypeMail, @"mail", 1011 | UIActivityTypeMessage, @"sms", 1012 | UIActivityTypeCopyToPasteboard, @"copy", 1013 | UIActivityTypeAssignToContact, @"contact", 1014 | UIActivityTypePostToWeibo, @"weibo", 1015 | UIActivityTypePrint, @"print", 1016 | UIActivityTypeSaveToCameraRoll, @"camera", 1017 | UIActivityTypeAddToReadingList, @"readinglist", 1018 | UIActivityTypePostToFlickr, @"flickr", 1019 | UIActivityTypePostToVimeo, @"vimeo", 1020 | UIActivityTypePostToTencentWeibo, @"tencentweibo", 1021 | UIActivityTypeAirDrop, @"airdrop", 1022 | UIActivityTypeOpenInIBooks, @"ibooks", 1023 | nil]; 1024 | 1025 | if ([TiUtils isIOSVersionOrGreater:@"11.0"]) { 1026 | iconMapping[@"pdf"] = UIActivityTypeMarkupAsPDF; 1027 | } 1028 | 1029 | NSArray *icons = [removeIcons componentsSeparatedByString:@","]; 1030 | NSMutableArray *excludedIcons = [[NSMutableArray alloc] init]; 1031 | 1032 | for (NSInteger i = 0; i < [icons count]; i++) { 1033 | NSString *str = [icons objectAtIndex:i]; 1034 | [excludedIcons addObject:[iconMapping objectForKey:str]]; 1035 | } 1036 | 1037 | RELEASE_TO_NIL(iconMapping); 1038 | 1039 | return [excludedIcons autorelease]; 1040 | } 1041 | 1042 | #pragma mark Helper 1043 | 1044 | - (void)fireActivityEventWithActivityType:(NSString *)activityName completed:(BOOL)completed { 1045 | if (completed == NO) { 1046 | NSDictionary *event = @{ 1047 | @"success" : NUMBOOL(NO), 1048 | @"platform" : @"activityPopover", 1049 | }; 1050 | [self fireEvent:@"cancelled" withObject:event]; 1051 | } else { 1052 | // Here we must verify if is a CustomActivity or not 1053 | // to returns ACTIVITY_CUSTOM constant 1054 | NSString *activity = activityName; 1055 | if ([activityName rangeOfString:@"com.apple.UIKit.activity"].location == NSNotFound) { 1056 | activity = [self ACTIVITY_CUSTOM]; 1057 | } 1058 | 1059 | NSDictionary *event = @{ 1060 | @"success" : NUMBOOL(YES), 1061 | @"platform" : @"activityPopover", 1062 | @"activity" : activity, 1063 | @"activityName" : activityName 1064 | }; 1065 | 1066 | [self fireEvent:@"complete" withObject:event]; 1067 | } 1068 | } 1069 | 1070 | - (NSString *)ACTIVITY_MARKUP_AS_PDF { 1071 | if (![TiUtils isIOSVersionOrGreater:@"11.0"]) { 1072 | return nil; 1073 | } 1074 | 1075 | return UIActivityTypeMarkupAsPDF; 1076 | } 1077 | 1078 | #pragma mark - UIPopoverPresentationController Delegate 1079 | 1080 | - (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController { 1081 | NSLog(@"[INFO] prepareForPopoverPresentation"); 1082 | 1083 | if (senderButton != nil) { 1084 | UIView *view = [senderButton view]; 1085 | 1086 | if (view != nil && (view.window != nil)) { 1087 | 1088 | popoverPresentationController.sourceView = view; 1089 | popoverPresentationController.sourceRect = (CGRectEqualToRect(CGRectZero, popoverRect) ? [view bounds] : popoverRect); 1090 | return; 1091 | } 1092 | } 1093 | 1094 | //Fell through. 1095 | UIViewController *presentingController = [viewController presentingViewController]; 1096 | popoverPresentationController.sourceView = [presentingController view]; 1097 | popoverPresentationController.sourceRect = (CGRectEqualToRect(CGRectZero, popoverRect) ? CGRectMake(presentingController.view.bounds.size.width / 2, presentingController.view.bounds.size.height / 2, 1, 1) : popoverRect); 1098 | } 1099 | 1100 | - (void)popoverPresentationController:(UIPopoverPresentationController *)popoverPresentationController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView **)view { 1101 | NSLog(@"[INFO] popoverPresentationController:willRepositionPopoverToRect"); 1102 | } 1103 | 1104 | - (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController { 1105 | NSLog(@"[INFO] popoverPresentationControllerDidDismissPopover"); 1106 | } 1107 | 1108 | @end 1109 | --------------------------------------------------------------------------------