@@ -214,24 +214,16 @@ + (BNCUpdateState) updateStateWithBuildDate:(NSDate*)buildDate
214214 storedAppVersion : (NSString *)storedAppVersion
215215 currentAppVersion : (NSString *)currentAppVersion {
216216
217- if ([UIDevice currentDevice ].systemVersion .floatValue > 10.3 &&
218- storedAppVersion.length <= 0 ) {
219- // iOS version greater than 10.2 and 10.3 since there were update problems there.
220- //
221- // Doesn't count re-installs or some enterprise distribution schemes.
222- // This solves the case where a user installs the app, doesn't run it,
223- // updates the app, then runs the app. These were being counted as updates
224- // rather than installs.
225- return BNCUpdateStateInstall;
226- }
227-
228217 if (storedAppVersion) {
229218 if (currentAppVersion && [storedAppVersion isEqualToString: currentAppVersion])
230219 return BNCUpdateStateNonUpdate;
231220 else
232221 return BNCUpdateStateUpdate;
233222 }
234223
224+ // If there isn't a stored app version it might be because Branch is just starting to be used in
225+ // this project. So use the app dates to figure out if this is a new install or an update.
226+
235227 if (buildDate && [buildDate timeIntervalSince1970 ] <= 0.0 ) {
236228 // Invalid buildDate.
237229 buildDate = nil ;
@@ -241,15 +233,18 @@ + (BNCUpdateState) updateStateWithBuildDate:(NSDate*)buildDate
241233 appInstallDate = nil ;
242234 }
243235
244- if (!(buildDate && appInstallDate)) {
236+ // If app dates can't be found it may be because iOS isn't reporting them.
237+ if (buildDate == nil || appInstallDate == nil ) {
238+ BNCLogError (@" Please report this to Branch: Build date is %@ and install date is %@ . iOS version %@ ." ,
239+ buildDate, appInstallDate, [UIDevice currentDevice ].systemVersion );
245240 return BNCUpdateStateInstall;
246241 }
247242
248243 if ([buildDate compare: appInstallDate] > 0 ) {
249244 return BNCUpdateStateUpdate;
250245 }
251246
252- if ([appInstallDate timeIntervalSinceNow ] > (-60 .0 * 60.0 * 24 .0 )) {
247+ if ([appInstallDate timeIntervalSinceNow ] > (-7 .0 * 24.0 * 60.0 * 60 .0 )) {
253248 return BNCUpdateStateInstall;
254249 }
255250
0 commit comments