|
18 | 18 | #import "Branch.h" |
19 | 19 | #import "BNCApplication.h" |
20 | 20 | #import "BNCAppleReceipt.h" |
| 21 | +#import "BNCTuneUtility.h" |
21 | 22 |
|
22 | 23 | @interface BranchOpenRequest () |
23 | 24 | @property (assign, nonatomic) BOOL isInstall; |
@@ -99,42 +100,22 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca |
99 | 100 | } |
100 | 101 |
|
101 | 102 | typedef NS_ENUM(NSInteger, BNCUpdateState) { |
102 | | - BNCUpdateStateInstall = 0, // App was recently installed. |
103 | | - BNCUpdateStateNonUpdate = 1, // App was neither newly installed nor updated. |
104 | | - BNCUpdateStateUpdate = 2, // App was recently updated. |
105 | | - |
106 | | -// BNCUpdateStateError = 3, // Error determining update state. |
107 | | -// BNCUpdateStateReinstall = 4 // App was re-installed. |
| 103 | +// Deprecated states, however older SDKs still send them. The server will ignores these values. |
| 104 | +// BNCUpdateStateInstall = 0, // App was recently installed. |
| 105 | +// BNCUpdateStateNonUpdate = 1, // App was neither newly installed nor updated. |
| 106 | +// BNCUpdateStateUpdate = 2, // App was recently updated. |
| 107 | +// BNCUpdateStateError = 3, // Error determining update state. |
| 108 | +// BNCUpdateStateReinstall = 4, // App was re-installed. |
| 109 | + |
| 110 | + BNCUpdateStateUnknown = 0, // App update status is unknown |
| 111 | + BNCUpdateStateTuneMigration = 5 // App was migrated from Tune SDK to Branch SDK |
108 | 112 | }; |
109 | 113 |
|
110 | | -+ (NSNumber*) appUpdateState { |
111 | | - |
112 | | - BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper]; |
113 | | - BNCApplication *application = [BNCApplication currentApplication]; |
114 | | - NSTimeInterval first_install_time = application.firstInstallDate.timeIntervalSince1970; |
115 | | - NSTimeInterval latest_install_time = application.currentInstallDate.timeIntervalSince1970; |
116 | | - NSTimeInterval latest_update_time = application.currentBuildDate.timeIntervalSince1970; |
117 | | - NSTimeInterval previous_update_time = preferenceHelper.previousAppBuildDate.timeIntervalSince1970; |
118 | | - NSTimeInterval const kOneDay = 1.0 * 24.0 * 60.0 * 60.0; |
119 | | - |
120 | | - BNCUpdateState update_state = 0; |
121 | | - if (first_install_time <= 0.0 || |
122 | | - latest_install_time <= 0.0 || |
123 | | - latest_update_time <= 0.0 || |
124 | | - previous_update_time > latest_update_time) |
125 | | - update_state = BNCUpdateStateNonUpdate; // Error: Send Non-update. |
126 | | - else |
127 | | - if ((latest_update_time - kOneDay) <= first_install_time && previous_update_time <= 0) |
128 | | - update_state = BNCUpdateStateInstall; |
129 | | - else |
130 | | - if (first_install_time < latest_install_time && previous_update_time <= 0) |
131 | | - update_state = BNCUpdateStateUpdate; // Re-install: Send Update. |
132 | | - else |
133 | | - if (latest_update_time > first_install_time && previous_update_time < latest_update_time) |
134 | | - update_state = BNCUpdateStateUpdate; |
135 | | - else |
136 | | - update_state = BNCUpdateStateNonUpdate; |
137 | | - |
| 114 | ++ (NSNumber *)appUpdateState { |
| 115 | + BNCUpdateState update_state = BNCUpdateStateUnknown; |
| 116 | + if ([BNCTuneUtility isTuneDataPresent]) { |
| 117 | + update_state = BNCUpdateStateTuneMigration; |
| 118 | + } |
138 | 119 | return @(update_state); |
139 | 120 | } |
140 | 121 |
|
|
0 commit comments