From dc692d5a113310dfde1f4d0be724a72b305021ea Mon Sep 17 00:00:00 2001 From: Vladimir Espinola Date: Fri, 7 Jun 2024 12:21:34 -0400 Subject: [PATCH] restored constants to avoid breaking changes --- ExampleSwift/ExampleSwift/AppDelegate.swift | 12 +++--- Framework/ATTNSDKFramework.h | 8 ++++ Framework/module.modulemap | 5 +++ Package.swift | 2 +- Sources/Public/ATTNEventTracker.swift | 5 +++ Sources/Public/Objc/ATTNConstants.m | 33 ++++++++++++++++ Sources/Public/Objc/Include/ATTNConstants.h | 38 +++++++++++++++++++ attentive-ios-sdk.xcodeproj/project.pbxproj | 34 ++++++++++++++++- .../xcshareddata/swiftpm/Package.resolved | 15 -------- 9 files changed, 128 insertions(+), 24 deletions(-) create mode 100644 Framework/ATTNSDKFramework.h create mode 100644 Framework/module.modulemap create mode 100644 Sources/Public/Objc/ATTNConstants.m create mode 100644 Sources/Public/Objc/Include/ATTNConstants.h delete mode 100644 attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/ExampleSwift/ExampleSwift/AppDelegate.swift b/ExampleSwift/ExampleSwift/AppDelegate.swift index 7f13d18..97ee94d 100644 --- a/ExampleSwift/ExampleSwift/AppDelegate.swift +++ b/ExampleSwift/ExampleSwift/AppDelegate.swift @@ -39,12 +39,12 @@ class AppDelegate : UIResponder, UIApplicationDelegate { public static func createUserIdentifiers() -> [String: Any] { [ - ATTNIdentifierType.phone: "+15671230987", - ATTNIdentifierType.email: "someemail@email.com", - ATTNIdentifierType.clientUserId: "APP_USER_ID", - ATTNIdentifierType.shopifyId: "207119551", - ATTNIdentifierType.klaviyoId: "555555", - ATTNIdentifierType.customIdentifiers: ["customId": "customIdValue"] + IDENTIFIER_TYPE_PHONE: "+15671230987", + IDENTIFIER_TYPE_EMAIL: "someemail@email.com", + IDENTIFIER_TYPE_CLIENT_USER_ID: "APP_USER_ID", + IDENTIFIER_TYPE_SHOPIFY_ID: "207119551", + IDENTIFIER_TYPE_KLAVIYO_ID: "555555", + IDENTIFIER_TYPE_CUSTOM_IDENTIFIERS: ["customId": "customIdValue"] ] } } diff --git a/Framework/ATTNSDKFramework.h b/Framework/ATTNSDKFramework.h new file mode 100644 index 0000000..6332662 --- /dev/null +++ b/Framework/ATTNSDKFramework.h @@ -0,0 +1,8 @@ +#import + +FOUNDATION_EXPORT double ATTNSDKFrameworkVersionNumber; + +FOUNDATION_EXPORT const unsigned char ATTNSDKFrameworkVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import +#import diff --git a/Framework/module.modulemap b/Framework/module.modulemap new file mode 100644 index 0000000..85de36c --- /dev/null +++ b/Framework/module.modulemap @@ -0,0 +1,5 @@ +framework module attentive_ios_sdk_framework { + umbrella header "ATTNSDKFramework.h" + export * + module * { export * } +} diff --git a/Package.swift b/Package.swift index b0dd1a2..9d9583d 100644 --- a/Package.swift +++ b/Package.swift @@ -14,7 +14,7 @@ let package = Package( name: "ATTNSDKFramework", path: "Sources", resources: [ .process("Resources") ], - publicHeadersPath: "include" + publicHeadersPath: "Public/Objc/Include" ) ] ) diff --git a/Sources/Public/ATTNEventTracker.swift b/Sources/Public/ATTNEventTracker.swift index 6eb1973..7a7f8a5 100644 --- a/Sources/Public/ATTNEventTracker.swift +++ b/Sources/Public/ATTNEventTracker.swift @@ -22,11 +22,16 @@ public final class ATTNEventTracker: NSObject { _sharedInstance = ATTNEventTracker(sdk: sdk) } + @available(swift, deprecated: 1.0, message: "Please use record(event: ATTNEvent) instead.") @objc(recordEvent:) public func record(_ event: ATTNEvent) { sdk.send(event: event) } + public func record(event: ATTNEvent) { + sdk.send(event: event) + } + @objc public static func sharedInstance() -> ATTNEventTracker? { assert(_sharedInstance != nil, "ATTNEventTracker must be setup before being used") diff --git a/Sources/Public/Objc/ATTNConstants.m b/Sources/Public/Objc/ATTNConstants.m new file mode 100644 index 0000000..e0032e8 --- /dev/null +++ b/Sources/Public/Objc/ATTNConstants.m @@ -0,0 +1,33 @@ +// +// ATTNConstants.m +// attentive-ios-sdk-framework +// +// Created by Vladimir - Work on 2024-05-28. +// + +#import "ATTNConstants.h" + +// Status passed to ATTNCreativeTriggerCompletionHandler when the creative is opened sucessfully +NSString *const CREATIVE_TRIGGER_STATUS_OPENED = @"CREATIVE_TRIGGER_STATUS_OPENED"; +// Status passed to ATTNCreativeTriggerCompletionHandler when the creative is closed sucessfully +NSString *const CREATIVE_TRIGGER_STATUS_CLOSED = @"CREATIVE_TRIGGER_STATUS_CLOSED"; +// Status passed to the ATTNCreativeTriggerCompletionHandler when the Creative has been triggered but it is not +// opened successfully. This can happen if there is no available mobile app creative, if the creative +// is fatigued, if the creative call has been timed out, or if an unknown exception occurs. +NSString *const CREATIVE_TRIGGER_STATUS_NOT_OPENED = @"CREATIVE_TRIGGER_STATUS_NOT_OPENED"; +// Status passed to the ATTNCreativeTriggerCompletionHandler when the Creative is not closed due to an unknown +// exception +NSString *const CREATIVE_TRIGGER_STATUS_NOT_CLOSED = @"CREATIVE_TRIGGER_STATUS_NOT_CLOSED"; + +// Your unique identifier for the user - this should be consistent across the user's lifetime, for example a database id +NSString *const IDENTIFIER_TYPE_CLIENT_USER_ID = @"clientUserId"; +// The user's phone number in E.164 format +NSString *const IDENTIFIER_TYPE_PHONE = @"phone"; +// The user's email +NSString *const IDENTIFIER_TYPE_EMAIL = @"email"; +// The user's Shopify Customer ID +NSString *const IDENTIFIER_TYPE_SHOPIFY_ID = @"shopifyId"; +// The user's Klaviyo ID +NSString *const IDENTIFIER_TYPE_KLAVIYO_ID = @"klaviyoId"; +// Key-value pairs of custom identifier names and values (both NSStrings) to associate with this user +NSString *const IDENTIFIER_TYPE_CUSTOM_IDENTIFIERS = @"customIdentifiers"; diff --git a/Sources/Public/Objc/Include/ATTNConstants.h b/Sources/Public/Objc/Include/ATTNConstants.h new file mode 100644 index 0000000..9278e22 --- /dev/null +++ b/Sources/Public/Objc/Include/ATTNConstants.h @@ -0,0 +1,38 @@ +// +// ATTNConstants.h +// attentive-ios-sdk-framework +// +// Created by Vladimir - Work on 2024-05-28. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +/// Status passed to `ATTNCreativeTriggerCompletionHandler` when the creative is opened successfully +extern NSString *const CREATIVE_TRIGGER_STATUS_OPENED __attribute__((deprecated("Please use ATTNCreativeTriggerStatus.opened instead."))); +/// Status passed to `ATTNCreativeTriggerCompletionHandler` when the creative is closed sucessfully +extern NSString *const CREATIVE_TRIGGER_STATUS_CLOSED __attribute__((deprecated("Please use ATTNCreativeTriggerStatus.closed instead."))); +/** Status passed to the`ATTNCreativeTriggerCompletionHandler` when the Creative has been triggered but it is not + opened successfully. This can happen if there is no available mobile app creative, if the creative + is fatigued, if the creative call has been timed out, or if an unknown exception occurs. + */ +extern NSString *const CREATIVE_TRIGGER_STATUS_NOT_OPENED __attribute__((deprecated("Please use ATTNCreativeTriggerStatus.notOpened instead."))); +/// Status passed to the `ATTNCreativeTriggerCompletionHandler` when the Creative is not closed due to an unknown exception +extern NSString *const CREATIVE_TRIGGER_STATUS_NOT_CLOSED __attribute__((deprecated("Please use ATTNCreativeTriggerStatus.notClosed instead."))); + + +/// Your unique identifier for the user - this should be consistent across the user's lifetime, for example a database id +extern NSString *const IDENTIFIER_TYPE_CLIENT_USER_ID __attribute__((deprecated("Please use ATTNIdentifierType.clientUserId instead."))); +/// The user's phone number in E.164 format +extern NSString *const IDENTIFIER_TYPE_PHONE __attribute__((deprecated("Please use ATTNIdentifierType.phone instead."))); +/// The user's email +extern NSString *const IDENTIFIER_TYPE_EMAIL __attribute__((deprecated("Please use ATTNIdentifierType.email instead."))); +/// The user's Shopify Customer ID +extern NSString *const IDENTIFIER_TYPE_SHOPIFY_ID __attribute__((deprecated("Please use ATTNIdentifierType.shopifyId instead."))); +/// The user's Klaviyo ID +extern NSString *const IDENTIFIER_TYPE_KLAVIYO_ID __attribute__((deprecated("Please use ATTNIdentifierType.klaviyoId instead."))); +/// Key-value pairs of custom identifier names and values (both Strings) to associate with this user +extern NSString *const IDENTIFIER_TYPE_CUSTOM_IDENTIFIERS __attribute__((deprecated("Please use ATTNIdentifierType.customIdentifiers instead."))); + +NS_ASSUME_NONNULL_END diff --git a/attentive-ios-sdk.xcodeproj/project.pbxproj b/attentive-ios-sdk.xcodeproj/project.pbxproj index 5eacbd4..0c0816d 100644 --- a/attentive-ios-sdk.xcodeproj/project.pbxproj +++ b/attentive-ios-sdk.xcodeproj/project.pbxproj @@ -67,6 +67,9 @@ FBA9FA1B2C0A77AB00C65024 /* ATTNSDKMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA9F9FD2C0A77AB00C65024 /* ATTNSDKMode.swift */; }; FBA9FA1C2C0A77AB00C65024 /* ATTNUserIdentity.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA9F9FE2C0A77AB00C65024 /* ATTNUserIdentity.swift */; }; FBA9FA1D2C0A77AB00C65024 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = FBA9FA012C0A77AB00C65024 /* PrivacyInfo.xcprivacy */; }; + FBF78AAB2C135E0700596479 /* ATTNSDKFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = FBF78AA92C135E0700596479 /* ATTNSDKFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FBF78AAE2C135ECD00596479 /* ATTNConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF78AAD2C135ECD00596479 /* ATTNConstants.m */; }; + FBF78AAF2C135ECD00596479 /* ATTNConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = FBF78AAC2C135ECD00596479 /* ATTNConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -155,6 +158,10 @@ FBA9F9FD2C0A77AB00C65024 /* ATTNSDKMode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ATTNSDKMode.swift; sourceTree = ""; }; FBA9F9FE2C0A77AB00C65024 /* ATTNUserIdentity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ATTNUserIdentity.swift; sourceTree = ""; }; FBA9FA012C0A77AB00C65024 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + FBF78AA92C135E0700596479 /* ATTNSDKFramework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ATTNSDKFramework.h; path = Framework/ATTNSDKFramework.h; sourceTree = ""; }; + FBF78AAA2C135E0700596479 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; name = module.modulemap; path = Framework/module.modulemap; sourceTree = ""; }; + FBF78AAC2C135ECD00596479 /* ATTNConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ATTNConstants.h; sourceTree = ""; }; + FBF78AAD2C135ECD00596479 /* ATTNConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ATTNConstants.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -203,6 +210,8 @@ FB0E49E52BFBB1900025E281 /* Package.swift */, 58332EDF292EC26000B1ECF3 /* LICENSE */, 58332EDE292EC26000B1ECF3 /* README.md */, + FBF78AA92C135E0700596479 /* ATTNSDKFramework.h */, + FBF78AAA2C135E0700596479 /* module.modulemap */, 58332EDC292EC25500B1ECF3 /* attentive-ios-sdk.podspec */, ); name = "Supporting Files"; @@ -373,6 +382,7 @@ FBA9F9FF2C0A77AB00C65024 /* Public */ = { isa = PBXGroup; children = ( + FBF78AA82C135D3E00596479 /* Objc */, FB60AF0F2C123ABB00C61537 /* SDK */, FBA9F9FA2C0A77AB00C65024 /* Events */, FBA9F9FB2C0A77AB00C65024 /* ATTNEventTracker.swift */, @@ -410,6 +420,23 @@ path = Sources; sourceTree = ""; }; + FBF78AA72C135C7300596479 /* Include */ = { + isa = PBXGroup; + children = ( + FBF78AAC2C135ECD00596479 /* ATTNConstants.h */, + ); + path = Include; + sourceTree = ""; + }; + FBF78AA82C135D3E00596479 /* Objc */ = { + isa = PBXGroup; + children = ( + FBF78AA72C135C7300596479 /* Include */, + FBF78AAD2C135ECD00596479 /* ATTNConstants.m */, + ); + path = Objc; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -417,6 +444,8 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + FBF78AAB2C135E0700596479 /* ATTNSDKFramework.h in Headers */, + FBF78AAF2C135ECD00596479 /* ATTNConstants.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -552,6 +581,7 @@ FBA9FA092C0A77AB00C65024 /* ATTNAppInfo.swift in Sources */, FB35C1792C0E030E009FA048 /* ATTNCreativeTriggerStatus.swift in Sources */, FBA9FA1B2C0A77AB00C65024 /* ATTNSDKMode.swift in Sources */, + FBF78AAE2C135ECD00596479 /* ATTNConstants.m in Sources */, FBA9FA072C0A77AB00C65024 /* ATTNEventRequest.swift in Sources */, FB35C1932C0E524E009FA048 /* ATTNPurchaseEvent+Extension.swift in Sources */, FB35C18D2C0E3FAA009FA048 /* ATTNUserIdentity+Extension.swift in Sources */, @@ -767,7 +797,7 @@ ); MACOSX_DEPLOYMENT_TARGET = 12.6; MARKETING_VERSION = 1.0; - MODULEMAP_FILE = ""; + MODULEMAP_FILE = "$(SRCROOT)/Framework/module.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = "com.attentive.attentive-ios-sdk-local"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = iphoneos; @@ -809,7 +839,7 @@ ); MACOSX_DEPLOYMENT_TARGET = 12.6; MARKETING_VERSION = 1.0; - MODULEMAP_FILE = ""; + MODULEMAP_FILE = "$(SRCROOT)/Framework/module.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = "com.attentive.attentive-ios-sdk-local"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = iphoneos; diff --git a/attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved b/attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 62609f3..0000000 --- a/attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,15 +0,0 @@ -{ - "originHash" : "6b3de92165125b4410ec54f34acb3ca6e0b8fc849f4bd109516c1eddb59f6bf0", - "pins" : [ - { - "identity" : "attentive-ios-sdk", - "kind" : "remoteSourceControl", - "location" : "https://github.com/vespinola/attentive-ios-sdk.git", - "state" : { - "branch" : "main", - "revision" : "46691f276e02add53c6f6a0af5cd1c13c04c9497" - } - } - ], - "version" : 3 -}