Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions Example/BasicExample/BasicExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -54,6 +55,7 @@
buildActionMask = 2147483647;
files = (
46EDC72127C6B92C00B870D7 /* Segment in Frameworks */,
F6DAD32D2F90D3E9000AF673 /* Intercom in Frameworks */,
827C512828661FB5000B1B9E /* SegmentIntercom in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -153,11 +155,13 @@
buildRules = (
);
dependencies = (
F66C32C82F90D5760077958F /* PBXTargetDependency */,
);
name = BasicExample;
packageProductDependencies = (
46EDC72027C6B92C00B870D7 /* Segment */,
827C512728661FB5000B1B9E /* SegmentIntercom */,
F6DAD32C2F90D3E9000AF673 /* Intercom */,
);
productName = BasicExample;
productReference = 46EDC6F227C6B8D100B870D7 /* BasicExample.app */;
Expand Down Expand Up @@ -207,7 +211,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1320;
LastUpgradeCheck = 1320;
LastUpgradeCheck = 1620;
TargetAttributes = {
46EDC6F127C6B8D100B870D7 = {
CreatedOnToolsVersion = 13.2.1;
Expand All @@ -233,6 +237,7 @@
mainGroup = 46EDC6E927C6B8D100B870D7;
packageReferences = (
46EDC71F27C6B92C00B870D7 /* XCRemoteSwiftPackageReference "analytics-swift" */,
F6DAD32B2F90D293000AF673 /* XCRemoteSwiftPackageReference "intercom-ios-sp" */,
);
productRefGroup = 46EDC6F327C6B8D100B870D7 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -311,6 +316,10 @@
target = 46EDC6F127C6B8D100B870D7 /* BasicExample */;
targetProxy = 46EDC70D27C6B8D200B870D7 /* PBXContainerItemProxy */;
};
F66C32C82F90D5760077958F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = F66C32C72F90D5760077958F /* Intercom */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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 */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
],
Expand All @@ -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: [
Expand Down
30 changes: 24 additions & 6 deletions Sources/SegmentIntercom/IntercomDestination.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Created by Cody Garvin on 9/21/21.

import Segment
import Intercom
import CoreMedia
import Intercom

// Copyright (c) 2022 Twilio
//
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -126,8 +144,8 @@ public class IntercomDestination: DestinationPlugin {

let userAttributes = ICMUserAttributes()
userAttributes.companies = [company]
Intercom.updateUser(userAttributes)

Intercom.updateUser(with: userAttributes)

return event
}
Expand Down Expand Up @@ -200,7 +218,7 @@ private extension IntercomDestination {
}

userAttributes.customAttributes = customAttributes
Intercom.updateUser(userAttributes)
Intercom.updateUser(with: userAttributes)
}

func setCompanyAttributes(_ company: [String: Any]) -> ICMCompany {
Expand Down