diff --git a/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj b/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj index 38e358f..5fa46d0 100644 --- a/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj +++ b/Example/BasicExample/BasicExample.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 46EDC71327C6B8D200B870D7 /* BasicExampleUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46EDC71227C6B8D200B870D7 /* BasicExampleUITestsLaunchTests.swift */; }; 46EDC72127C6B92C00B870D7 /* Segment in Frameworks */ = {isa = PBXBuildFile; productRef = 46EDC72027C6B92C00B870D7 /* Segment */; }; 827C512828661FB5000B1B9E /* SegmentIntercom in Frameworks */ = {isa = PBXBuildFile; productRef = 827C512728661FB5000B1B9E /* SegmentIntercom */; }; + F6DAD32D2F90D3E9000AF673 /* Intercom in Frameworks */ = {isa = PBXBuildFile; productRef = F6DAD32C2F90D3E9000AF673 /* Intercom */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -54,6 +55,7 @@ buildActionMask = 2147483647; files = ( 46EDC72127C6B92C00B870D7 /* Segment in Frameworks */, + F6DAD32D2F90D3E9000AF673 /* Intercom in Frameworks */, 827C512828661FB5000B1B9E /* SegmentIntercom in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -153,11 +155,13 @@ buildRules = ( ); dependencies = ( + F66C32C82F90D5760077958F /* PBXTargetDependency */, ); name = BasicExample; packageProductDependencies = ( 46EDC72027C6B92C00B870D7 /* Segment */, 827C512728661FB5000B1B9E /* SegmentIntercom */, + F6DAD32C2F90D3E9000AF673 /* Intercom */, ); productName = BasicExample; productReference = 46EDC6F227C6B8D100B870D7 /* BasicExample.app */; @@ -207,7 +211,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1320; - LastUpgradeCheck = 1320; + LastUpgradeCheck = 1620; TargetAttributes = { 46EDC6F127C6B8D100B870D7 = { CreatedOnToolsVersion = 13.2.1; @@ -233,6 +237,7 @@ mainGroup = 46EDC6E927C6B8D100B870D7; packageReferences = ( 46EDC71F27C6B92C00B870D7 /* XCRemoteSwiftPackageReference "analytics-swift" */, + F6DAD32B2F90D293000AF673 /* XCRemoteSwiftPackageReference "intercom-ios-sp" */, ); productRefGroup = 46EDC6F327C6B8D100B870D7 /* Products */; projectDirPath = ""; @@ -311,6 +316,10 @@ target = 46EDC6F127C6B8D100B870D7 /* BasicExample */; targetProxy = 46EDC70D27C6B8D200B870D7 /* PBXContainerItemProxy */; }; + F66C32C82F90D5760077958F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + productRef = F66C32C72F90D5760077958F /* Intercom */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -351,6 +360,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -412,6 +422,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -489,7 +500,6 @@ 46EDC71A27C6B8D200B870D7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -508,7 +518,6 @@ 46EDC71B27C6B8D200B870D7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; @@ -527,7 +536,6 @@ 46EDC71D27C6B8D200B870D7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; @@ -544,7 +552,6 @@ 46EDC71E27C6B8D200B870D7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; @@ -608,6 +615,14 @@ kind = branch; }; }; + F6DAD32B2F90D293000AF673 /* XCRemoteSwiftPackageReference "intercom-ios-sp" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/intercom/intercom-ios-sp"; + requirement = { + kind = exactVersion; + version = 19.1.2; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -620,6 +635,16 @@ isa = XCSwiftPackageProductDependency; productName = SegmentIntercom; }; + F66C32C72F90D5760077958F /* Intercom */ = { + isa = XCSwiftPackageProductDependency; + package = F6DAD32B2F90D293000AF673 /* XCRemoteSwiftPackageReference "intercom-ios-sp" */; + productName = Intercom; + }; + F6DAD32C2F90D3E9000AF673 /* Intercom */ = { + isa = XCSwiftPackageProductDependency; + package = F6DAD32B2F90D293000AF673 /* XCRemoteSwiftPackageReference "intercom-ios-sp" */; + productName = Intercom; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 46EDC6EA27C6B8D100B870D7 /* Project object */; diff --git a/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved index 30040c5..d2e7581 100644 --- a/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/BasicExample/BasicExample.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,26 +6,35 @@ "repositoryURL": "https://github.com/segmentio/analytics-swift", "state": { "branch": "main", - "revision": "4c7aab453b56a80d5d2577a378bced8dc20c8f2d", + "revision": "acfd5fc1baaf78520d962884672ce1224745c5d1", "version": null } }, { "package": "Intercom", - "repositoryURL": "https://github.com/intercom/intercom-ios", + "repositoryURL": "https://github.com/intercom/intercom-ios-sp", "state": { "branch": null, - "revision": "7d1072dc39ebaf8af117b697730b6aaa834e5f48", - "version": "12.4.3" + "revision": "eda17ebd60ede445e205cfa8f880c14569dc58da", + "version": "19.1.2" + } + }, + { + "package": "JSONSafeEncoding", + "repositoryURL": "https://github.com/segmentio/jsonsafeencoding-swift.git", + "state": { + "branch": null, + "revision": "af6a8b360984085e36c6341b21ecb35c12f47ebd", + "version": "2.0.0" } }, { "package": "Sovran", - "repositoryURL": "https://github.com/segmentio/Sovran-Swift.git", + "repositoryURL": "https://github.com/segmentio/sovran-swift.git", "state": { "branch": null, - "revision": "64f3b5150c282a34af4578188dce2fd597e600e3", - "version": "1.1.0" + "revision": "24867f3e4ac62027db9827112135e6531b6f4051", + "version": "1.1.2" } } ] diff --git a/Package.resolved b/Package.resolved index 462ad3f..0131ea1 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,26 +6,35 @@ "repositoryURL": "https://github.com/segmentio/analytics-swift.git", "state": { "branch": null, - "revision": "79fb17a5d4abf8f80e6a0935e57c7df7b670a6c0", - "version": "1.4.1" + "revision": "acfd5fc1baaf78520d962884672ce1224745c5d1", + "version": "1.9.3" } }, { "package": "Intercom", - "repositoryURL": "https://github.com/intercom/intercom-ios", + "repositoryURL": "https://github.com/intercom/intercom-ios-sp", "state": { "branch": null, - "revision": "7d1072dc39ebaf8af117b697730b6aaa834e5f48", - "version": "12.4.3" + "revision": "eda17ebd60ede445e205cfa8f880c14569dc58da", + "version": "19.1.2" + } + }, + { + "package": "JSONSafeEncoding", + "repositoryURL": "https://github.com/segmentio/jsonsafeencoding-swift.git", + "state": { + "branch": null, + "revision": "af6a8b360984085e36c6341b21ecb35c12f47ebd", + "version": "2.0.0" } }, { "package": "Sovran", - "repositoryURL": "https://github.com/segmentio/Sovran-Swift.git", + "repositoryURL": "https://github.com/segmentio/sovran-swift.git", "state": { "branch": null, - "revision": "944c17d7c46bd95fc37f09136cabd172be5b413b", - "version": "1.0.3" + "revision": "24867f3e4ac62027db9827112135e6531b6f4051", + "version": "1.1.2" } } ] diff --git a/Package.swift b/Package.swift index ccbcad9..ef27eb3 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ let package = Package( name: "SegmentIntercom", platforms: [ .macOS("10.15"), - .iOS("13.0"), + .iOS("15.0"), .tvOS("11.0"), .watchOS("7.1") ], @@ -27,8 +27,8 @@ let package = Package( ), .package( name: "Intercom", - url: "https://github.com/intercom/intercom-ios", - from: "12.4.3" + url: "https://github.com/intercom/intercom-ios-sp", + from: "19.1.2" ) ], targets: [ diff --git a/Sources/SegmentIntercom/IntercomDestination.swift b/Sources/SegmentIntercom/IntercomDestination.swift index 97125ae..2fcdc80 100644 --- a/Sources/SegmentIntercom/IntercomDestination.swift +++ b/Sources/SegmentIntercom/IntercomDestination.swift @@ -1,8 +1,8 @@ // Created by Cody Garvin on 9/21/21. import Segment -import Intercom import CoreMedia +import Intercom // Copyright (c) 2022 Twilio // @@ -54,9 +54,27 @@ public class IntercomDestination: DestinationPlugin { public func identify(event: IdentifyEvent) -> IdentifyEvent? { if let userId = event.userId { - Intercom.registerUser(withUserId: userId) + let userAttributes = ICMUserAttributes() + userAttributes.userId = userId + Intercom.loginUser(with: userAttributes) { result in + switch result { + case .success: + print("Logged in") + case .failure(let error): + print("Failed: \(error.localizedDescription)") + } + } + } else if let _ = event.anonymousId { - Intercom.registerUnidentifiedUser() + + Intercom.loginUnidentifiedUser { result in + switch result { + case .success: + print("Logged in anonymously") + case .failure(let error): + print("Failed: \(error.localizedDescription)") + } + } } if let integration = event.integrations?.dictionaryValue?["Intercom"] as? [AnyHashable: Any], @@ -126,8 +144,8 @@ public class IntercomDestination: DestinationPlugin { let userAttributes = ICMUserAttributes() userAttributes.companies = [company] - - Intercom.updateUser(userAttributes) + + Intercom.updateUser(with: userAttributes) return event } @@ -200,7 +218,7 @@ private extension IntercomDestination { } userAttributes.customAttributes = customAttributes - Intercom.updateUser(userAttributes) + Intercom.updateUser(with: userAttributes) } func setCompanyAttributes(_ company: [String: Any]) -> ICMCompany {