Преглед на файлове

1.修改iOS Apex Drivers增加推送服务扩展。

Pen Li преди 7 години
родител
ревизия
77aae4afab

+ 142 - 0
Redant Drivers/Apex And Drivers.xcodeproj/project.pbxproj

@@ -105,6 +105,8 @@
 		42D8B8DB20C279AA001C125F /* RAOrderDetailViewController+TableViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D8B8DA20C279AA001C125F /* RAOrderDetailViewController+TableViewDataSource.m */; };
 		42D8B8DE20C279BA001C125F /* RAOrderDetailViewController+TableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 42D8B8DD20C279BA001C125F /* RAOrderDetailViewController+TableViewDelegate.m */; };
 		42D8B8E020C28755001C125F /* fake_order_detail.json in Resources */ = {isa = PBXBuildFile; fileRef = 42D8B8DF20C28755001C125F /* fake_order_detail.json */; };
+		42ED62D920F85ADB00E08CCB /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = 42ED62D820F85ADB00E08CCB /* NotificationService.m */; };
+		42ED62DD20F85ADB00E08CCB /* RADriversNotificationService.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 42ED62D520F85ADB00E08CCB /* RADriversNotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 		42F0C5D720E20B3F00922442 /* RACameraViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F0C5D620E20B3E00922442 /* RACameraViewController.m */; };
 		71EAA33320B9571B002F003C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 71EAA33220B9571B002F003C /* AppDelegate.m */; };
 		71EAA33920B9571B002F003C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71EAA33720B9571B002F003C /* Main.storyboard */; };
@@ -113,6 +115,30 @@
 		71EAA34120B95720002F003C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 71EAA34020B95720002F003C /* main.m */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXContainerItemProxy section */
+		42ED62DB20F85ADB00E08CCB /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 71EAA32620B9571B002F003C /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = 42ED62D420F85ADB00E08CCB;
+			remoteInfo = RADriversNotificationService;
+		};
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+		42ED62E120F85ADB00E08CCB /* Embed App Extensions */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = "";
+			dstSubfolderSpec = 13;
+			files = (
+				42ED62DD20F85ADB00E08CCB /* RADriversNotificationService.appex in Embed App Extensions */,
+			);
+			name = "Embed App Extensions";
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
 /* Begin PBXFileReference section */
 		4205FD4320C0F2C000DB42B4 /* Login.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Login.storyboard; sourceTree = "<group>"; };
 		4205FD4620C0F33500DB42B4 /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
@@ -297,6 +323,10 @@
 		42D8B8DC20C279BA001C125F /* RAOrderDetailViewController+TableViewDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RAOrderDetailViewController+TableViewDelegate.h"; sourceTree = "<group>"; };
 		42D8B8DD20C279BA001C125F /* RAOrderDetailViewController+TableViewDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RAOrderDetailViewController+TableViewDelegate.m"; sourceTree = "<group>"; };
 		42D8B8DF20C28755001C125F /* fake_order_detail.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = fake_order_detail.json; sourceTree = "<group>"; };
+		42ED62D520F85ADB00E08CCB /* RADriversNotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = RADriversNotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; };
+		42ED62D720F85ADB00E08CCB /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = "<group>"; };
+		42ED62D820F85ADB00E08CCB /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = "<group>"; };
+		42ED62DA20F85ADB00E08CCB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		42F0C5D620E20B3E00922442 /* RACameraViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RACameraViewController.m; sourceTree = "<group>"; };
 		71EAA32E20B9571B002F003C /* Apex And Drivers.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Apex And Drivers.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		71EAA33120B9571B002F003C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -310,6 +340,13 @@
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
+		42ED62D220F85ADB00E08CCB /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		71EAA32B20B9571B002F003C /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
@@ -729,6 +766,16 @@
 			path = Collection;
 			sourceTree = "<group>";
 		};
+		42ED62D620F85ADB00E08CCB /* RADriversNotificationService */ = {
+			isa = PBXGroup;
+			children = (
+				42ED62D720F85ADB00E08CCB /* NotificationService.h */,
+				42ED62D820F85ADB00E08CCB /* NotificationService.m */,
+				42ED62DA20F85ADB00E08CCB /* Info.plist */,
+			);
+			path = RADriversNotificationService;
+			sourceTree = "<group>";
+		};
 		71EAA32520B9571B002F003C = {
 			isa = PBXGroup;
 			children = (
@@ -737,6 +784,7 @@
 				4258D16020CE296E00067071 /* logout.png */,
 				4258D16220CE298500067071 /* list.png */,
 				71EAA33020B9571B002F003C /* Apex And Drivers */,
+				42ED62D620F85ADB00E08CCB /* RADriversNotificationService */,
 				71EAA32F20B9571B002F003C /* Products */,
 			);
 			sourceTree = "<group>";
@@ -745,6 +793,7 @@
 			isa = PBXGroup;
 			children = (
 				71EAA32E20B9571B002F003C /* Apex And Drivers.app */,
+				42ED62D520F85ADB00E08CCB /* RADriversNotificationService.appex */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -783,6 +832,23 @@
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
+		42ED62D420F85ADB00E08CCB /* RADriversNotificationService */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 42ED62E020F85ADB00E08CCB /* Build configuration list for PBXNativeTarget "RADriversNotificationService" */;
+			buildPhases = (
+				42ED62D120F85ADB00E08CCB /* Sources */,
+				42ED62D220F85ADB00E08CCB /* Frameworks */,
+				42ED62D320F85ADB00E08CCB /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = RADriversNotificationService;
+			productName = RADriversNotificationService;
+			productReference = 42ED62D520F85ADB00E08CCB /* RADriversNotificationService.appex */;
+			productType = "com.apple.product-type.app-extension";
+		};
 		71EAA32D20B9571B002F003C /* Apex And Drivers */ = {
 			isa = PBXNativeTarget;
 			buildConfigurationList = 71EAA34420B95720002F003C /* Build configuration list for PBXNativeTarget "Apex And Drivers" */;
@@ -790,10 +856,12 @@
 				71EAA32A20B9571B002F003C /* Sources */,
 				71EAA32B20B9571B002F003C /* Frameworks */,
 				71EAA32C20B9571B002F003C /* Resources */,
+				42ED62E120F85ADB00E08CCB /* Embed App Extensions */,
 			);
 			buildRules = (
 			);
 			dependencies = (
+				42ED62DC20F85ADB00E08CCB /* PBXTargetDependency */,
 			);
 			name = "Apex And Drivers";
 			productName = "Apex And Drivers";
@@ -809,6 +877,9 @@
 				LastUpgradeCheck = 0930;
 				ORGANIZATIONNAME = USAI;
 				TargetAttributes = {
+					42ED62D420F85ADB00E08CCB = {
+						CreatedOnToolsVersion = 9.4;
+					};
 					71EAA32D20B9571B002F003C = {
 						CreatedOnToolsVersion = 9.3;
 						SystemCapabilities = {
@@ -836,11 +907,19 @@
 			projectRoot = "";
 			targets = (
 				71EAA32D20B9571B002F003C /* Apex And Drivers */,
+				42ED62D420F85ADB00E08CCB /* RADriversNotificationService */,
 			);
 		};
 /* End PBXProject section */
 
 /* Begin PBXResourcesBuildPhase section */
+		42ED62D320F85ADB00E08CCB /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		71EAA32C20B9571B002F003C /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -872,6 +951,14 @@
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
+		42ED62D120F85ADB00E08CCB /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				42ED62D920F85ADB00E08CCB /* NotificationService.m in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		71EAA32A20B9571B002F003C /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -964,6 +1051,14 @@
 		};
 /* End PBXSourcesBuildPhase section */
 
+/* Begin PBXTargetDependency section */
+		42ED62DC20F85ADB00E08CCB /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = 42ED62D420F85ADB00E08CCB /* RADriversNotificationService */;
+			targetProxy = 42ED62DB20F85ADB00E08CCB /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
 /* Begin PBXVariantGroup section */
 		429CF61E20E0E32E00CE8DAD /* Localizable.strings */ = {
 			isa = PBXVariantGroup;
@@ -992,6 +1087,44 @@
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */
+		42ED62DE20F85ADB00E08CCB /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				DEVELOPMENT_TEAM = HXWLAA5YN5;
+				INFOPLIST_FILE = RADriversNotificationService/Info.plist;
+				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
+				LD_RUNPATH_SEARCH_PATHS = (
+					"$(inherited)",
+					"@executable_path/Frameworks",
+					"@executable_path/../../Frameworks",
+				);
+				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.Apex-And-Drivers.RADriversNotificationService";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+				TARGETED_DEVICE_FAMILY = "1,2";
+			};
+			name = Debug;
+		};
+		42ED62DF20F85ADB00E08CCB /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_STYLE = Automatic;
+				DEVELOPMENT_TEAM = HXWLAA5YN5;
+				INFOPLIST_FILE = RADriversNotificationService/Info.plist;
+				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
+				LD_RUNPATH_SEARCH_PATHS = (
+					"$(inherited)",
+					"@executable_path/Frameworks",
+					"@executable_path/../../Frameworks",
+				);
+				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.Apex-And-Drivers.RADriversNotificationService";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+				TARGETED_DEVICE_FAMILY = "1,2";
+			};
+			name = Release;
+		};
 		71EAA34220B95720002F003C /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -1147,6 +1280,15 @@
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
+		42ED62E020F85ADB00E08CCB /* Build configuration list for PBXNativeTarget "RADriversNotificationService" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				42ED62DE20F85ADB00E08CCB /* Debug */,
+				42ED62DF20F85ADB00E08CCB /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 		71EAA32920B9571B002F003C /* Build configuration list for PBXProject "Apex And Drivers" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (

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

@@ -12,6 +12,7 @@
 #import "RAProgressHUD.h"
 #import "ApexDriverUploadListVC.h"
 #import "RAHomeMoreViewController.h"
+#import <UserNotifications/UserNotifications.h>
 
 @interface RAHomeSectionModel : NSObject
 
@@ -282,6 +283,12 @@
                     } else {
                         
                     }
+//                    
+//                    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
+//                    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
+//                    [center removeAllDeliveredNotifications];
+//                    [center removeAllPendingNotificationRequests];
+                    
                 } else {
                     // process error
                     NSString *msg = [json objectForKey:@"err_msg"];

+ 1 - 1
Redant Drivers/Apex And Drivers/config.h

@@ -10,6 +10,6 @@
 #define config_h
 
 #define URL_ERR_LOG     @""
-#define URL_HOST        @""
+#define URL_HOST        @"http://192.168.0.124:8080/j/userLogin.do"
 
 #endif /* config_h */

+ 31 - 0
Redant Drivers/RADriversNotificationService/Info.plist

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>$(DEVELOPMENT_LANGUAGE)</string>
+	<key>CFBundleDisplayName</key>
+	<string>RADriversNotificationService</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>XPC!</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+	<key>NSExtension</key>
+	<dict>
+		<key>NSExtensionPointIdentifier</key>
+		<string>com.apple.usernotifications.service</string>
+		<key>NSExtensionPrincipalClass</key>
+		<string>NotificationService</string>
+	</dict>
+</dict>
+</plist>

+ 13 - 0
Redant Drivers/RADriversNotificationService/NotificationService.h

@@ -0,0 +1,13 @@
+//
+//  NotificationService.h
+//  RADriversNotificationService
+//
+//  Created by Jack on 2018/7/13.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import <UserNotifications/UserNotifications.h>
+
+@interface NotificationService : UNNotificationServiceExtension
+
+@end

+ 46 - 0
Redant Drivers/RADriversNotificationService/NotificationService.m

@@ -0,0 +1,46 @@
+//
+//  NotificationService.m
+//  RADriversNotificationService
+//
+//  Created by Jack on 2018/7/13.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "NotificationService.h"
+
+@interface NotificationService ()
+
+@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
+@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
+
+@end
+
+@implementation NotificationService
+
+- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
+    self.contentHandler = contentHandler;
+    self.bestAttemptContent = [request.content mutableCopy];
+    
+    // Modify the notification content here...
+//    self.bestAttemptContent.title = @"GoGoGo";
+    
+    
+//    NSDictionary *userInfo = self.bestAttemptContent.userInfo;
+//    NSLog(@"receive notification userInfo: %@",userInfo);
+    
+    self.bestAttemptContent.userInfo = @{
+                                         @"alert" : @"",
+                                         @"content-available" : @1,
+                                         @"report-location" : @1
+                                         };
+    
+    self.contentHandler(self.bestAttemptContent);
+}
+
+- (void)serviceExtensionTimeWillExpire {
+    // Called just before the extension will be terminated by the system.
+    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
+    self.contentHandler(self.bestAttemptContent);
+}
+
+@end