From 244df98fe03da50f2aebb5dc3e590ce05398ae15 Mon Sep 17 00:00:00 2001 From: Anton Makarov Date: Mon, 1 Oct 2018 21:27:23 +0300 Subject: [PATCH] [NY-4041] Link up the Intercome --- Nynja.xcodeproj/project.pbxproj | 24 +++++++++++-------- Nynja/AppDelegate.swift | 7 ++++++ Nynja/HomeItemsFactory.swift | 6 ++++- .../Main/Interactor/MainInteractor.swift | 15 +++++++++++- .../Main/View/MainNavigationItem.swift | 2 +- .../MainViewController+NavigateProtocol.swift | 8 +++++++ .../Modules/Main/View/NavigateProtocol.swift | 1 + Nynja/Resources/en.lproj/Localizable.strings | 2 +- Podfile | 2 ++ Podfile.lock | 6 ++++- 10 files changed, 58 insertions(+), 15 deletions(-) diff --git a/Nynja.xcodeproj/project.pbxproj b/Nynja.xcodeproj/project.pbxproj index a41803610..8d148c5eb 100644 --- a/Nynja.xcodeproj/project.pbxproj +++ b/Nynja.xcodeproj/project.pbxproj @@ -13245,12 +13245,16 @@ "${SRCROOT}/Pods/Target Support Files/Pods-Nynja/Pods-Nynja-resources.sh", "${PODS_ROOT}/GoogleMaps/Maps/Frameworks/GoogleMaps.framework/Resources/GoogleMaps.bundle", "${PODS_ROOT}/GooglePlaces/Frameworks/GooglePlaces.framework/Resources/GooglePlaces.bundle", + "${PODS_ROOT}/Intercom/Intercom/Intercom.framework/Versions/A/Resources/Intercom.bundle", + "${PODS_ROOT}/Intercom/Intercom/Intercom.framework/Versions/A/Resources/IntercomTranslations.bundle", "${PODS_ROOT}/TestFairy/upload-dsym.sh", ); name = "[CP] Copy Pods Resources"; outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleMaps.bundle", "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GooglePlaces.bundle", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Intercom.bundle", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/IntercomTranslations.bundle", "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/upload-dsym.sh", ); runOnlyForDeploymentPostprocessing = 0; @@ -15938,8 +15942,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIconRC; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Nynja/Resources/Nynja.entitlements; - CODE_SIGN_IDENTITY = "iPhone Distribution"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; @@ -15951,9 +15955,9 @@ MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "$(BundleIdentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = "45a1afcf-be11-4391-825d-7cf40979bc47"; - PROVISIONING_PROFILE_SPECIFIER = NynjaRC_adhoc; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = RELEASE; + PROVISIONING_PROFILE = "d22f9bd2-3299-4c7a-ac33-6a12c4c3cdaa"; + PROVISIONING_PROFILE_SPECIFIER = NynjaRC_dev; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OBJC_BRIDGING_HEADER = "Nynja-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; @@ -15970,8 +15974,8 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = "Nynja-Share/Resources/Nynja-Share.entitlements"; - CODE_SIGN_IDENTITY = "iPhone Distribution"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 9GKQ5AMF2B; @@ -15983,10 +15987,10 @@ OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -DSHARE_EXTENSION"; PRODUCT_BUNDLE_IDENTIFIER = "$(ExtensionBundleIdentifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = "9b8a591a-4b46-4454-a314-16a54e890933"; - PROVISIONING_PROFILE_SPECIFIER = NynjaRC_adhocExt; + PROVISIONING_PROFILE = "1fc6c35e-7400-4bfc-8831-e2bba8e2d5e0"; + PROVISIONING_PROFILE_SPECIFIER = NynjaRC_devExt; SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = RELEASE; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/Nynja/AppDelegate.swift b/Nynja/AppDelegate.swift index 92bf7435e..6acb23d7a 100644 --- a/Nynja/AppDelegate.swift +++ b/Nynja/AppDelegate.swift @@ -15,6 +15,7 @@ import AWSCore import AWSS3 import UserNotifications import Firebase +import Intercom @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate { @@ -104,6 +105,7 @@ private extension AppDelegate { setupCrashlytics() setupGoogleMaps() setupAmazon() + setupIntercom() try? AudioSessionManager.shared.configureDefaultSession() @@ -181,4 +183,9 @@ private extension AppDelegate { AWSServiceManager.default().defaultServiceConfiguration = defaultConfiguration } + + private func setupIntercom() { + Intercom.setApiKey("ios_sdk-3f0f8a4f52e4ed08a2bf6f1a39a1e9eb8b0763d5", forAppId: "s3isdm0n") + } + } diff --git a/Nynja/HomeItemsFactory.swift b/Nynja/HomeItemsFactory.swift index e46843c23..966285952 100644 --- a/Nynja/HomeItemsFactory.swift +++ b/Nynja/HomeItemsFactory.swift @@ -26,8 +26,12 @@ class HomeItemsFactory: WCBaseItemsFactory { navigateDelegate?.call(indexPath: indexPath) }) call.subitems = [videoCall, voiceCall] + + let help = ImageActionItemModel(navItem: .help, isSelectable: false, action: { [weak navigateDelegate] (item, indexPath) in + navigateDelegate?.helpFeedBack(indexPath: indexPath) + }) - return [call, edit, myQR] + return [call, edit, myQR, help] } // MARK: - Calls diff --git a/Nynja/Modules/Main/Interactor/MainInteractor.swift b/Nynja/Modules/Main/Interactor/MainInteractor.swift index 71868b0be..0fa62886c 100644 --- a/Nynja/Modules/Main/Interactor/MainInteractor.swift +++ b/Nynja/Modules/Main/Interactor/MainInteractor.swift @@ -7,6 +7,7 @@ // import SDWebImage +import Intercom class MainInteractor: MainInteractorInputProtocol, EditPhotoDelegate, MQTTServiceDelegate { @@ -25,8 +26,9 @@ class MainInteractor: MainInteractorInputProtocol, EditPhotoDelegate, MQTTServic UIApplication.shared.registerUserNotificationSettings(notificationsSettings) UIApplication.shared.registerForRemoteNotifications() let _ = PushService.sharedInstance - + MQTTService.sharedInstance.addSubscriber(self) + setupIntercom() } func checkSession() { @@ -134,5 +136,16 @@ class MainInteractor: MainInteractorInputProtocol, EditPhotoDelegate, MQTTServic func saveLogoutState() { MQTTService.sharedInstance.state = .notAuthenticated(isLoggedOutFromServer: false) } + + private func setupIntercom() { + let rand = "\(UIDevice.current.persistentIdentifier)" + Intercom.registerUser(withUserId: rand) + guard let roster = RosterDAO.currentRoster else { return } + let userAttibutes = ICMUserAttributes() + userAttibutes.userId = roster.id != nil ? "\(roster.id!)" : rand + userAttibutes.name = roster.myContact?.fullName + userAttibutes.phone = roster.phone + Intercom.updateUser(userAttibutes) + } } diff --git a/Nynja/Modules/Main/View/MainNavigationItem.swift b/Nynja/Modules/Main/View/MainNavigationItem.swift index 48cc9a8c4..4f29d1c0a 100644 --- a/Nynja/Modules/Main/View/MainNavigationItem.swift +++ b/Nynja/Modules/Main/View/MainNavigationItem.swift @@ -45,7 +45,7 @@ enum MainNavigationItem: String { case username = "wheel_item_username" case phoneNumber = "wheel_item_changeNumber" case payment = "wheel_item_transfer" - + case help = "wheel_item_help" // Chats section case starred = "wheel_item_starred" diff --git a/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift b/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift index 8f7b0e298..da5d7374f 100644 --- a/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift +++ b/Nynja/Modules/Main/View/MainViewController+NavigateProtocol.swift @@ -8,6 +8,7 @@ import Foundation import Photos +import Intercom extension MainViewController: NavigateProtocol { @@ -205,6 +206,11 @@ extension MainViewController: NavigateProtocol { closeWheel(indexPath: indexPath) } + func helpFeedBack(indexPath: IndexPath?) { + Intercom.presentMessenger() + closeWheel(indexPath: indexPath) + } + // MARK: - Contact Actions func showListContacts(indexPath: IndexPath?) { presenter.showMyContacts() @@ -325,4 +331,6 @@ extension MainViewController: NavigateProtocol { closeWheel(indexPath: indexPath) } + + } diff --git a/Nynja/Modules/Main/View/NavigateProtocol.swift b/Nynja/Modules/Main/View/NavigateProtocol.swift index 910ae76f6..b00a29af4 100644 --- a/Nynja/Modules/Main/View/NavigateProtocol.swift +++ b/Nynja/Modules/Main/View/NavigateProtocol.swift @@ -55,6 +55,7 @@ protocol SecondLevelNavigateProtocol: class { func showMedia(indexPath: IndexPath?) func showGallery(indexPath: IndexPath?) func showRecentsMedia(indexPath: IndexPath?) + func helpFeedBack(indexPath: IndexPath?) // MARK: - Profile Actions diff --git a/Nynja/Resources/en.lproj/Localizable.strings b/Nynja/Resources/en.lproj/Localizable.strings index e812b8a34..dfcddf270 100644 --- a/Nynja/Resources/en.lproj/Localizable.strings +++ b/Nynja/Resources/en.lproj/Localizable.strings @@ -582,7 +582,7 @@ "wheel_privacy"="Privacy"; "wheel_invite_friends"="Invite Friends"; "wheel_item_transfer" = "Transfer"; - +"wheel_item_help" = "Help & Feedback"; // MARK: Main "main_undefined"="Undefined"; diff --git a/Podfile b/Podfile index b040182dc..af9cccf5e 100644 --- a/Podfile +++ b/Podfile @@ -44,6 +44,8 @@ def commonPodsForNynja pod 'CryptoSwift', '= 0.10.0' pod 'MulticastDelegateSwift', '= 2.1.1' + + pod 'Intercom', '= 5.1.6' end def commonPodsForNynjaTests diff --git a/Podfile.lock b/Podfile.lock index c8c9dad06..872ef199d 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -46,6 +46,7 @@ PODS: - GRDBCipher (2.10.0): - SQLCipher (~> 3.4.1) - GTMSessionFetcher/Core (1.1.15) + - Intercom (5.1.6) - JTAppleCalendar (7.1.5) - libPhoneNumber-iOS (0.9.13) - MaterialComponents/FlexibleHeader (55.3.0): @@ -85,6 +86,7 @@ DEPENDENCIES: - GoogleMaps (= 2.7.0) - GooglePlaces (= 2.7.0) - GRDBCipher (= 2.10.0) + - Intercom (= 5.1.6) - JTAppleCalendar (= 7.1.5) - libPhoneNumber-iOS (= 0.9.13) - MaterialComponents/FlexibleHeader (= 55.3.0) @@ -115,6 +117,7 @@ SPEC REPOS: - GoogleToolboxForMac - GRDBCipher - GTMSessionFetcher + - Intercom - JTAppleCalendar - libPhoneNumber-iOS - MaterialComponents @@ -159,6 +162,7 @@ SPEC CHECKSUMS: GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f GRDBCipher: eef21d242c727a21e0f87ad44f8ea2df03edd252 GTMSessionFetcher: 5fa5b80fd20e439ef5f545fb2cb3ca6c6714caa2 + Intercom: 083a05bf222811b0b5e0a0b24c863544123397f0 JTAppleCalendar: 2d4f974f9f3c8b4964d51ca1f6e004883c031fbe libPhoneNumber-iOS: e444379ac18bbfbdefad571da735b2cd7e096caa MaterialComponents: 915f4e844400a35db3ea4c710a9af40aa8bcb093 @@ -173,6 +177,6 @@ SPEC CHECKSUMS: SwiftyTimer: 2efd74b060d69ad4f1496baf5bbedbe132125fcf TestFairy: 842f8ddc45477b208eb85326b0418047b40f7137 -PODFILE CHECKSUM: 7e29c30b225b81fe9cd363f542473994d7969f73 +PODFILE CHECKSUM: 95f05f4ee5cc99d269461cdd9ca4184f0c839a2e COCOAPODS: 1.5.3 -- GitLab