Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Commit 485feb6

Browse files
authored
[ITBL-5182] Refactor SDK initialization (#58)
* Refactor SDK initialization: deprecate old constructor and sharedInstance methods, introduce initializeWithApiKey:launchOptions:config:, persist user email/id, make sure we handle the push notification that opened the app once * Fix tests + minor changes * Determine APNS production/sandbox environment automatically, add pushIntegrationName, sandboxPushIntegrationName and pushPlatform fields to IterableConfig * Add documentation for the new initialization methods * Do not handle actions and try to open Safari for URLs unless the SDK is initialized with a new init method * Add a test for registerToken: method * Add email/userId persistency test * Check that appName is not nil in registerToken
1 parent e8ded60 commit 485feb6

16 files changed

+708
-291
lines changed

Iterable-iOS-SDK.xcodeproj/project.pbxproj

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,18 @@
6666
929330912099449F00DAE180 /* IterableAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 9293308F2099449F00DAE180 /* IterableAction.m */; };
6767
92C6325C208FF7AA00A7C216 /* IterableAppIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 92C6325A208FF7AA00A7C216 /* IterableAppIntegration.h */; settings = {ATTRIBUTES = (Public, ); }; };
6868
92C6325D208FF7AA00A7C216 /* IterableAppIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C6325B208FF7AA00A7C216 /* IterableAppIntegration.m */; };
69+
92F03EEC20D899CE00C3BFCA /* IterableConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 92F03EEA20D899CE00C3BFCA /* IterableConfig.h */; };
70+
92F03EED20D899CE00C3BFCA /* IterableConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 92F03EEB20D899CE00C3BFCA /* IterableConfig.m */; };
6971
92FB47C020995A0F00DA94DC /* IterableActionRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 92FB47BE20995A0F00DA94DC /* IterableActionRunner.h */; };
7072
92FB47C120995A0F00DA94DC /* IterableActionRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FB47BF20995A0F00DA94DC /* IterableActionRunner.m */; };
7173
934790CB297DB001AB6F035E /* libPods-Iterable-iOS-SDKTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 558AF668BE59E5C06930892D /* libPods-Iterable-iOS-SDKTests.a */; };
7274
AC60AB4820BDD4DC00BF6BEC /* IterableUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = AC60AB4620BDD4DC00BF6BEC /* IterableUtil.h */; };
7375
AC60AB4920BDD4DC00BF6BEC /* IterableUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = AC60AB4720BDD4DC00BF6BEC /* IterableUtil.m */; };
7476
AC60AB4B20BDDD5100BF6BEC /* IterableUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AC60AB4A20BDDD5100BF6BEC /* IterableUtilTests.m */; };
7577
E95160B3683E5A47EC313472 /* IterableAppIntegration+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = E9516F6B446F6E9AB537C83F /* IterableAppIntegration+Private.h */; };
78+
E951624B2D970B91EE110E56 /* IterableAPI+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = E95162E0F83DDB6177F24360 /* IterableAPI+Internal.h */; };
79+
E9516B4E1A6D7B8CB1314D1F /* IterableAPI+Deprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = E9516BD2E9DDA6AE024F6A63 /* IterableAPI+Deprecated.h */; };
80+
E9516D3401091CA4D87B10B9 /* IterableAPI+Deprecated.m in Sources */ = {isa = PBXBuildFile; fileRef = E9516D87A090ED58BED61C6B /* IterableAPI+Deprecated.m */; };
7681
/* End PBXBuildFile section */
7782

7883
/* Begin PBXContainerItemProxy section */
@@ -176,14 +181,19 @@
176181
9293308F2099449F00DAE180 /* IterableAction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IterableAction.m; sourceTree = "<group>"; };
177182
92C6325A208FF7AA00A7C216 /* IterableAppIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IterableAppIntegration.h; sourceTree = "<group>"; };
178183
92C6325B208FF7AA00A7C216 /* IterableAppIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IterableAppIntegration.m; sourceTree = "<group>"; };
184+
92F03EEA20D899CE00C3BFCA /* IterableConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IterableConfig.h; sourceTree = "<group>"; };
185+
92F03EEB20D899CE00C3BFCA /* IterableConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IterableConfig.m; sourceTree = "<group>"; };
179186
92FB47BE20995A0F00DA94DC /* IterableActionRunner.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IterableActionRunner.h; sourceTree = "<group>"; };
180187
92FB47BF20995A0F00DA94DC /* IterableActionRunner.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IterableActionRunner.m; sourceTree = "<group>"; };
181188
AC60AB4620BDD4DC00BF6BEC /* IterableUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IterableUtil.h; sourceTree = "<group>"; };
182189
AC60AB4720BDD4DC00BF6BEC /* IterableUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IterableUtil.m; sourceTree = "<group>"; };
183190
AC60AB4A20BDDD5100BF6BEC /* IterableUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IterableUtilTests.m; sourceTree = "<group>"; };
184191
BE5CCE23DD4BB53759B5D427 /* Pods-Iterable-iOS-SDK.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Iterable-iOS-SDK.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Iterable-iOS-SDK/Pods-Iterable-iOS-SDK.debug.xcconfig"; sourceTree = "<group>"; };
185192
DAB696718A4F07CC09FB5CB1 /* Pods-Iterable-iOS-SDKTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Iterable-iOS-SDKTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Iterable-iOS-SDKTests/Pods-Iterable-iOS-SDKTests.release.xcconfig"; sourceTree = "<group>"; };
193+
E95162E0F83DDB6177F24360 /* IterableAPI+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IterableAPI+Internal.h"; sourceTree = "<group>"; };
186194
E95162E4972E90805BB61534 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = file.yml; path = .travis.yml; sourceTree = "<group>"; };
195+
E9516BD2E9DDA6AE024F6A63 /* IterableAPI+Deprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IterableAPI+Deprecated.h"; sourceTree = "<group>"; };
196+
E9516D87A090ED58BED61C6B /* IterableAPI+Deprecated.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "IterableAPI+Deprecated.m"; sourceTree = "<group>"; };
187197
E9516F6B446F6E9AB537C83F /* IterableAppIntegration+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IterableAppIntegration+Private.h"; sourceTree = "<group>"; };
188198
/* End PBXFileReference section */
189199

@@ -269,6 +279,9 @@
269279
6804B8651AC10426000A126B /* CommerceItem.h */,
270280
093734251A1D6E8800C950B6 /* IterableAPI.h */,
271281
093734261A1D701F00C950B6 /* IterableAPI.m */,
282+
E95162E0F83DDB6177F24360 /* IterableAPI+Internal.h */,
283+
E9516D87A090ED58BED61C6B /* IterableAPI+Deprecated.m */,
284+
E9516BD2E9DDA6AE024F6A63 /* IterableAPI+Deprecated.h */,
272285
094995451A85880A0047E59B /* NSData+Conversion.h */,
273286
094995461A8588400047E59B /* NSData+Conversion.m */,
274287
0995DBDB1CFFF70800D50F19 /* IterableLogging.h */,
@@ -286,6 +299,8 @@
286299
926B33E320B7A091004DD7CE /* IterableAttributionInfo.m */,
287300
AC60AB4620BDD4DC00BF6BEC /* IterableUtil.h */,
288301
AC60AB4720BDD4DC00BF6BEC /* IterableUtil.m */,
302+
92F03EEA20D899CE00C3BFCA /* IterableConfig.h */,
303+
92F03EEB20D899CE00C3BFCA /* IterableConfig.m */,
289304
);
290305
path = "Iterable-iOS-SDK";
291306
sourceTree = "<group>";
@@ -402,6 +417,7 @@
402417
92C6325C208FF7AA00A7C216 /* IterableAppIntegration.h in Headers */,
403418
161D98BC20236BC700E91846 /* IterableDeeplinkManager.h in Headers */,
404419
0937342E1A1D99C000C950B6 /* IterableAPI.h in Headers */,
420+
92F03EEC20D899CE00C3BFCA /* IterableConfig.h in Headers */,
405421
92FB47C020995A0F00DA94DC /* IterableActionRunner.h in Headers */,
406422
68E32EF61AC21D37000CEBE1 /* CommerceItem.h in Headers */,
407423
093028D21D1B942100E7CFBE /* IterableNotificationMetadata.h in Headers */,
@@ -413,6 +429,8 @@
413429
926B33E420B7A091004DD7CE /* IterableAttributionInfo.h in Headers */,
414430
E95160B3683E5A47EC313472 /* IterableAppIntegration+Private.h in Headers */,
415431
AC60AB4820BDD4DC00BF6BEC /* IterableUtil.h in Headers */,
432+
E9516B4E1A6D7B8CB1314D1F /* IterableAPI+Deprecated.h in Headers */,
433+
E951624B2D970B91EE110E56 /* IterableAPI+Internal.h in Headers */,
416434
);
417435
runOnlyForDeploymentPostprocessing = 0;
418436
};
@@ -438,7 +456,6 @@
438456
09C0FBF91A1D6D4700D5A86B /* CopyFiles */,
439457
0937342D1A1D99BB00C950B6 /* Headers */,
440458
092302A31CF6455A004EA265 /* ShellScript */,
441-
8F897BDABF58966C088F94AF /* [CP] Copy Pods Resources */,
442459
);
443460
buildRules = (
444461
);
@@ -457,8 +474,6 @@
457474
09C0FC021A1D6D4700D5A86B /* Sources */,
458475
09C0FC031A1D6D4700D5A86B /* Frameworks */,
459476
09C0FC041A1D6D4700D5A86B /* Resources */,
460-
0D4C767C5C672D1D9C760D48 /* [CP] Embed Pods Frameworks */,
461-
6F2BAB400D026ADDE1329DB1 /* [CP] Copy Pods Resources */,
462477
);
463478
buildRules = (
464479
);
@@ -645,51 +660,6 @@
645660
shellPath = /bin/sh;
646661
shellScript = "# based on https://www.raywenderlich.com/65964/create-a-framework-for-ios and https://github.com/jverkoey/iOS-Framework#static_library_target\n# also, need to explicitly add armv7s to target architectures; see also: http://stackoverflow.com/questions/28270582/building-ios-framework-missing-architecture-armv7s-and-x86-64-on-fat-file\n\nset -o errexit\nset +o nounset\n# Avoid recursively calling this script.\nif [[ $ITBL_MASTER_SCRIPT_RUNNING ]]; then\nexit 0\nfi\nset -o nounset\nexport ITBL_MASTER_SCRIPT_RUNNING=1\n\nITBL_TARGET_NAME=${PROJECT_NAME}\nITBL_EXECUTABLE_PATH=\"lib${ITBL_TARGET_NAME}.a\"\nITBL_WRAPPER_NAME=\"${ITBL_TARGET_NAME}.framework\"\n\n# The following conditionals come from\n# https://github.com/kstenerud/iOS-Universal-Framework\n\nif [[ \"$SDK_NAME\" =~ ([A-Za-z]+) ]]\nthen\nITBL_SDK_PLATFORM=${BASH_REMATCH[1]}\nelse\necho \"Could not find platform name from SDK_NAME: $SDK_NAME\"\nexit 1\nfi\n\nif [[ \"$SDK_NAME\" =~ ([0-9]+.*$) ]]\nthen\nITBL_SDK_VERSION=${BASH_REMATCH[1]}\nelse\necho \"Could not find sdk version from SDK_NAME: $SDK_NAME\"\nexit 1\nfi\n\n# Build for the simulator architecture\necho \"Building static library: workspace=${PROJECT_DIR}/${PROJECT_NAME}.xcworkspace, scheme=${ITBL_TARGET_NAME}, platform=iphonesimulator, destination='platform=iOS Simulator,name=iPad'\"\n# iPhone5 is the last one on armv7s, iPhone6+ is on armv7\nxcrun xcodebuild ONLY_ACTIVE_ARCH=NO -workspace \"${PROJECT_DIR}/${PROJECT_NAME}.xcworkspace\" -scheme \"${ITBL_TARGET_NAME}\" -configuration \"${CONFIGURATION}\" -sdk iphonesimulator -destination \"platform=iOS Simulator,name=iPhone 6\" BUILD_DIR=\"${BUILD_DIR}\" OBJROOT=\"${OBJROOT}\" BUILD_ROOT=\"${BUILD_ROOT}\" SYMROOT=\"${SYMROOT}\" $ACTION\n\n# Build for real devices\necho \"Building static library: workspace=${PROJECT_DIR}/${PROJECT_NAME}.xcworkspace, scheme=${ITBL_TARGET_NAME}, platform=iphoneos, sdk version=${ITBL_SDK_VERSION}\"\nxcrun xcodebuild ONLY_ACTIVE_ARCH=NO -workspace \"${PROJECT_DIR}/${PROJECT_NAME}.xcworkspace\" -scheme \"${ITBL_TARGET_NAME}\" -configuration \"${CONFIGURATION}\" -sdk iphoneos${ITBL_SDK_VERSION} BUILD_DIR=\"${BUILD_DIR}\" OBJROOT=\"${OBJROOT}\" BUILD_ROOT=\"${BUILD_ROOT}\" SYMROOT=\"${SYMROOT}\" $ACTION\n\necho \"Done building architectures. Cleaning up previous artifacts...\"\n\nDESTINATION_UNIVERSAL_DIR=\"${PROJECT_DIR}/Artifacts/\"\nrm -r \"${DESTINATION_UNIVERSAL_DIR}\"\nmkdir -p \"${DESTINATION_UNIVERSAL_DIR}\"\n\necho \"Done cleaning up artifacts. Running lipo...\"\n\n# Smash the two static libraries into one fat binary and store it in the .framework\nxcrun lipo -create \"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${ITBL_EXECUTABLE_PATH}\" \"${BUILD_DIR}/${CONFIGURATION}-iphoneos/${ITBL_EXECUTABLE_PATH}\" -output \"${DESTINATION_UNIVERSAL_DIR}/${ITBL_EXECUTABLE_PATH}\"\n\necho \"Done creating fat file, now copying public headers\"\ncp -r \"${TARGET_BUILD_DIR}/include\" \"${DESTINATION_UNIVERSAL_DIR}/\"\n";
647662
};
648-
0D4C767C5C672D1D9C760D48 /* [CP] Embed Pods Frameworks */ = {
649-
isa = PBXShellScriptBuildPhase;
650-
buildActionMask = 2147483647;
651-
files = (
652-
);
653-
inputPaths = (
654-
);
655-
name = "[CP] Embed Pods Frameworks";
656-
outputPaths = (
657-
);
658-
runOnlyForDeploymentPostprocessing = 0;
659-
shellPath = /bin/sh;
660-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Iterable-iOS-SDKTests/Pods-Iterable-iOS-SDKTests-frameworks.sh\"\n";
661-
showEnvVarsInLog = 0;
662-
};
663-
6F2BAB400D026ADDE1329DB1 /* [CP] Copy Pods Resources */ = {
664-
isa = PBXShellScriptBuildPhase;
665-
buildActionMask = 2147483647;
666-
files = (
667-
);
668-
inputPaths = (
669-
);
670-
name = "[CP] Copy Pods Resources";
671-
outputPaths = (
672-
);
673-
runOnlyForDeploymentPostprocessing = 0;
674-
shellPath = /bin/sh;
675-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Iterable-iOS-SDKTests/Pods-Iterable-iOS-SDKTests-resources.sh\"\n";
676-
showEnvVarsInLog = 0;
677-
};
678-
8F897BDABF58966C088F94AF /* [CP] Copy Pods Resources */ = {
679-
isa = PBXShellScriptBuildPhase;
680-
buildActionMask = 2147483647;
681-
files = (
682-
);
683-
inputPaths = (
684-
);
685-
name = "[CP] Copy Pods Resources";
686-
outputPaths = (
687-
);
688-
runOnlyForDeploymentPostprocessing = 0;
689-
shellPath = /bin/sh;
690-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Iterable-iOS-SDK/Pods-Iterable-iOS-SDK-resources.sh\"\n";
691-
showEnvVarsInLog = 0;
692-
};
693663
9AE5129658339C152ECDBC56 /* [CP] Check Pods Manifest.lock */ = {
694664
isa = PBXShellScriptBuildPhase;
695665
buildActionMask = 2147483647;
@@ -733,6 +703,7 @@
733703
isa = PBXSourcesBuildPhase;
734704
buildActionMask = 2147483647;
735705
files = (
706+
92F03EED20D899CE00C3BFCA /* IterableConfig.m in Sources */,
736707
09CCB9301D07A7EA003EB75D /* IterableNotificationMetadata.m in Sources */,
737708
16513DDF1D89EECC00C205B3 /* IterableInAppManager.m in Sources */,
738709
094995471A8588400047E59B /* NSData+Conversion.m in Sources */,
@@ -747,6 +718,7 @@
747718
16E02BAD1E035EA400644C15 /* IterableConstants.m in Sources */,
748719
0995DBDD1CFFF7FE00D50F19 /* IterableLogging.m in Sources */,
749720
926B33E520B7A091004DD7CE /* IterableAttributionInfo.m in Sources */,
721+
E9516D3401091CA4D87B10B9 /* IterableAPI+Deprecated.m in Sources */,
750722
);
751723
runOnlyForDeploymentPostprocessing = 0;
752724
};
@@ -1035,6 +1007,7 @@
10351007
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
10361008
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
10371009
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1010+
MACH_O_TYPE = staticlib;
10381011
PRODUCT_BUNDLE_IDENTIFIER = com.iterable.IterableAppExtensions;
10391012
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
10401013
SKIP_INSTALL = YES;
@@ -1075,6 +1048,7 @@
10751048
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
10761049
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
10771050
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1051+
MACH_O_TYPE = staticlib;
10781052
PRODUCT_BUNDLE_IDENTIFIER = com.iterable.IterableAppExtensions;
10791053
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
10801054
SKIP_INSTALL = YES;

0 commit comments

Comments
 (0)