Skip to content

Commit 9f77494

Browse files
Code review fixes
1. check for either email or userId 2. return result of DeeplinkHandler.handleURL
1 parent a0c6288 commit 9f77494

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

sample-apps/objc-sample-app/objc-sample-app/AppDelegate.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ @interface AppDelegate ()
1616
@end
1717

1818
@implementation AppDelegate
19+
// IMP: Either email or userId must be set.
1920
NSString *apiKey = @""; // set iterable api key here
2021
NSString *email = @""; // set iterable email here
22+
NSString *userId = @"";// set iterable userId here, either email or userId must be set
2123

2224

2325
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2426
// initial check
25-
if (apiKey.length == 0 || email.length == 0) {
26-
[NSException raise:@"Not Initialized" format:@"Iterable API key and email must be set."];
27+
if (apiKey.length == 0 || (email.length == 0 && userId.length == 0)) {
28+
[NSException raise:@"Not Initialized" format:@"Iterable API key and either email or userId must be set."];
2729
}
2830

2931
//ITBL: Setup Notifications
@@ -115,7 +117,7 @@ - (BOOL)handleIterableCustomAction:(IterableAction *)action context:(IterableAct
115117
if (action.userInput != nil) {
116118
NSString *urlString = [[NSString alloc] initWithFormat:@"https://majumder.me/coffee?q=%@", action.userInput];
117119
NSURL *url = [[NSURL alloc] initWithString:urlString];
118-
[DeeplinkHandler handleURL:url];
120+
return [DeeplinkHandler handleURL:url];
119121
}
120122
}
121123

sample-apps/swift-sample-app/swift-sample-app/AppDelegate.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import IterableSDK
1414
@UIApplicationMain
1515
class AppDelegate: UIResponder, UIApplicationDelegate {
1616
// ITBL: replace with your api key and email.
17+
// IMP: Either userId or email must be set.
1718
let apiKey = "" // set Iterable api key here
1819
let email = "" // set Iterable user email here.
20+
let userId = "" // set iterable userId here. Either email or userId must be set.
1921

2022
var window: UIWindow?
2123

2224
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2325
// Initial check
24-
if apiKey.isEmpty || email.isEmpty {
25-
fatalError("Iterable API Key and email need to be set.")
26+
if apiKey.isEmpty || (email.isEmpty && userId.isEmpty) {
27+
fatalError("Iterable API Key and either email or userId need to be set.")
2628
}
2729

2830
//ITBL: Setup Notification
@@ -138,7 +140,7 @@ extension AppDelegate : IterableCustomActionDelegate {
138140
func handle(iterableCustomAction action: IterableAction, inContext context: IterableActionContext) -> Bool {
139141
if action.type == "handleFindCoffee" {
140142
if let query = action.userInput {
141-
_ = DeeplinkHandler.handle(url: URL(string: "https://majumder.me/coffee?q=\(query)")!)
143+
return DeeplinkHandler.handle(url: URL(string: "https://majumder.me/coffee?q=\(query)")!)
142144
}
143145
}
144146
return false

0 commit comments

Comments
 (0)