Skip to content

Commit 0e9948c

Browse files
authored
Fix objc example to alleviate analytics leaving scope and terminating (#192)
* Fix objc example to alleviate analytics leaving scope and terminating * removed writekey
1 parent 1b4fe3f commit 0e9948c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Examples/apps/ObjCExample/ObjCExample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
460FF309299AAEEC00635FF9 /* Segment in Frameworks */ = {isa = PBXBuildFile; productRef = 460FF308299AAEEC00635FF9 /* Segment */; };
1011
464247BC26C6D7A700CAD301 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 464247BB26C6D7A700CAD301 /* AppDelegate.m */; };
1112
464247BF26C6D7A700CAD301 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 464247BE26C6D7A700CAD301 /* SceneDelegate.m */; };
1213
464247C226C6D7A700CAD301 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 464247C126C6D7A700CAD301 /* ViewController.m */; };
1314
464247C526C6D7A700CAD301 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 464247C326C6D7A700CAD301 /* Main.storyboard */; };
1415
464247C726C6D7A800CAD301 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 464247C626C6D7A800CAD301 /* Assets.xcassets */; };
1516
464247CA26C6D7A800CAD301 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 464247C826C6D7A800CAD301 /* LaunchScreen.storyboard */; };
1617
464247CD26C6D7A800CAD301 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 464247CC26C6D7A800CAD301 /* main.m */; };
17-
464247D526C6D7DC00CAD301 /* Segment in Frameworks */ = {isa = PBXBuildFile; productRef = 464247D426C6D7DC00CAD301 /* Segment */; };
1818
/* End PBXBuildFile section */
1919

2020
/* Begin PBXFileReference section */
@@ -37,7 +37,7 @@
3737
isa = PBXFrameworksBuildPhase;
3838
buildActionMask = 2147483647;
3939
files = (
40-
464247D526C6D7DC00CAD301 /* Segment in Frameworks */,
40+
460FF309299AAEEC00635FF9 /* Segment in Frameworks */,
4141
);
4242
runOnlyForDeploymentPostprocessing = 0;
4343
};
@@ -103,7 +103,7 @@
103103
);
104104
name = ObjCExample;
105105
packageProductDependencies = (
106-
464247D426C6D7DC00CAD301 /* Segment */,
106+
460FF308299AAEEC00635FF9 /* Segment */,
107107
);
108108
productName = ObjCExample;
109109
productReference = 464247B726C6D7A700CAD301 /* ObjCExample.app */;
@@ -357,7 +357,7 @@
357357
/* End XCConfigurationList section */
358358

359359
/* Begin XCSwiftPackageProductDependency section */
360-
464247D426C6D7DC00CAD301 /* Segment */ = {
360+
460FF308299AAEEC00635FF9 /* Segment */ = {
361361
isa = XCSwiftPackageProductDependency;
362362
productName = Segment;
363363
};

Examples/apps/ObjCExample/ObjCExample/AppDelegate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
//
77

88
#import <UIKit/UIKit.h>
9+
@import Segment;
910

1011
@interface AppDelegate : UIResponder <UIApplicationDelegate>
1112

13+
@property (nonatomic, retain, nullable) SEGAnalytics *analytics;
1214

1315
@end
1416

Examples/apps/ObjCExample/ObjCExample/AppDelegate.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ @implementation AppDelegate
1818

1919
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2020
// Override point for customization after application launch.
21-
SEGConfiguration *config = [[SEGConfiguration alloc] initWithWriteKey:@"WRITE_KEY"];
21+
SEGConfiguration *config = [[SEGConfiguration alloc] initWithWriteKey:@"<writekey>"];
2222
config.trackApplicationLifecycleEvents = YES;
2323

24-
SEGAnalytics *analytics = [[SEGAnalytics alloc] initWithConfiguration: config];
24+
_analytics = [[SEGAnalytics alloc] initWithConfiguration: config];
2525

26-
[analytics track:@"test"];
27-
[analytics track:@"testProps" properties:@{@"email": @"[email protected]"}];
26+
[self.analytics track:@"test"];
27+
[self.analytics track:@"testProps" properties:@{@"email": @"[email protected]"}];
28+
29+
[self.analytics flush];
2830

2931
return YES;
3032
}

0 commit comments

Comments
 (0)