|
@@ -10,6 +10,7 @@
|
|
|
#import "LoginViewController.h"
|
|
#import "LoginViewController.h"
|
|
|
#import "RAHomeViewController.h"
|
|
#import "RAHomeViewController.h"
|
|
|
#import <CoreLocation/CoreLocation.h>
|
|
#import <CoreLocation/CoreLocation.h>
|
|
|
|
|
+#import "RANavigationController.h"
|
|
|
|
|
|
|
|
static const NSInteger OrderTypeNew = 2;
|
|
static const NSInteger OrderTypeNew = 2;
|
|
|
|
|
|
|
@@ -23,13 +24,10 @@ static const NSInteger OrderTypeNew = 2;
|
|
|
|
|
|
|
|
#pragma mark - Private
|
|
#pragma mark - Private
|
|
|
|
|
|
|
|
-- (void)showHomeVCWithOrderID:(NSString *)orderID type:(NSInteger)type type2:(NSString *)type2 {
|
|
|
|
|
|
|
+- (void)showHomeVC{
|
|
|
|
|
|
|
|
RAHomeViewController *homeVC = [RAHomeViewController viewControllerFromStoryboard];
|
|
RAHomeViewController *homeVC = [RAHomeViewController viewControllerFromStoryboard];
|
|
|
- homeVC.gotoDetailID = orderID;
|
|
|
|
|
- homeVC.gotoDetailType = type;
|
|
|
|
|
- homeVC.gotoDetailType2 = type2;
|
|
|
|
|
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:homeVC];
|
|
|
|
|
|
|
+ RANavigationController *nav = [[RANavigationController alloc] initWithRootViewController:homeVC];
|
|
|
self.window.rootViewController = nav;
|
|
self.window.rootViewController = nav;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -42,7 +40,7 @@ static const NSInteger OrderTypeNew = 2;
|
|
|
|
|
|
|
|
[[RASingleton sharedInstance] loginUser:user password:password];
|
|
[[RASingleton sharedInstance] loginUser:user password:password];
|
|
|
|
|
|
|
|
- [weakSelf showHomeVCWithOrderID:nil type:OrderTypeNew type2:nil];
|
|
|
|
|
|
|
+ [weakSelf showHomeVC];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
|
|
@@ -106,17 +104,17 @@ static const NSInteger OrderTypeNew = 2;
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
// Override point for customization after application launch.
|
|
// Override point for customization after application launch.
|
|
|
|
|
|
|
|
- NSString *orderID = nil;
|
|
|
|
|
- NSInteger orderType = OrderTypeNew;
|
|
|
|
|
- NSString *orderType2 = nil;
|
|
|
|
|
- if (launchOptions) {
|
|
|
|
|
- NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
|
|
|
|
- NSDictionary *aps = [userInfo objectForKey:@"aps"];
|
|
|
|
|
- orderID = [aps objectForKey:@"order-id"];
|
|
|
|
|
- orderType = [[aps objectForKey:@"order-type"] integerValue];
|
|
|
|
|
- orderType2 = [aps objectForKey:@"order-type2"];
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// NSString *orderID = nil;
|
|
|
|
|
+// NSInteger orderType = OrderTypeNew;
|
|
|
|
|
+// NSString *orderType2 = nil;
|
|
|
|
|
+// if (launchOptions) {
|
|
|
|
|
+// NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
|
|
|
|
+// NSDictionary *aps = [userInfo objectForKey:@"aps"];
|
|
|
|
|
+// orderID = [aps objectForKey:@"order-id"];
|
|
|
|
|
+// orderType = [[aps objectForKey:@"order-type"] integerValue];
|
|
|
|
|
+// orderType2 = [aps objectForKey:@"order-type2"];
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// View
|
|
// View
|
|
|
|
|
|
|
@@ -124,7 +122,7 @@ static const NSInteger OrderTypeNew = 2;
|
|
|
self.window.backgroundColor = [UIColor whiteColor];
|
|
self.window.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
if (RASingleton.sharedInstance.autoLogin) {
|
|
if (RASingleton.sharedInstance.autoLogin) {
|
|
|
- [self showHomeVCWithOrderID:orderID type:orderType type2:orderType2];
|
|
|
|
|
|
|
+ [self showHomeVC];
|
|
|
} else {
|
|
} else {
|
|
|
[self showLoginVC];
|
|
[self showLoginVC];
|
|
|
}
|
|
}
|
|
@@ -207,21 +205,25 @@ static const NSInteger OrderTypeNew = 2;
|
|
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
|
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
|
|
|
NSLog(@"接收到推送内容==%@", response.notification.request.content.userInfo);
|
|
NSLog(@"接收到推送内容==%@", response.notification.request.content.userInfo);
|
|
|
// 点击通知
|
|
// 点击通知
|
|
|
- NSDictionary *userInfo = response.notification.request.content.userInfo;
|
|
|
|
|
- NSDictionary *aps = [userInfo objectForKey:@"aps"];
|
|
|
|
|
- NSString *orderID = [aps objectForKey:@"order-id"];
|
|
|
|
|
- NSInteger orderType = [[aps objectForKey:@"order-type"] integerValue];
|
|
|
|
|
- NSString *orderType2 = [aps objectForKey:@"order-type2"];
|
|
|
|
|
- if (!orderType2) {
|
|
|
|
|
- orderType2 = @"";
|
|
|
|
|
- }
|
|
|
|
|
- if (orderID) {
|
|
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationGoDetail object:@{@"orderID" : orderID,@"orderType" : @(orderType),@"orderType2" : orderType2}];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+// NSDictionary *userInfo = response.notification.request.content.userInfo;
|
|
|
|
|
+// if (userInfo) {
|
|
|
|
|
+//
|
|
|
|
|
+// NSDictionary *aps = [userInfo objectForKey:@"aps"];
|
|
|
|
|
+//
|
|
|
|
|
+// NSInteger is_order = [[aps objectForKey:@"is-order"] integerValue];
|
|
|
|
|
+// if (is_order) {
|
|
|
|
|
+// [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationHandleOrder object:nil userInfo:userInfo];
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
completionHandler();
|
|
completionHandler();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ 程序处于非运行状态时,收到通知,点击Icon运行程序会调用此方法
|
|
|
|
|
+ 程序处于运行状态或后台,收到通知也会调用此方法。
|
|
|
|
|
+ */
|
|
|
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -260,7 +262,7 @@ static const NSInteger OrderTypeNew = 2;
|
|
|
"title" : "Notification",
|
|
"title" : "Notification",
|
|
|
"body" : "You have a new order"
|
|
"body" : "You have a new order"
|
|
|
},
|
|
},
|
|
|
- "new-order" : 1,
|
|
|
|
|
|
|
+ "is-order" : 1,
|
|
|
"order-id" : "AFS20180530001200",
|
|
"order-id" : "AFS20180530001200",
|
|
|
"order-type2" : "Pick Up",
|
|
"order-type2" : "Pick Up",
|
|
|
"order-type" : 2,
|
|
"order-type" : 2,
|
|
@@ -270,10 +272,10 @@ static const NSInteger OrderTypeNew = 2;
|
|
|
}
|
|
}
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
- NSInteger new_order = [[aps objectForKey:@"new-order"] integerValue];
|
|
|
|
|
- if (new_order) {
|
|
|
|
|
|
|
+ NSInteger is_order = [[aps objectForKey:@"is-order"] integerValue];
|
|
|
|
|
+ if (is_order) {
|
|
|
|
|
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationNewOrder object:nil];
|
|
|
|
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationHandleOrder object:nil userInfo:userInfo];
|
|
|
}
|
|
}
|
|
|
completionHandler(UIBackgroundFetchResultNewData);
|
|
completionHandler(UIBackgroundFetchResultNewData);
|
|
|
}
|
|
}
|