Skip to content

Commit 544b8ba

Browse files
author
Alexis Oyama
committed
Merge branch 'release/2.0.5'
2 parents dc935a8 + 5d9d4b6 commit 544b8ba

13 files changed

+224
-124
lines changed

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# How to Contribute
2+
3+
Here are some important resources:
4+
5+
* [Leanplum Docs](http://leanplum.com/docs) The official Leanplum docs.
6+
* Support: Get help at [email protected].
7+
8+
## Submitting changes
9+
10+
Please consider following guidelines before creating a PR:
11+
12+
- Confirm the intention and design of your change by reaching out to your Customer Success Manager or to Leanplum Dev Team through a new Github Issue.
13+
- Start creating your pull request from `develop` branch
14+
- Please send a GitHub Pull Request with a clear list of what you've done (read more about [pull requests](https://help.github.com/articles/about-pull-requests/)).
15+
- Add unit tests for the code that you have touched.
16+
- Please follow the existing coding conventions (which are mostly standard of the default IDE).
17+
- Make sure all of your commits are atomic (one feature per commit).
18+
- Please adhere to the conventional changelog commit style: https://github.com/commitizen/cz-cli That allows us to easily create change logs.

ISSUE_TEMPLATE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Expected Behavior
2+
3+
4+
## Actual Behavior
5+
6+
7+
## Steps to Reproduce the Problem
8+
9+
1.
10+
1.
11+
1.
12+
13+
## Specifications
14+
15+
- Version:
16+
- Platform:
17+
- Subsystem:
18+

Leanplum-SDK/Classes/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define IS_NOOP ((!IS_SUPPORTED_IOS_VERSION) || IS_JAILBROKEN || [LPConstantsState sharedState].isTestMode || [LPConstantsState sharedState].isInPermanentFailureState)
4646
#define RETURN_IF_NOOP if (IS_NOOP) return
4747

48-
#define LEANPLUM_SDK_VERSION @"2.0.4"
48+
#define LEANPLUM_SDK_VERSION @"2.0.5"
4949
#define LEANPLUM_CLIENT @"ios"
5050

5151
// Can upload up to 100 files or 50 MB per request.

Leanplum-SDK/Classes/Constants.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,17 @@ void leanplumInternalError(NSException *e)
315315
int userCodeBlocks = [[[[NSThread currentThread] threadDictionary]
316316
objectForKey:LP_USER_CODE_BLOCKS] intValue];
317317
if (userCodeBlocks <= 0) {
318-
[[LeanplumRequest post:LP_METHOD_LOG
319-
params:@{
320-
LP_PARAM_TYPE: LP_VALUE_SDK_ERROR,
321-
LP_PARAM_MESSAGE: [e description],
322-
@"stackTrace": [[e callStackSymbols] description] ?: @"",
323-
LP_PARAM_VERSION_NAME: versionName
324-
}] send];
318+
@try {
319+
[[LeanplumRequest post:LP_METHOD_LOG
320+
params:@{
321+
LP_PARAM_TYPE: LP_VALUE_SDK_ERROR,
322+
LP_PARAM_MESSAGE: [e description],
323+
@"stackTrace": [[e callStackSymbols] description] ?: @"",
324+
LP_PARAM_VERSION_NAME: versionName
325+
}] send];
326+
} @catch (NSException *e) {
327+
// This empty try/catch is needed to prevent crash <-> loop.
328+
}
325329
NSLog(@"Leanplum: INTERNAL ERROR: %@\n%@", e, [e callStackSymbols]);
326330
} else {
327331
NSLog(@"Leanplum: Caught exception in callback code: %@\n%@", e, [e callStackSymbols]);

Leanplum-SDK/Classes/LPDatabase.m

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@ - (id)init
4747
/**
4848
* Create/Open SQLite database.
4949
*/
50-
- (void)initSQLite
50+
- (sqlite3 *)initSQLite
5151
{
5252
const char *sqliteFilePath = [[LPDatabase sqliteFilePath] UTF8String];
5353
int result = sqlite3_open(sqliteFilePath, &sqlite);
5454
if (result != SQLITE_OK) {
5555
[self handleSQLiteError:@"SQLite fail to open" errorResult:result query:nil];
56-
return;
56+
return nil;
5757
}
5858
retryOnCorrupt = NO;
5959

6060
// Create tables.
6161
[self runQuery:@"CREATE TABLE IF NOT EXISTS event ("
6262
"data TEXT NOT NULL"
6363
"); PRAGMA user_version = 1;"];
64+
return sqlite;
6465
}
6566

6667
- (void)dealloc
@@ -97,18 +98,9 @@ - (void)handleSQLiteError:(NSString *)errorName errorResult:(int)result query:(N
9798
}
9899
LPLog(LPError, @"%@: %@", errorName, reason);
99100

100-
// Send error log. Using willSendErrorLog to prevent infinte loop.
101-
if (!willSendErrorLog) {
102-
willSendErrorLog = YES;
103-
NSException *exception = [NSException exceptionWithName:errorName
104-
reason:reason
105-
userInfo:nil];
106-
leanplumInternalError(exception);
107-
}
108-
109-
// If SQLite is corrupted create a new one.
101+
// If SQLite is corrupted, create a new one.
110102
// Using retryOnCorrupt to prevent infinite loop.
111-
if (result == SQLITE_CORRUPT || !retryOnCorrupt) {
103+
if (result == SQLITE_CORRUPT && !retryOnCorrupt) {
112104
[[NSFileManager defaultManager] removeItemAtPath:[LPDatabase sqliteFilePath] error:nil];
113105
retryOnCorrupt = YES;
114106
[self initSQLite];
@@ -122,15 +114,15 @@ - (void)handleSQLiteError:(NSString *)errorName errorResult:(int)result query:(N
122114
- (sqlite3_stmt *)sqliteStatementFromQuery:(NSString *)query
123115
bindObjects:(NSArray *)objectsToBind
124116
{
125-
if (!query) {
117+
// Retry creating SQLite.
118+
if (!query || (!sqlite && [self initSQLite])) {
126119
return nil;
127120
}
128121

129122
sqlite3_stmt *statement;
130123
int __block result = sqlite3_prepare_v2(sqlite, [query UTF8String], -1, &statement, NULL);
131124
if (result != SQLITE_OK) {
132-
LPLog(LPError, @"Preparing '%@': %s (%d)", query, sqlite3_errmsg(sqlite),
133-
result);
125+
[self handleSQLiteError:@"SQLite fail to prepare" errorResult:result query:query];
134126
return nil;
135127
}
136128

@@ -147,8 +139,8 @@ - (sqlite3_stmt *)sqliteStatementFromQuery:(NSString *)query
147139
SQLITE_TRANSIENT);
148140

149141
if (result != SQLITE_OK) {
150-
LPLog(LPError, @"Binding %@ to %ld: %s (%d)", obj, idx+1, sqlite3_errmsg(sqlite),
151-
result);
142+
NSString *message = [NSString stringWithFormat:@"SQLite fail to bind %@ to %ld", obj, idx+1];
143+
[self handleSQLiteError:message errorResult:result query:query];
152144
}
153145
}];
154146

@@ -162,18 +154,26 @@ - (void)runQuery:(NSString *)query
162154

163155
- (void)runQuery:(NSString *)query bindObjects:(NSArray *)objectsToBind
164156
{
157+
// Retry creating SQLite.
158+
if (!sqlite && [self initSQLite]) {
159+
return;
160+
}
161+
165162
@synchronized (self) {
166-
sqlite3_stmt *statement = [self sqliteStatementFromQuery:query bindObjects:objectsToBind];
167-
if (!statement) {
168-
return;
169-
}
170-
171-
int result = sqlite3_step(statement);
172-
if (result != SQLITE_DONE) {
173-
[self handleSQLiteError:@"SQLite fail to run query" errorResult:result query:query];
163+
@try {
164+
sqlite3_stmt *statement = [self sqliteStatementFromQuery:query bindObjects:objectsToBind];
165+
if (!statement) {
166+
return;
167+
}
168+
int result = sqlite3_step(statement);
169+
if (result != SQLITE_DONE) {
170+
LPLog(LPError, @"SQLite fail to run query.");
171+
}
172+
sqlite3_finalize(statement);
173+
} @catch (NSException *e) {
174+
LPLog(LPError, @"SQLite operation failed.");
175+
// TODO: Make sure to catch this when new logging is in place,
174176
}
175-
willSendErrorLog = NO;
176-
sqlite3_finalize(statement);
177177
}
178178
}
179179

@@ -184,6 +184,11 @@ - (NSArray *)rowsFromQuery:(NSString *)query
184184

185185
- (NSArray *)rowsFromQuery:(NSString *)query bindObjects:(NSArray *)objectsToBind
186186
{
187+
// Retry creating SQLite.
188+
if (!sqlite && [self initSQLite]) {
189+
return @[];
190+
}
191+
187192
@synchronized (self) {
188193
NSMutableArray *rows = [NSMutableArray new];
189194
sqlite3_stmt *statement = [self sqliteStatementFromQuery:query

Leanplum-SDK/Classes/LPMessageTemplates.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@
9595
#define LPMT_DEFAULT_NO_BUTTON_TEXT @"No"
9696
#define LPMT_DEFAULT_LATER_BUTTON_TEXT @"Maybe Later"
9797
#define LPMT_DEFAULT_URL @"http://www.example.com"
98-
#define LPMT_DEFAULT_CLOSE_URL @"http://leanplum:close"
99-
#define LPMT_DEFAULT_OPEN_URL @"http://leanplum:loadFinished"
100-
#define LPMT_DEFAULT_TRACK_URL @"http://leanplum:track"
101-
#define LPMT_DEFAULT_ACTION_URL @"http://leanplum:runAction"
102-
#define LPMT_DEFAULT_TRACK_ACTION_URL @"http://leanplum:runTrackedAction"
98+
#define LPMT_DEFAULT_CLOSE_URL @"http://leanplum/close"
99+
#define LPMT_DEFAULT_OPEN_URL @"http://leanplum/loadFinished"
100+
#define LPMT_DEFAULT_TRACK_URL @"http://leanplum/track"
101+
#define LPMT_DEFAULT_ACTION_URL @"http://leanplum/runAction"
102+
#define LPMT_DEFAULT_TRACK_ACTION_URL @"http://leanplum/runTrackedAction"
103103
#define LPMT_DEFAULT_HAS_DISMISS_BUTTON YES
104104
#define LPMT_DEFAULT_APP_ICON @"__iOSAppIcon-PrimaryIcon.png"
105105

Leanplum-SDK/Classes/LPVarCache.m

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -511,60 +511,60 @@ + (void)applyVariableDiffs:(NSDictionary *)diffs_
511511
maybeDownloadFiles];
512512
}
513513
}
514-
}
515514

516-
// If LeanplumLocation is linked in, setup region monitoring.
517-
if (messages_ || regions_) {
518-
if (!regionInitBlock) {
519-
if ([LPConstantsState sharedState].isDevelopmentModeEnabled) {
520-
if ([regions_ count] > 0) {
521-
NSLog(@"Leanplum: Regions have been defined in dashboard, but the app is not built to handle them.");
522-
NSLog(@"Leanplum: Add LeanplumLocation.framework or LeanplumBeacon.framework to Build Settings -> Link Binary With Libraries.");
523-
NSLog(@"Leanplum: Disregard warning if there are no plans to utilize iBeacon or Geofencing within the app");
515+
// If LeanplumLocation is linked in, setup region monitoring.
516+
if (messages_ || regions_) {
517+
if (!regionInitBlock) {
518+
if ([LPConstantsState sharedState].isDevelopmentModeEnabled) {
519+
if ([regions_ count] > 0) {
520+
NSLog(@"Leanplum: Regions have been defined in dashboard, but the app is not built to handle them.");
521+
NSLog(@"Leanplum: Add LeanplumLocation.framework or LeanplumBeacon.framework to Build Settings -> Link Binary With Libraries.");
522+
NSLog(@"Leanplum: Disregard warning if there are no plans to utilize iBeacon or Geofencing within the app");
523+
}
524524
}
525-
}
526-
} else {
527-
NSSet *foregroundRegionNames;
528-
NSSet *backgroundRegionNames;
529-
[LPActionManager getForegroundRegionNames:&foregroundRegionNames
530-
andBackgroundRegionNames:&backgroundRegionNames];
531-
regionInitBlock([LPVarCache regions], foregroundRegionNames, backgroundRegionNames);
525+
} else {
526+
NSSet *foregroundRegionNames;
527+
NSSet *backgroundRegionNames;
528+
[LPActionManager getForegroundRegionNames:&foregroundRegionNames
529+
andBackgroundRegionNames:&backgroundRegionNames];
530+
regionInitBlock([LPVarCache regions], foregroundRegionNames, backgroundRegionNames);
531+
}
532532
}
533-
}
534-
535-
BOOL interfaceUpdated = NO;
536-
if (updateRules_) {
537-
interfaceUpdated = ![updateRules_ isEqual:updateRulesDiffs];
538-
updateRulesDiffs = [updateRules_ mutableCopy];
539-
[self downloadUpdateRulesImages];
540-
}
541-
542-
BOOL eventsUpdated = NO;
543-
if (eventRules_ && ![eventRules_ isKindOfClass:NSNull.class]) {
544-
eventsUpdated = ![eventRules_ isEqual:eventRulesDiffs];
545-
eventRulesDiffs = eventRules_;
546-
}
547-
548-
if (variants_) {
549-
variants = variants_;
550-
}
551-
552-
contentVersion++;
553533

554-
if (!silent) {
555-
[self saveDiffs];
556-
557-
hasReceivedDiffs = YES;
558-
if (updateBlock) {
559-
updateBlock();
534+
BOOL interfaceUpdated = NO;
535+
if (updateRules_) {
536+
interfaceUpdated = ![updateRules_ isEqual:updateRulesDiffs];
537+
updateRulesDiffs = [updateRules_ mutableCopy];
538+
[self downloadUpdateRulesImages];
560539
}
561540

562-
if (interfaceUpdated) {
563-
interfaceUpdateBlock();
541+
BOOL eventsUpdated = NO;
542+
if (eventRules_ && ![eventRules_ isKindOfClass:NSNull.class]) {
543+
eventsUpdated = ![eventRules_ isEqual:eventRulesDiffs];
544+
eventRulesDiffs = eventRules_;
545+
}
546+
547+
if (variants_) {
548+
variants = variants_;
564549
}
565550

566-
if (eventsUpdated) {
567-
eventsUpdateBlock();
551+
contentVersion++;
552+
553+
if (!silent) {
554+
[self saveDiffs];
555+
556+
hasReceivedDiffs = YES;
557+
if (updateBlock) {
558+
updateBlock();
559+
}
560+
561+
if (interfaceUpdated) {
562+
interfaceUpdateBlock();
563+
}
564+
565+
if (eventsUpdated) {
566+
eventsUpdateBlock();
567+
}
568568
}
569569
}
570570
}

Leanplum-SDK/Classes/Leanplum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Leanplum.h
3-
// Leanplum iOS SDK Version 2.0.4
3+
// Leanplum iOS SDK Version 2.0.5
44
//
55
// Copyright (c) 2012 Leanplum, Inc. All rights reserved.
66
//

0 commit comments

Comments
 (0)