diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..96a9dfb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +#CocoaPods +Pods/ +Podfile.lock + +#Xcode +Build/ +xcuserdata/ +*.xcworkspace + +#OSX +.DS_Store diff --git a/README.md b/README.md index b3f9ec01..771180a9 100755 --- a/README.md +++ b/README.md @@ -21,6 +21,17 @@ Add the Intercom pod into your Podfile and run a `pod install` or `pod update`. If you get errors, check out our [Troubleshooting section here](http://docs.intercom.io/Install-on-your-mobile-product/installing-intercom-for-ios#troubleshooting-tips). +##Sample app + +To use the sample app: + +1. Go to the `Sample` directory and run `pod install`. +2. Set your iOS API key and App ID at the top of `ITCAppDelegate.m`, here: +``` +#define INTERCOM_APP_ID @"YOUR_APP_ID" +#define INTERCOM_API_KEY @"YOUR_API_KEY" +``` +3. Build and run. ##How should I use Intercom for iOS in my app? Broadly speaking, there are three types of apps that Intercom for iOS will work in. diff --git a/Sample/Podfile b/Sample/Podfile new file mode 100644 index 00000000..65718a7c --- /dev/null +++ b/Sample/Podfile @@ -0,0 +1,3 @@ +source 'https://github.com/CocoaPods/Specs.git' + +pod 'Intercom' \ No newline at end of file diff --git a/Sample/Sample.xcodeproj/project.pbxproj b/Sample/Sample.xcodeproj/project.pbxproj new file mode 100644 index 00000000..3d3e4f51 --- /dev/null +++ b/Sample/Sample.xcodeproj/project.pbxproj @@ -0,0 +1,357 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1A0F1E0E1B034B7100DA78D2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F1E0D1B034B7100DA78D2 /* main.m */; }; + 1A0F1E111B034B7100DA78D2 /* ITCAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F1E101B034B7100DA78D2 /* ITCAppDelegate.m */; }; + 1A0F1E141B034B7100DA78D2 /* ITCViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A0F1E131B034B7100DA78D2 /* ITCViewController.m */; }; + 1A0F1E171B034B7100DA78D2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1A0F1E151B034B7100DA78D2 /* Main.storyboard */; }; + 1A0F1E191B034B7100DA78D2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A0F1E181B034B7100DA78D2 /* Images.xcassets */; }; + 41B7C7F5B6A2B7BBFB150C42 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 98C43708C680E2477FAD146C /* libPods.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 1A0F1E081B034B7100DA78D2 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A0F1E0C1B034B7100DA78D2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 1A0F1E0D1B034B7100DA78D2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 1A0F1E0F1B034B7100DA78D2 /* ITCAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ITCAppDelegate.h; sourceTree = ""; }; + 1A0F1E101B034B7100DA78D2 /* ITCAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ITCAppDelegate.m; sourceTree = ""; }; + 1A0F1E121B034B7100DA78D2 /* ITCViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ITCViewController.h; sourceTree = ""; }; + 1A0F1E131B034B7100DA78D2 /* ITCViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ITCViewController.m; sourceTree = ""; }; + 1A0F1E161B034B7100DA78D2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 1A0F1E181B034B7100DA78D2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 85430A3E591C9A403636B060 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + 8C6C505514D1683341C821E8 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + 98C43708C680E2477FAD146C /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1A0F1E051B034B7100DA78D2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 41B7C7F5B6A2B7BBFB150C42 /* libPods.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1A0F1DFF1B034B7100DA78D2 = { + isa = PBXGroup; + children = ( + 1A0F1E0A1B034B7100DA78D2 /* Sample */, + 1A0F1E091B034B7100DA78D2 /* Products */, + 99A634D8FD9561D82582548A /* Pods */, + D34511F59F27AF5F3DE9174F /* Frameworks */, + ); + sourceTree = ""; + }; + 1A0F1E091B034B7100DA78D2 /* Products */ = { + isa = PBXGroup; + children = ( + 1A0F1E081B034B7100DA78D2 /* Sample.app */, + ); + name = Products; + sourceTree = ""; + }; + 1A0F1E0A1B034B7100DA78D2 /* Sample */ = { + isa = PBXGroup; + children = ( + 1A0F1E0F1B034B7100DA78D2 /* ITCAppDelegate.h */, + 1A0F1E101B034B7100DA78D2 /* ITCAppDelegate.m */, + 1A0F1E121B034B7100DA78D2 /* ITCViewController.h */, + 1A0F1E131B034B7100DA78D2 /* ITCViewController.m */, + 1A0F1E151B034B7100DA78D2 /* Main.storyboard */, + 1A0F1E181B034B7100DA78D2 /* Images.xcassets */, + 1A0F1E0B1B034B7100DA78D2 /* Supporting Files */, + ); + path = Sample; + sourceTree = ""; + }; + 1A0F1E0B1B034B7100DA78D2 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 1A0F1E0C1B034B7100DA78D2 /* Info.plist */, + 1A0F1E0D1B034B7100DA78D2 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 99A634D8FD9561D82582548A /* Pods */ = { + isa = PBXGroup; + children = ( + 85430A3E591C9A403636B060 /* Pods.debug.xcconfig */, + 8C6C505514D1683341C821E8 /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + D34511F59F27AF5F3DE9174F /* Frameworks */ = { + isa = PBXGroup; + children = ( + 98C43708C680E2477FAD146C /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1A0F1E071B034B7100DA78D2 /* Sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1A0F1E2B1B034B7100DA78D2 /* Build configuration list for PBXNativeTarget "Sample" */; + buildPhases = ( + 9EFCFC36D71F6292341B4961 /* Check Pods Manifest.lock */, + 1A0F1E041B034B7100DA78D2 /* Sources */, + 1A0F1E051B034B7100DA78D2 /* Frameworks */, + 1A0F1E061B034B7100DA78D2 /* Resources */, + C013679E94F860BABB90640E /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Sample; + productName = Sample; + productReference = 1A0F1E081B034B7100DA78D2 /* Sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1A0F1E001B034B7100DA78D2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = Intercom; + TargetAttributes = { + 1A0F1E071B034B7100DA78D2 = { + CreatedOnToolsVersion = 6.3.1; + }; + }; + }; + buildConfigurationList = 1A0F1E031B034B7100DA78D2 /* Build configuration list for PBXProject "Sample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 1A0F1DFF1B034B7100DA78D2; + productRefGroup = 1A0F1E091B034B7100DA78D2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1A0F1E071B034B7100DA78D2 /* Sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1A0F1E061B034B7100DA78D2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A0F1E171B034B7100DA78D2 /* Main.storyboard in Resources */, + 1A0F1E191B034B7100DA78D2 /* Images.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 9EFCFC36D71F6292341B4961 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + C013679E94F860BABB90640E /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1A0F1E041B034B7100DA78D2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A0F1E141B034B7100DA78D2 /* ITCViewController.m in Sources */, + 1A0F1E111B034B7100DA78D2 /* ITCAppDelegate.m in Sources */, + 1A0F1E0E1B034B7100DA78D2 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 1A0F1E151B034B7100DA78D2 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1A0F1E161B034B7100DA78D2 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1A0F1E291B034B7100DA78D2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 1A0F1E2A1B034B7100DA78D2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 1A0F1E2C1B034B7100DA78D2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 85430A3E591C9A403636B060 /* Pods.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = Sample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 1A0F1E2D1B034B7100DA78D2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 8C6C505514D1683341C821E8 /* Pods.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = Sample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1A0F1E031B034B7100DA78D2 /* Build configuration list for PBXProject "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1A0F1E291B034B7100DA78D2 /* Debug */, + 1A0F1E2A1B034B7100DA78D2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1A0F1E2B1B034B7100DA78D2 /* Build configuration list for PBXNativeTarget "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1A0F1E2C1B034B7100DA78D2 /* Debug */, + 1A0F1E2D1B034B7100DA78D2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1A0F1E001B034B7100DA78D2 /* Project object */; +} diff --git a/Sample/Sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Sample/Sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..a80c0382 --- /dev/null +++ b/Sample/Sample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Sample/Sample/Base.lproj/Main.storyboard b/Sample/Sample/Base.lproj/Main.storyboard new file mode 100644 index 00000000..5cb0b2f3 --- /dev/null +++ b/Sample/Sample/Base.lproj/Main.storyboard @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sample/Sample/ITCAppDelegate.h b/Sample/Sample/ITCAppDelegate.h new file mode 100644 index 00000000..dea26d3d --- /dev/null +++ b/Sample/Sample/ITCAppDelegate.h @@ -0,0 +1,17 @@ +// +// ITCAppDelegate.h +// Sample +// +// Created by James Treanor on 13/05/2015. +// Copyright (c) 2015 Intercom. All rights reserved. +// + +#import + +@interface ITCAppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/Sample/Sample/ITCAppDelegate.m b/Sample/Sample/ITCAppDelegate.m new file mode 100644 index 00000000..cc8c0411 --- /dev/null +++ b/Sample/Sample/ITCAppDelegate.m @@ -0,0 +1,57 @@ +// +// ITCAppDelegate.m +// Sample +// +// Created by James Treanor on 13/05/2015. +// Copyright (c) 2015 Intercom. All rights reserved. +// + +#import "ITCAppDelegate.h" +#import "ITCViewController.h" +#import + +/*! + To try out the sample, change these values to your own iOS API key and App ID. + */ +#define INTERCOM_APP_ID @"<#YOUR APP ID#>" +#define INTERCOM_API_KEY @"<#YOUR API KEY#>" + +@implementation ITCAppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [Intercom setApiKey:INTERCOM_API_KEY forAppId:INTERCOM_APP_ID]; + + #ifdef DEBUG + [Intercom enableLogging]; + #endif + + NSString *email = [[NSUserDefaults standardUserDefaults] objectForKey:@"email"]; + if (email.length > 0) { //There is a user logged in + [Intercom registerUserWithEmail:email]; + } + + return YES; +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + //Register for push notifications + //For more info, see: http://docs.intercom.io/Install-on-your-mobile-product/enabling-push-notifications-with-intercom-for-ios + if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]){ // iOS 8 (User notifications) + [application registerUserNotificationSettings:[UIUserNotificationSettings + settingsForTypes:(UIUserNotificationTypeBadge + | UIUserNotificationTypeSound + | UIUserNotificationTypeAlert) + categories:nil]]; + [application registerForRemoteNotifications]; + } else { // iOS 7 (Remote notifications) + [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge + | UIRemoteNotificationTypeSound + | UIRemoteNotificationTypeAlert]; + } +} + +- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { + [Intercom setDeviceToken:deviceToken]; +} + +@end diff --git a/Sample/Sample/ITCViewController.h b/Sample/Sample/ITCViewController.h new file mode 100644 index 00000000..aca302b9 --- /dev/null +++ b/Sample/Sample/ITCViewController.h @@ -0,0 +1,14 @@ +// +// ITCViewController.h +// Sample +// +// Created by James Treanor on 13/05/2015. +// Copyright (c) 2015 Intercom. All rights reserved. +// + +#import + +@interface ITCViewController : UIViewController + +@end + diff --git a/Sample/Sample/ITCViewController.m b/Sample/Sample/ITCViewController.m new file mode 100644 index 00000000..72aa4ae5 --- /dev/null +++ b/Sample/Sample/ITCViewController.m @@ -0,0 +1,85 @@ +// +// ITCViewController.m +// Sample +// +// Created by James Treanor on 13/05/2015. +// Copyright (c) 2015 Intercom. All rights reserved. +// + +#import "ITCViewController.h" +#import + +@interface ITCViewController () + +@property (nonatomic, weak) IBOutlet UIButton *logoutButton; +@property (nonatomic, weak) IBOutlet UIButton *loginButton; +@property (nonatomic, weak) IBOutlet UIButton *sendMessageButton; +@property (nonatomic, assign) BOOL loggedIn; + +@end + +@implementation ITCViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.loggedIn = [[NSUserDefaults standardUserDefaults] objectForKey:@"email"] != nil; +} + +- (void)setLoggedIn:(BOOL)loggedIn { + _loggedIn = loggedIn; + + self.loginButton.enabled = !loggedIn; + self.logoutButton.enabled = loggedIn; + self.sendMessageButton.enabled = loggedIn; +} + +- (IBAction)loginPressed:(id)sender { + //The user is not logged in, so prompt for their email address + UIAlertView *loginAlert = [[UIAlertView alloc] initWithTitle:@"User Login" + message:@"Type in an email address" + delegate:self + cancelButtonTitle:@"Cancel" + otherButtonTitles:@"Login", nil]; + loginAlert.alertViewStyle = UIAlertViewStylePlainTextInput; + [loginAlert show]; +} + +- (IBAction)logoutPressed:(id)sender { + //Logout was pressed, so calling [Intercom reset] will log remove all local user data and stop tracking them. + [Intercom reset]; + + //Save email so we know the user is logged in + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"email"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + + self.loggedIn = NO; +} + +- (IBAction)openIntercomPressed:(id)sender { + //If your Intercom plan includes inbound messaging, this will show the message composer. Otherwise the message list will be shown. + [Intercom presentMessageComposer]; +} + +#pragma mark - UIAlertViewDelegate + +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { + if (buttonIndex == 0) { //Cancel button + return; + } + + //The user pressed login, if they gave us an email, log them in. + NSString *email = [alertView textFieldAtIndex:0].text; + if (email.length > 0) { + //Start tracking the user with Intercom + [Intercom registerUserWithEmail:email]; + + //Save email so we know the user is logged in + [[NSUserDefaults standardUserDefaults] setObject:email forKey:@"email"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + + self.loggedIn = YES; + } +} + +@end diff --git a/Sample/Sample/Images.xcassets/AppIcon.appiconset/Contents.json b/Sample/Sample/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d43f4ae1 --- /dev/null +++ b/Sample/Sample/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,44 @@ +{ + "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "intercomicon58.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "intercomicon87.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "intercomicon80.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "intercomicon120-1.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "intercomicon120.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "intercomicon180.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon120-1.png b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon120-1.png new file mode 100644 index 00000000..ac77a386 Binary files /dev/null and b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon120-1.png differ diff --git a/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon120.png b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon120.png new file mode 100644 index 00000000..ac77a386 Binary files /dev/null and b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon120.png differ diff --git a/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon180.png b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon180.png new file mode 100644 index 00000000..0c1ed6f0 Binary files /dev/null and b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon180.png differ diff --git a/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon58.png b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon58.png new file mode 100644 index 00000000..d7805e24 Binary files /dev/null and b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon58.png differ diff --git a/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon80.png b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon80.png new file mode 100644 index 00000000..3f544cc5 Binary files /dev/null and b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon80.png differ diff --git a/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon87.png b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon87.png new file mode 100644 index 00000000..381ed297 Binary files /dev/null and b/Sample/Sample/Images.xcassets/AppIcon.appiconset/intercomicon87.png differ diff --git a/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Contents.json b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 00000000..5b72f0d9 --- /dev/null +++ b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,50 @@ +{ + "images" : [ + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "736h", + "filename" : "launch55.png", + "minimum-system-version" : "8.0", + "orientation" : "portrait", + "scale" : "3x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "667h", + "filename" : "launch47.png", + "minimum-system-version" : "8.0", + "orientation" : "portrait", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "filename" : "Splash.png", + "scale" : "2x" + }, + { + "extent" : "full-screen", + "idiom" : "iphone", + "subtype" : "retina4", + "filename" : "Default@2x.png", + "minimum-system-version" : "7.0", + "orientation" : "portrait", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "filename" : "Splash-1.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Default@2x.png b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Default@2x.png new file mode 100644 index 00000000..0dcd92e9 Binary files /dev/null and b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Default@2x.png differ diff --git a/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Splash-1.png b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Splash-1.png new file mode 100644 index 00000000..36dc7d94 Binary files /dev/null and b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Splash-1.png differ diff --git a/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Splash.png b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Splash.png new file mode 100644 index 00000000..2307771f Binary files /dev/null and b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/Splash.png differ diff --git a/Sample/Sample/Images.xcassets/LaunchImage.launchimage/launch47.png b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/launch47.png new file mode 100644 index 00000000..623fb4cb Binary files /dev/null and b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/launch47.png differ diff --git a/Sample/Sample/Images.xcassets/LaunchImage.launchimage/launch55.png b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/launch55.png new file mode 100644 index 00000000..0b746a78 Binary files /dev/null and b/Sample/Sample/Images.xcassets/LaunchImage.launchimage/launch55.png differ diff --git a/Sample/Sample/Info.plist b/Sample/Sample/Info.plist new file mode 100644 index 00000000..33be0bd5 --- /dev/null +++ b/Sample/Sample/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + io.intercom.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Sample + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Sample/Sample/main.m b/Sample/Sample/main.m new file mode 100644 index 00000000..3c7d5b90 --- /dev/null +++ b/Sample/Sample/main.m @@ -0,0 +1,16 @@ +// +// main.m +// Sample +// +// Created by James Treanor on 13/05/2015. +// Copyright (c) 2015 Intercom. All rights reserved. +// + +#import +#import "ITCAppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([ITCAppDelegate class])); + } +}