Skip to content

Commit df2555e

Browse files
Add changes to Objc sample project.
1 parent 590541a commit df2555e

File tree

12 files changed

+274
-32
lines changed

12 files changed

+274
-32
lines changed

sample-apps/objc-sample-app/objc-sample-app.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
AC9080D620E309B0004BC146 /* CoffeeType.m in Sources */ = {isa = PBXBuildFile; fileRef = AC9080D220E309B0004BC146 /* CoffeeType.m */; };
2121
AC9080DF20E30A63004BC146 /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = AC9080DE20E30A63004BC146 /* NotificationService.m */; };
2222
AC9080E320E30A63004BC146 /* objc-sample-app-notification-extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = AC9080DB20E30A63004BC146 /* objc-sample-app-notification-extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
23+
ACEFDCEE20FFC005009B91A2 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ACEFDCED20FFC005009B91A2 /* LoginViewController.m */; };
2324
/* End PBXBuildFile section */
2425

2526
/* Begin PBXContainerItemProxy section */
@@ -70,6 +71,8 @@
7071
AC9080DD20E30A63004BC146 /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = "<group>"; };
7172
AC9080DE20E30A63004BC146 /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = "<group>"; };
7273
AC9080E020E30A63004BC146 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
74+
ACEFDCEC20FFC005009B91A2 /* LoginViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
75+
ACEFDCED20FFC005009B91A2 /* LoginViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
7376
ACF560C820E30AB8000AAC23 /* objc-sample-app.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "objc-sample-app.entitlements"; sourceTree = "<group>"; };
7477
C63446E13C9D0D41E3092C12 /* Pods_objc_sample_app_notification_extension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_objc_sample_app_notification_extension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7578
DDFF7C4DDD2898BE48245488 /* Pods-objc-sample-app.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-objc-sample-app.release.xcconfig"; path = "Pods/Target Support Files/Pods-objc-sample-app/Pods-objc-sample-app.release.xcconfig"; sourceTree = "<group>"; };
@@ -159,6 +162,8 @@
159162
AC9080CF20E309AF004BC146 /* CoffeeViewController.m */,
160163
AC9080CB20E309AF004BC146 /* CoffeeListTableViewController.h */,
161164
AC9080CC20E309AF004BC146 /* CoffeeListTableViewController.m */,
165+
ACEFDCEC20FFC005009B91A2 /* LoginViewController.h */,
166+
ACEFDCED20FFC005009B91A2 /* LoginViewController.m */,
162167
);
163168
name = ViewControllers;
164169
sourceTree = "<group>";
@@ -391,6 +396,7 @@
391396
AC9080D620E309B0004BC146 /* CoffeeType.m in Sources */,
392397
AC9080D520E309B0004BC146 /* DeeplinkHandler.m in Sources */,
393398
AC9080B920E308D2004BC146 /* main.m in Sources */,
399+
ACEFDCEE20FFC005009B91A2 /* LoginViewController.m in Sources */,
394400
AC9080D320E309B0004BC146 /* CoffeeListTableViewController.m in Sources */,
395401
AC9080AB20E308D1004BC146 /* AppDelegate.m in Sources */,
396402
);

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

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@ @interface AppDelegate ()
1616
@end
1717

1818
@implementation AppDelegate
19-
// IMP: Either email or userId must be set.
20-
NSString *apiKey = @""; // set iterable api key here
21-
NSString *email = @""; // set iterable email here
22-
NSString *userId = @"";// set iterable userId here, either email or userId must be set
19+
// ITBL: Set your actual api key here.
20+
NSString *iterableApiKey = @"a415841b631a4c97924bc09660c658fc"; // set iterable api key here
2321

2422

2523
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
26-
// initial check
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."];
29-
}
3024

3125
//ITBL: Setup Notifications
3226
[self setupNotifications];
@@ -38,10 +32,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3832
config.pushIntegrationName = @"objc-sample-app";
3933
config.sandboxPushIntegrationName = @"objc-sample-app";
4034

41-
[IterableAPI initializeWithApiKey: apiKey
42-
launchOptions:launchOptions
43-
config:config];
44-
IterableAPI.email = email;
35+
[IterableAPI initializeWithApiKey: iterableApiKey
36+
launchOptions:launchOptions
37+
config:config];
4538

4639
return YES;
4740
}
@@ -66,6 +59,31 @@ - (void)applicationWillEnterForeground:(UIApplication *)application {
6659

6760
- (void)applicationDidBecomeActive:(UIApplication *)application {
6861
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
62+
63+
//ITBL:
64+
// You don't need to do this in your app. Just set the correct value for 'iterableApiKey' when it is declared.
65+
if ([iterableApiKey isEqualToString:@""]) {
66+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"API Key Required" message:@"You must set Iterable API Key. Run this app again after setting 'AppDelegate.iterableApiKey'." preferredStyle:UIAlertControllerStyleAlert];
67+
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
68+
exit(0);
69+
}];
70+
[alert addAction:action];
71+
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];
72+
return;
73+
}
74+
75+
//ITBL:
76+
if (IterableAPI.email == nil) {
77+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Please Login" message:@"You must set 'IterableAPI.email' before receiving push notifications from Iterable." preferredStyle:UIAlertControllerStyleAlert];
78+
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
79+
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
80+
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginNavController"];
81+
[self.window.rootViewController presentViewController:vc animated:YES completion:nil];
82+
}];
83+
[alert addAction:action];
84+
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];
85+
return;
86+
}
6987
}
7088

7189

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "iterableLogo.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
}
12+
}
Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,50 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="VyA-EU-i4h">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
59
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
610
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
711
</dependencies>
812
<scenes>
9-
<!--View Controller-->
10-
<scene sceneID="EHf-IW-A2E">
13+
<!--Launch Screen View Controller-->
14+
<scene sceneID="P7E-2V-lch">
1115
<objects>
12-
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13-
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
16+
<viewController id="VyA-EU-i4h" userLabel="Launch Screen View Controller" sceneMemberID="viewController">
17+
<view key="view" contentMode="scaleToFill" id="yvb-kM-53a">
1418
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1519
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17-
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
20+
<subviews>
21+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="50" translatesAutoresizingMaskIntoConstraints="NO" id="8fR-HX-qwe">
22+
<rect key="frame" x="40" y="170" width="295" height="33"/>
23+
<subviews>
24+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="iterableLogo" translatesAutoresizingMaskIntoConstraints="NO" id="V80-vq-1aP">
25+
<rect key="frame" x="0.0" y="0.0" width="295" height="33"/>
26+
</imageView>
27+
</subviews>
28+
</stackView>
29+
</subviews>
30+
<color key="backgroundColor" red="0.80000000000000004" green="0.80000000000000004" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
31+
<color key="tintColor" red="0.31372549020000001" green="0.71372549019999998" blue="0.98823529409999999" alpha="1" colorSpace="calibratedRGB"/>
32+
<gestureRecognizers/>
33+
<constraints>
34+
<constraint firstItem="XRF-32-D5S" firstAttribute="trailing" secondItem="8fR-HX-qwe" secondAttribute="trailing" constant="40" id="2gB-4E-geL"/>
35+
<constraint firstItem="8fR-HX-qwe" firstAttribute="leading" secondItem="XRF-32-D5S" secondAttribute="leading" constant="40" id="Ciq-j8-9o4"/>
36+
<constraint firstItem="8fR-HX-qwe" firstAttribute="top" secondItem="XRF-32-D5S" secondAttribute="top" constant="150" id="Fz1-83-ErX"/>
37+
</constraints>
38+
<viewLayoutGuide key="safeArea" id="XRF-32-D5S"/>
1839
</view>
1940
</viewController>
20-
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
41+
<placeholder placeholderIdentifier="IBFirstResponder" id="CTK-Lb-ToS" sceneMemberID="firstResponder"/>
42+
<tapGestureRecognizer id="Zqw-c1-Sz3"/>
2143
</objects>
22-
<point key="canvasLocation" x="53" y="375"/>
44+
<point key="canvasLocation" x="119" y="140"/>
2345
</scene>
2446
</scenes>
47+
<resources>
48+
<image name="iterableLogo" width="143" height="33"/>
49+
</resources>
2550
</document>

0 commit comments

Comments
 (0)