Jelajahi Sumber

1.修改iOS Apex Drivers定位开启与关闭处理。

Pen Li 7 tahun lalu
induk
melakukan
1d54a205a1

+ 15 - 1
Redant Drivers/Apex And Drivers/AppDelegate.m

@@ -92,9 +92,19 @@
     [self showLoginVC];
 }
 
+- (void)receiveStartLocationNotification:(NSNotification *)notification {
+    [self startLocation];
+}
+
+- (void)receiveStopLocationNotification:(NSNotification *)notification {
+    [self stopLocation];
+}
+
 - (void)registActionNotification {
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveLogoutNotification:) name:RANotificationLogout object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveStartLocationNotification:) name:RANotificationStartLocation object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveStopLocationNotification:) name:RANotificationStopLocation object:nil];
 }
 
 #pragma mark - AppDelegate
@@ -122,7 +132,7 @@
     
     [self.window makeKeyAndVisible];
     
-    [self startLocation];
+    [RASingleton.sharedInstance loadSavedReuqiredLocation];
     
     //
     [self registActionNotification];
@@ -156,6 +166,10 @@
     [self saveUploadTasks];
 }
 
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
 #pragma mark - Notification
 
 //完成注册后收到devicetoken

+ 3 - 1
Redant Drivers/Apex And Drivers/Detail/Model/Collection/RADetailActionModel.h

@@ -14,7 +14,9 @@ typedef enum {
 } RADetailActionType;
 
 typedef enum {
-    RADetailActionSubTypeEnum = 0
+    RADetailActionSubTypeEnum = 0,
+    RADetailActionSubTypeAccept = 1,
+    RADetailActionSubTypeReject = 2,
 } RADetailActionSubType;
 
 @class RADetailActionSelectionModel;

+ 4 - 0
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -201,6 +201,10 @@
                 int result = [[json objectForKey:@"result"] intValue];
                 if (result == RESULT_TRUE) {
                     
+                    if (model.actionSubType == RADetailActionSubTypeAccept) {
+                        RASingleton.sharedInstance.requiredLocation = YES;
+                    }
+                    
                     [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationReloadHome object:nil];
                     [strongSelf.navigationController popToRootViewControllerAnimated:YES];
                     

+ 2 - 0
Redant Drivers/Apex And Drivers/FakeData/fake_order_detail.json

@@ -49,6 +49,7 @@
                                         {
                                         "actionType": "0",
                                         "actionTitle": "Reject",
+                                        "actionSubType": "2",
                                         "url": "",
                                         "params": {
                                         "action": "reject",
@@ -57,6 +58,7 @@
                                         },
                                         {
                                         "actionType": "0",
+                                        "actionSubType": "1",
                                         "actionTitle": "Accept",
                                         "url": "",
                                         "params": {

+ 3 - 0
Redant Drivers/Apex And Drivers/Home/RAHomeViewController.m

@@ -254,6 +254,9 @@
                 int result = [[json objectForKey:@"result"] intValue];
                 if (result == RESULT_TRUE) {
                     
+                    BOOL requiredLocation = [[json objectForKey:@"requiredLocation"] boolValue];
+                    [RASingleton sharedInstance].requiredLocation = requiredLocation;
+                    
                     NSArray *sectionArray = [json objectForKey:@"sections"];
                     [strongSelf.sectionArray removeAllObjects];
                     strongSelf.currentIndexPath = nil;

+ 2 - 0
Redant Drivers/Apex And Drivers/RANotificationNameCenter.h

@@ -13,3 +13,5 @@ FOUNDATION_EXTERN NSString * const RANotificationNewOrder;
 FOUNDATION_EXTERN NSString * const RANotificationReloadHome;
 FOUNDATION_EXTERN NSString * const RANotificationLogout;
 FOUNDATION_EXTERN NSString * const RANotificationGoDetail;
+FOUNDATION_EXTERN NSString * const RANotificationStopLocation;
+FOUNDATION_EXTERN NSString * const RANotificationStartLocation;

+ 6 - 4
Redant Drivers/Apex And Drivers/RANotificationNameCenter.m

@@ -9,7 +9,9 @@
 #import "RANotificationNameCenter.h"
 
 
-NSString * const RANotificationNewOrder     = @"RANotificationNewOrder";
-NSString * const RANotificationReloadHome   = @"RANotificationReloadHome";
-NSString * const RANotificationLogout       = @"RANotificationLogout";
-NSString * const RANotificationGoDetail     = @"RANotificationGoDetail";
+NSString * const RANotificationNewOrder         = @"RANotificationNewOrder";
+NSString * const RANotificationReloadHome       = @"RANotificationReloadHome";
+NSString * const RANotificationLogout           = @"RANotificationLogout";
+NSString * const RANotificationGoDetail         = @"RANotificationGoDetail";
+NSString * const RANotificationStartLocation    = @"RANotificationStartLocation";
+NSString * const RANotificationStopLocation     = @"RANotificationStopLocation";

+ 3 - 0
Redant Drivers/Apex And Drivers/RASingleton.h

@@ -22,6 +22,7 @@
 @property (nonatomic,copy,readonly) NSString *encryptPassword;
 
 @property (nonatomic,copy) NSString *notificationToken;
+@property (nonatomic,assign) BOOL requiredLocation;
 
 - (void)saveUserInfo;
 
@@ -35,4 +36,6 @@
 
 - (void)logout;
 
+- (void)loadSavedReuqiredLocation;
+
 @end

+ 31 - 0
Redant Drivers/Apex And Drivers/RASingleton.m

@@ -24,6 +24,8 @@ static RASingleton *singleton;
     return singleton;
 }
 
+#pragma mark - User
+
 - (NSString *)secretKey {
     return _secretKey;
 }
@@ -107,6 +109,35 @@ static RASingleton *singleton;
     [defaults synchronize];
 }
 
+#pragma mark - Location
+
+- (void)setRequiredLocation:(BOOL)requiredLocation {
+    _requiredLocation = requiredLocation;
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    [defaults setBool:_requiredLocation forKey:@"requiredLocation"];
+    [defaults synchronize];
+    
+    [self sendRequiredLocationNotification];
+}
+
+- (void)loadSavedReuqiredLocation { // 启动的时候
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    _requiredLocation = [defaults objectForKey:@"requiredLocation"];
+    
+    [self sendRequiredLocationNotification];
+}
+
+- (void)sendRequiredLocationNotification {
+    
+    if (_requiredLocation) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationStartLocation object:nil];
+    } else {
+        [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationStopLocation object:nil];
+    }
+    
+}
 
 
 @end

+ 3 - 0
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -277,6 +277,9 @@
             int result = [[json objectForKey:@"result"] intValue];
             if (result == RESULT_TRUE) {
                 
+                BOOL requiredLocation = [[json objectForKey:@"requiredLocation"] boolValue];
+                [RASingleton sharedInstance].requiredLocation = requiredLocation;
+                
                 [strongSelf syncUploadPhotos:photoArr Json:json HUD:nil];
                 
             } else {