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

Commit 3510c18

Browse files
authored
[ITBL-3976] Push Revamp (#52)
* Add ITBNotificationServiceExtension * Add IterableAction and IterableActionRunner to execute actions specified in push payload * Remove old project files from IterableAppExtensions * Use LogDebug instead of NSLog * Additional tests for new classes * Add documentation for new classes and protocols, export service extension header * Fix lint warning * Move button attributes to button payload, leave openUrl and custom actions for IterableAction object. Extract field names into constants. * Add IterableActionRunner test, check that automatic push open tracking passes all campaign fields * Add URL open error logging, other minor changes * Fix a warning * Extract constants from tests * Add support for notification action handling on iOS 9 * Add notification handling tests for iOS 9 * Fix a typo, make some of the new headers public
1 parent 3c78e65 commit 3510c18

40 files changed

+2577
-48
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ xcuserdata
44
*~
55
Podfile.lock
66
Pods/
7-
Iterable-iOS-SDK.xcworkspace/
87
Iterable-iOS-SDKDocs/
98

109
*.xccheckout

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
osx_image: xcode9.2
1+
osx_image: xcode9.3
22
language: objective-c
33
xcode_workspace: Iterable-iOS-SDK.xcworkspace
44
xcode_scheme: Iterable-iOS-SDKTests
@@ -8,7 +8,9 @@ before_install:
88
- gem install xcpretty xcpretty-travis-formatter
99

1010
script:
11+
- xcodebuild test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X' -workspace Iterable-iOS-SDK.xcworkspace -scheme IterableAppExtensionsTests CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
1112
- xcodebuild test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X' -workspace Iterable-iOS-SDK.xcworkspace -scheme Iterable-iOS-SDKTests CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
13+
- xcodebuild test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.0' -workspace Iterable-iOS-SDK.xcworkspace -scheme Iterable-iOS-SDKTests CODE_SIGNING_REQUIRED=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty -f `xcpretty-travis-formatter`
1214
- pod lib lint
1315

1416
after_success:

Iterable-iOS-SDK.xcodeproj/project.pbxproj

+595-41
Large diffs are not rendered by default.

Iterable-iOS-SDK.xcodeproj/xcshareddata/xcschemes/Iterable-iOS-SDKTests.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
buildForAnalyzing = "NO">
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "DCC94D024AAEED7818D49D28024958F6"
17+
BlueprintIdentifier = "D0173C9E99BAFAC1D674FD7D7887CF5B"
1818
BuildableName = "libPods-Iterable-iOS-SDK.a"
1919
BlueprintName = "Pods-Iterable-iOS-SDK"
2020
ReferencedContainer = "container:Pods/Pods.xcodeproj">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0930"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "9267AA0E20992F9C006AF394"
18+
BuildableName = "IterableAppExtensions.framework"
19+
BlueprintName = "IterableAppExtensions"
20+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "9267AA1620992F9C006AF394"
36+
BuildableName = "IterableAppExtensionsTests.xctest"
37+
BlueprintName = "IterableAppExtensionsTests"
38+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
<MacroExpansion>
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "9267AA0E20992F9C006AF394"
46+
BuildableName = "IterableAppExtensions.framework"
47+
BlueprintName = "IterableAppExtensions"
48+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
49+
</BuildableReference>
50+
</MacroExpansion>
51+
<AdditionalOptions>
52+
</AdditionalOptions>
53+
</TestAction>
54+
<LaunchAction
55+
buildConfiguration = "Debug"
56+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
57+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
58+
launchStyle = "0"
59+
useCustomWorkingDirectory = "NO"
60+
ignoresPersistentStateOnLaunch = "NO"
61+
debugDocumentVersioning = "YES"
62+
debugServiceExtension = "internal"
63+
allowLocationSimulation = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "9267AA0E20992F9C006AF394"
68+
BuildableName = "IterableAppExtensions.framework"
69+
BlueprintName = "IterableAppExtensions"
70+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
<AdditionalOptions>
74+
</AdditionalOptions>
75+
</LaunchAction>
76+
<ProfileAction
77+
buildConfiguration = "Release"
78+
shouldUseLaunchSchemeArgsEnv = "YES"
79+
savedToolIdentifier = ""
80+
useCustomWorkingDirectory = "NO"
81+
debugDocumentVersioning = "YES">
82+
<MacroExpansion>
83+
<BuildableReference
84+
BuildableIdentifier = "primary"
85+
BlueprintIdentifier = "9267AA0E20992F9C006AF394"
86+
BuildableName = "IterableAppExtensions.framework"
87+
BlueprintName = "IterableAppExtensions"
88+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
89+
</BuildableReference>
90+
</MacroExpansion>
91+
</ProfileAction>
92+
<AnalyzeAction
93+
buildConfiguration = "Debug">
94+
</AnalyzeAction>
95+
<ArchiveAction
96+
buildConfiguration = "Release"
97+
revealArchiveInOrganizer = "YES">
98+
</ArchiveAction>
99+
</Scheme>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0930"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForRunning = "YES"
11+
buildForTesting = "YES">
12+
<BuildableReference
13+
BuildableIdentifier = "primary"
14+
BlueprintIdentifier = "9267AA1620992F9C006AF394"
15+
BuildableName = "IterableAppExtensionsTests.xctest"
16+
BlueprintName = "IterableAppExtensionsTests"
17+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
18+
</BuildableReference>
19+
</BuildActionEntry>
20+
</BuildActionEntries>
21+
</BuildAction>
22+
<TestAction
23+
buildConfiguration = "Debug"
24+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
25+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
26+
shouldUseLaunchSchemeArgsEnv = "YES">
27+
<Testables>
28+
<TestableReference
29+
skipped = "NO">
30+
<BuildableReference
31+
BuildableIdentifier = "primary"
32+
BlueprintIdentifier = "9267AA1620992F9C006AF394"
33+
BuildableName = "IterableAppExtensionsTests.xctest"
34+
BlueprintName = "IterableAppExtensionsTests"
35+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
36+
</BuildableReference>
37+
</TestableReference>
38+
</Testables>
39+
<AdditionalOptions>
40+
</AdditionalOptions>
41+
</TestAction>
42+
<LaunchAction
43+
buildConfiguration = "Debug"
44+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
45+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
46+
launchStyle = "0"
47+
useCustomWorkingDirectory = "NO"
48+
ignoresPersistentStateOnLaunch = "NO"
49+
debugDocumentVersioning = "YES"
50+
debugServiceExtension = "internal"
51+
allowLocationSimulation = "YES">
52+
<AdditionalOptions>
53+
</AdditionalOptions>
54+
</LaunchAction>
55+
<ProfileAction
56+
buildConfiguration = "Release"
57+
shouldUseLaunchSchemeArgsEnv = "YES"
58+
savedToolIdentifier = ""
59+
useCustomWorkingDirectory = "NO"
60+
debugDocumentVersioning = "YES">
61+
</ProfileAction>
62+
<AnalyzeAction
63+
buildConfiguration = "Debug">
64+
</AnalyzeAction>
65+
<ArchiveAction
66+
buildConfiguration = "Release"
67+
revealArchiveInOrganizer = "YES">
68+
</ArchiveAction>
69+
</Scheme>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0930"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "093028C81D1B56E000E7CFBE"
18+
BuildableName = "IterableSDKFramework"
19+
BlueprintName = "IterableSDKFramework"
20+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<AdditionalOptions>
33+
</AdditionalOptions>
34+
</TestAction>
35+
<LaunchAction
36+
buildConfiguration = "Debug"
37+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
38+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
39+
launchStyle = "0"
40+
useCustomWorkingDirectory = "NO"
41+
ignoresPersistentStateOnLaunch = "NO"
42+
debugDocumentVersioning = "YES"
43+
debugServiceExtension = "internal"
44+
allowLocationSimulation = "YES">
45+
<MacroExpansion>
46+
<BuildableReference
47+
BuildableIdentifier = "primary"
48+
BlueprintIdentifier = "093028C81D1B56E000E7CFBE"
49+
BuildableName = "IterableSDKFramework"
50+
BlueprintName = "IterableSDKFramework"
51+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
52+
</BuildableReference>
53+
</MacroExpansion>
54+
<AdditionalOptions>
55+
</AdditionalOptions>
56+
</LaunchAction>
57+
<ProfileAction
58+
buildConfiguration = "Release"
59+
shouldUseLaunchSchemeArgsEnv = "YES"
60+
savedToolIdentifier = ""
61+
useCustomWorkingDirectory = "NO"
62+
debugDocumentVersioning = "YES">
63+
<MacroExpansion>
64+
<BuildableReference
65+
BuildableIdentifier = "primary"
66+
BlueprintIdentifier = "093028C81D1B56E000E7CFBE"
67+
BuildableName = "IterableSDKFramework"
68+
BlueprintName = "IterableSDKFramework"
69+
ReferencedContainer = "container:Iterable-iOS-SDK.xcodeproj">
70+
</BuildableReference>
71+
</MacroExpansion>
72+
</ProfileAction>
73+
<AnalyzeAction
74+
buildConfiguration = "Debug">
75+
</AnalyzeAction>
76+
<ArchiveAction
77+
buildConfiguration = "Release"
78+
revealArchiveInOrganizer = "YES">
79+
</ArchiveAction>
80+
</Scheme>

Iterable-iOS-SDK.xcworkspace/contents.xcworkspacedata

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Iterable-iOS-SDK/IterableAPI.h

+34-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
// Copyright (c) 2014 Iterable. All rights reserved.
77
//
88

9-
@import Foundation;
9+
#import <UIKit/UIKit.h>
1010
#import "CommerceItem.h"
11+
#import "IterableAction.h"
1112
#import "IterableConstants.h"
1213

1314
// all params are nonnull, unless annotated otherwise
@@ -33,6 +34,35 @@ typedef NS_ENUM(NSInteger, PushServicePlatform) {
3334
APNS
3435
};
3536

37+
/**
38+
* Custom URL handling delegate
39+
*/
40+
@protocol IterableURLDelegate <NSObject>
41+
42+
/**
43+
* Callback called for a deeplink action. Return YES to override default behavior
44+
* @param url Deeplink URL
45+
* @param action Original openUrl Action object
46+
* @return Boolean value. Return YES if the URL was handled to override default behavior.
47+
*/
48+
- (BOOL)handleIterableURL:(NSURL *)url fromAction:(IterableAction *)action;
49+
50+
@end
51+
52+
/**
53+
* Custom action handling delegate
54+
*/
55+
@protocol IterableCustomActionDelegate <NSObject>
56+
57+
/**
58+
* Callback called for custom actions from push notifications
59+
* @param action `IterableAction` object containing action payload
60+
* @return Boolean value. Reserved for future use.
61+
*/
62+
- (BOOL)handleIterableCustomAction:(IterableAction *)action;
63+
64+
@end
65+
3666
/**
3767
`IterableAPI` contains all the essential functions for communicating with Iterable's API
3868
*/
@@ -63,6 +93,9 @@ typedef NS_ENUM(NSInteger, PushServicePlatform) {
6393
*/
6494
@property(nonatomic, readonly, copy) NSString *hexToken;
6595

96+
@property(nonatomic) id<IterableURLDelegate> urlDelegate;
97+
@property(nonatomic) id<IterableCustomActionDelegate> customActionDelegate;
98+
6699
/////////////////////////////////
67100
/// @name Creating an IterableAPI
68101
/////////////////////////////////

Iterable-iOS-SDK/IterableAPI.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import "IterableInAppManager.h"
2424
#import "IterableConstants.h"
2525
#import "IterableDeeplinkManager.h"
26+
#import "IterableAppIntegration+Private.h"
2627

2728
@interface IterableAPI ()
2829
@end
@@ -391,9 +392,9 @@ - (instancetype)createSession:(NSDictionary *)launchOptions useCustomLaunchOptio
391392
// Automatically try to track a pushOpen
392393
if (launchOptions) {
393394
if (useCustomLaunchOptions) {
394-
[self trackPushOpen:launchOptions];
395+
[IterableAppIntegration performDefaultNotificationAction:launchOptions api:self];
395396
} else if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
396-
[self trackPushOpen:launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]];
397+
[IterableAppIntegration performDefaultNotificationAction:launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] api:self];
397398
}
398399
}
399400

0 commit comments

Comments
 (0)