|
@@ -21,9 +21,10 @@
|
|
|
|
|
|
|
|
#pragma mark - Private
|
|
#pragma mark - Private
|
|
|
|
|
|
|
|
-- (void)showHomeVC {
|
|
|
|
|
|
|
+- (void)showHomeVCWithOrderID:(NSString *)orderID {
|
|
|
|
|
|
|
|
RAHomeViewController *homeVC = [RAHomeViewController viewControllerFromStoryboard];
|
|
RAHomeViewController *homeVC = [RAHomeViewController viewControllerFromStoryboard];
|
|
|
|
|
+ homeVC.gotoDetailID = orderID;
|
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:homeVC];
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:homeVC];
|
|
|
self.window.rootViewController = nav;
|
|
self.window.rootViewController = nav;
|
|
|
}
|
|
}
|
|
@@ -35,11 +36,9 @@
|
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
|
rootVC.loginSuccessful = ^(NSString *user,NSString *password){
|
|
rootVC.loginSuccessful = ^(NSString *user,NSString *password){
|
|
|
|
|
|
|
|
- RASingleton.sharedInstance.user = user;
|
|
|
|
|
- RASingleton.sharedInstance.password = password;
|
|
|
|
|
- [RASingleton.sharedInstance saveUserInfo];
|
|
|
|
|
|
|
+ [[RASingleton sharedInstance] loginUser:user password:password];
|
|
|
|
|
|
|
|
- [weakSelf showHomeVC];
|
|
|
|
|
|
|
+ [weakSelf showHomeVCWithOrderID:nil];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
|
|
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
|
|
@@ -103,12 +102,23 @@
|
|
|
- (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;
|
|
|
|
|
+ if (launchOptions) {
|
|
|
|
|
+ NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
|
|
|
|
+ NSDictionary *aps = [userInfo objectForKey:@"aps"];
|
|
|
|
|
+ orderID = [aps objectForKey:@"order-id"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// View
|
|
// View
|
|
|
|
|
|
|
|
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
|
|
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
|
|
|
self.window.backgroundColor = [UIColor whiteColor];
|
|
self.window.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
- [self showLoginVC];
|
|
|
|
|
|
|
+ if (RASingleton.sharedInstance.autoLogin) {
|
|
|
|
|
+ [self showHomeVCWithOrderID:orderID];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [self showLoginVC];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
[self.window makeKeyAndVisible];
|
|
[self.window makeKeyAndVisible];
|
|
|
|
|
|
|
@@ -130,6 +140,7 @@
|
|
|
}];
|
|
}];
|
|
|
[application registerForRemoteNotifications];
|
|
[application registerForRemoteNotifications];
|
|
|
|
|
|
|
|
|
|
+
|
|
|
return YES;
|
|
return YES;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -154,6 +165,8 @@
|
|
|
NSLog(@"fullstr= %@",fullStr);
|
|
NSLog(@"fullstr= %@",fullStr);
|
|
|
NSString *deviceTokenStr = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<" withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""];
|
|
NSString *deviceTokenStr = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<" withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""];
|
|
|
NSLog(@"deviceTokenStr:\n%@",deviceTokenStr);
|
|
NSLog(@"deviceTokenStr:\n%@",deviceTokenStr);
|
|
|
|
|
+
|
|
|
|
|
+ [[RASingleton sharedInstance] setNotificationToken:deviceTokenStr];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
|
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
|
@@ -180,6 +193,13 @@
|
|
|
- (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"];
|
|
|
|
|
+ if (orderID) {
|
|
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationGoDetail object:@{@"orderID" : orderID}];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
completionHandler();
|
|
completionHandler();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -214,6 +234,7 @@
|
|
|
"body" : "You have a new order"
|
|
"body" : "You have a new order"
|
|
|
},
|
|
},
|
|
|
"new-order" : 1,
|
|
"new-order" : 1,
|
|
|
|
|
+ "order-id" : "AFS20180530001200",
|
|
|
"sound" : "default",
|
|
"sound" : "default",
|
|
|
"content-available" : 1
|
|
"content-available" : 1
|
|
|
}
|
|
}
|