|
|
@@ -196,6 +196,7 @@
|
|
|
|
|
|
if (!self.uploadManager) {
|
|
|
self.uploadManager=[[RAUploadManager alloc] init];
|
|
|
+ self.uploadManager.maxRetry = 10;
|
|
|
}
|
|
|
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
|
|
|
|
|
|
@@ -297,16 +298,17 @@
|
|
|
|
|
|
NSString *orderID = [aps objectForKey:@"order-id"];
|
|
|
BOOL tracing = [[aps objectForKey:@"tracing"] boolValue];
|
|
|
+ NSString *locationId = [aps objectForKey:@"location-id"];
|
|
|
|
|
|
if (tracing) {
|
|
|
|
|
|
if (RASingleton.sharedInstance.backgroundReportType == RABackgroundReportTypeAllow) {
|
|
|
|
|
|
- [self reportLastLocation:[RASingleton sharedInstance].lastLocation forOrder:orderID];
|
|
|
+ [self reportLastLocation:[RASingleton sharedInstance].lastLocation forOrder:orderID locationID:locationId];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- [self rejectReportLocationWithReason:[NSString stringWithFormat:@"Driver %@ rejected to report location",RASingleton.sharedInstance.user] forOrder:orderID];
|
|
|
+ [self rejectReportLocationWithReason:[NSString stringWithFormat:@"Driver %@ rejected to report location",RASingleton.sharedInstance.user] forOrder:orderID locationID:locationId];
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
@@ -314,14 +316,14 @@
|
|
|
|
|
|
if (RASingleton.sharedInstance.backgroundReportType == RABackgroundReportTypeAllow) {
|
|
|
|
|
|
- [self reportLastLocation:[RASingleton sharedInstance].lastLocation forOrder:orderID];
|
|
|
+ [self reportLastLocation:[RASingleton sharedInstance].lastLocation forOrder:orderID locationID:locationId];
|
|
|
|
|
|
} else if (RASingleton.sharedInstance.backgroundReportType == RABackgroundReportTypeAlwaysAsk) {
|
|
|
|
|
|
- [self askForReportLastLocation:orderID];
|
|
|
+ [self askForReportLastLocation:orderID locationID:locationId];
|
|
|
} else if (RASingleton.sharedInstance.backgroundReportType == RABackgroundReportTypeReject) {
|
|
|
|
|
|
- [self rejectReportLocationWithReason:[NSString stringWithFormat:@"Driver %@ rejected to report location",RASingleton.sharedInstance.user] forOrder:orderID];
|
|
|
+ [self rejectReportLocationWithReason:[NSString stringWithFormat:@"Driver %@ rejected to report location",RASingleton.sharedInstance.user] forOrder:orderID locationID:locationId];
|
|
|
}
|
|
|
completionHandler(UIBackgroundFetchResultNewData);
|
|
|
} else {
|
|
|
@@ -386,68 +388,20 @@
|
|
|
|
|
|
#pragma mark - Report Location
|
|
|
|
|
|
-- (void)rejectReportLocationWithReason:(NSString *)reason forOrder:(NSString *)orderID {
|
|
|
+- (void)rejectReportLocationWithReason:(NSString *)reason forOrder:(NSString *)orderID locationID:(NSString *)locationId {
|
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
- [RADataProvider reportLocationWithUserReason:reason forOrder:orderID];
|
|
|
+ [RADataProvider reportLocationWithUserReason:reason forOrder:orderID locationID:locationId];
|
|
|
});
|
|
|
}
|
|
|
-- (void)reportLastLocation:(CLLocation *)location forOrder:(NSString *)orderID {
|
|
|
-
|
|
|
- NSString *latLon = nil;
|
|
|
- if (location) {
|
|
|
- latLon = [NSString stringWithFormat:@"%f,%f",location.coordinate.latitude,location.coordinate.longitude];
|
|
|
-
|
|
|
- } else {
|
|
|
- latLon = @"-999,-999";
|
|
|
- }
|
|
|
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
- [RADataProvider reportLastLocation:latLon forOrderID:orderID];
|
|
|
- });
|
|
|
-}
|
|
|
-- (void)reportLocation:(CLLocation *)location forOrder:(NSString *)orderID {
|
|
|
+
|
|
|
+- (void)reportLastLocation:(CLLocation *)location forOrder:(NSString *)orderID locationID:(NSString *)locationId {
|
|
|
|
|
|
- NSString *latLon = nil;
|
|
|
- if (location) {
|
|
|
- latLon = [NSString stringWithFormat:@"%f,%f",location.coordinate.latitude,location.coordinate.longitude];
|
|
|
-
|
|
|
- } else {
|
|
|
- latLon = @"-999,-999";
|
|
|
- }
|
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
- [RADataProvider reportCurrentLocation:latLon forOrderID:orderID];
|
|
|
+ [RADataProvider reportLastLocation:location forOrderID:orderID locationID:locationId];
|
|
|
});
|
|
|
}
|
|
|
-- (void)askForReportLastLocation:(NSString *)orderID {
|
|
|
-
|
|
|
- UIViewController *topVC = self.window.rootViewController;
|
|
|
- while (topVC.presentedViewController) {
|
|
|
- topVC = topVC.presentedViewController;
|
|
|
- }
|
|
|
-
|
|
|
- if (topVC) {
|
|
|
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"Report Location For Order:%@",orderID] preferredStyle:UIAlertControllerStyleAlert];
|
|
|
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
-
|
|
|
- [self rejectReportLocationWithReason:[NSString stringWithFormat:@"Driver %@ cancel to report location",RASingleton.sharedInstance.user] forOrder:orderID];
|
|
|
-
|
|
|
- }];
|
|
|
-
|
|
|
- __weak typeof(self) weakSelf = self;
|
|
|
- UIAlertAction *reportAction = [UIAlertAction actionWithTitle:@"Report" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
|
|
-
|
|
|
- [weakSelf reportLastLocation:[RASingleton sharedInstance].lastLocation forOrder:orderID];
|
|
|
-
|
|
|
- }];
|
|
|
-
|
|
|
- [alertVC addAction:cancelAction];
|
|
|
- [alertVC addAction:reportAction];
|
|
|
-
|
|
|
- [topVC presentViewController:alertVC animated:YES completion:nil];
|
|
|
-
|
|
|
- [self sendLocalNotification:@"Report Location Notification" message:[NSString stringWithFormat:@"The Apex ask your location for order:%@",orderID]];
|
|
|
- }
|
|
|
-}
|
|
|
-- (void)reportLocationWithOrder:(NSString *)orderID {
|
|
|
+
|
|
|
+- (void)askForReportLastLocation:(NSString *)orderID locationID:(NSString *)locationId{
|
|
|
|
|
|
UIViewController *topVC = self.window.rootViewController;
|
|
|
while (topVC.presentedViewController) {
|
|
|
@@ -458,14 +412,14 @@
|
|
|
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"Report Location For Order:%@",orderID] preferredStyle:UIAlertControllerStyleAlert];
|
|
|
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
- [self rejectReportLocationWithReason:[NSString stringWithFormat:@"Driver %@ cancel to report location",RASingleton.sharedInstance.user] forOrder:orderID];
|
|
|
+ [self rejectReportLocationWithReason:[NSString stringWithFormat:@"Driver %@ cancel to report location",RASingleton.sharedInstance.user] forOrder:orderID locationID:locationId];
|
|
|
|
|
|
}];
|
|
|
|
|
|
__weak typeof(self) weakSelf = self;
|
|
|
UIAlertAction *reportAction = [UIAlertAction actionWithTitle:@"Report" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
- [weakSelf reportLocation:[RASingleton sharedInstance].currentLocation forOrder:orderID];
|
|
|
+ [weakSelf reportLastLocation:[RASingleton sharedInstance].lastLocation forOrder:orderID locationID:locationId];
|
|
|
|
|
|
}];
|
|
|
|