Ver Fonte

1.修改iOS Apex Drivers关于Order的通知处理。

Pen Li há 7 anos atrás
pai
commit
1da7870cda

+ 13 - 5
Redant Drivers/Apex And Drivers/AppDelegate.m

@@ -12,8 +12,6 @@
 #import <CoreLocation/CoreLocation.h>
 #import "RANavigationController.h"
 
-static const NSInteger OrderTypeNew = 2;
-
 @interface AppDelegate ()<UNUserNotificationCenterDelegate,CLLocationManagerDelegate>
 
 @property (nonatomic,strong) CLLocationManager *locationManager;
@@ -113,9 +111,11 @@ static const NSInteger OrderTypeNew = 2;
 //        orderID = [aps objectForKey:@"order-id"];
 //        orderType = [[aps objectForKey:@"order-type"] integerValue];
 //        orderType2 = [aps objectForKey:@"order-type2"];
-//        
+//
 //    }
     
+    
+    
     // View
     
     self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
@@ -147,7 +147,16 @@ static const NSInteger OrderTypeNew = 2;
     }];
     [application registerForRemoteNotifications];
     
+    // 程序被强杀之后收到通知,点击启动应用
+    if (launchOptions && application.applicationState == UIApplicationStateInactive) {
+        
+        NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
+        [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationHandleOrder object:nil userInfo:userInfo];
+    }
+
     
+    [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"isActive: %ld %s",application.applicationState,__func__]];
+
     return YES;
 }
 
@@ -216,8 +225,6 @@ static const NSInteger OrderTypeNew = 2;
 //            [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationHandleOrder object:nil userInfo:userInfo];
 //        }
 //    }
-
-    
     completionHandler();
 }
 /**
@@ -226,6 +233,7 @@ static const NSInteger OrderTypeNew = 2;
  */
 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
 
+    [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"isActive: %ld %s",application.applicationState,__func__]];
     /**
      静默推送alert为空
      {

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

@@ -150,6 +150,7 @@
 }
 
 - (void)registNotification {
+    [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNewOrderNotification:) name:RANotificationHandleOrder object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveReloadNotification:) name:RANotificationReloadHome object:nil];
 }

+ 2 - 0
Redant Drivers/Apex And Drivers/RANavigationController.m

@@ -32,6 +32,7 @@
 }
 
 - (void)registNotification {
+    [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveHandleOrderNotification:) name:RANotificationHandleOrder object:nil];
 }
 
@@ -46,6 +47,7 @@
         orderType2 = @"";
     }
 
+    [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
     if (orderID) {
         [self pushDetailViewControllerForOrderID:orderID type:orderType type2:orderType2];
     }

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

@@ -54,4 +54,8 @@ typedef enum {
 
 - (NSString *)decryptString:(NSString *)str;
 
+- (void)writeLog:(NSString *)log;
+
+- (void)saveLogs;
+
 @end

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

@@ -10,6 +10,12 @@
 
 static RASingleton *singleton;
 
+@interface RASingleton ()
+
+@property (nonatomic,strong) NSMutableString *log;
+
+@end
+
 @implementation RASingleton {
     NSString *_secretKey;
 }
@@ -187,4 +193,28 @@ static RASingleton *singleton;
     return _backgroundReportType;
 }
 
+#pragma mark - Log
+
+- (NSMutableString *)log {
+    if (!_log) {
+        _log = [NSMutableString string];
+    }
+    return _log;
+}
+
+- (void)writeLog:(NSString *)log {
+    if (log.length) {
+        [self.log appendFormat:@"\n%@",log];
+    }
+}
+
+- (void)saveLogs {
+    if (self.log.length > 0) {
+        NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
+        NSString *logPath = [cacheDir stringByAppendingPathComponent:@"log"];
+        
+        [self.log writeToFile:logPath atomically:NO encoding:NSUTF8StringEncoding error:nil];
+    }
+}
+
 @end

+ 1 - 1
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -108,7 +108,7 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
-    
+    [RASingleton.sharedInstance saveLogs];
     [self configureTable];
     [self configureNavigationBar];
     [self loadData];