Просмотр исходного кода

1.修改iOS Apex Drivers增加宿主程序和Extension之间数据共享。

Pen Li 7 лет назад
Родитель
Сommit
58039f052b

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

@@ -327,6 +327,7 @@
 		42ED62D720F85ADB00E08CCB /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = "<group>"; };
 		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>"; };
 		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>"; };
 		42ED62DA20F85ADB00E08CCB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		42ED62E220F88B1400E08CCB /* RADriversNotificationService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RADriversNotificationService.entitlements; sourceTree = "<group>"; };
 		42F0C5D620E20B3E00922442 /* RACameraViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RACameraViewController.m; 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; };
 		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>"; };
 		71EAA33120B9571B002F003C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -769,6 +770,7 @@
 		42ED62D620F85ADB00E08CCB /* RADriversNotificationService */ = {
 		42ED62D620F85ADB00E08CCB /* RADriversNotificationService */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				42ED62E220F88B1400E08CCB /* RADriversNotificationService.entitlements */,
 				42ED62D720F85ADB00E08CCB /* NotificationService.h */,
 				42ED62D720F85ADB00E08CCB /* NotificationService.h */,
 				42ED62D820F85ADB00E08CCB /* NotificationService.m */,
 				42ED62D820F85ADB00E08CCB /* NotificationService.m */,
 				42ED62DA20F85ADB00E08CCB /* Info.plist */,
 				42ED62DA20F85ADB00E08CCB /* Info.plist */,
@@ -879,10 +881,18 @@
 				TargetAttributes = {
 				TargetAttributes = {
 					42ED62D420F85ADB00E08CCB = {
 					42ED62D420F85ADB00E08CCB = {
 						CreatedOnToolsVersion = 9.4;
 						CreatedOnToolsVersion = 9.4;
+						SystemCapabilities = {
+							com.apple.ApplicationGroups.iOS = {
+								enabled = 1;
+							};
+						};
 					};
 					};
 					71EAA32D20B9571B002F003C = {
 					71EAA32D20B9571B002F003C = {
 						CreatedOnToolsVersion = 9.3;
 						CreatedOnToolsVersion = 9.3;
 						SystemCapabilities = {
 						SystemCapabilities = {
+							com.apple.ApplicationGroups.iOS = {
+								enabled = 1;
+							};
 							com.apple.BackgroundModes = {
 							com.apple.BackgroundModes = {
 								enabled = 1;
 								enabled = 1;
 							};
 							};
@@ -1090,6 +1100,7 @@
 		42ED62DE20F85ADB00E08CCB /* Debug */ = {
 		42ED62DE20F85ADB00E08CCB /* Debug */ = {
 			isa = XCBuildConfiguration;
 			isa = XCBuildConfiguration;
 			buildSettings = {
 			buildSettings = {
+				CODE_SIGN_ENTITLEMENTS = RADriversNotificationService/RADriversNotificationService.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				INFOPLIST_FILE = RADriversNotificationService/Info.plist;
 				INFOPLIST_FILE = RADriversNotificationService/Info.plist;
@@ -1109,6 +1120,7 @@
 		42ED62DF20F85ADB00E08CCB /* Release */ = {
 		42ED62DF20F85ADB00E08CCB /* Release */ = {
 			isa = XCBuildConfiguration;
 			isa = XCBuildConfiguration;
 			buildSettings = {
 			buildSettings = {
+				CODE_SIGN_ENTITLEMENTS = RADriversNotificationService/RADriversNotificationService.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				INFOPLIST_FILE = RADriversNotificationService/Info.plist;
 				INFOPLIST_FILE = RADriversNotificationService/Info.plist;

+ 4 - 0
Redant Drivers/Apex And Drivers/Apex And Drivers.entitlements

@@ -4,5 +4,9 @@
 <dict>
 <dict>
 	<key>aps-environment</key>
 	<key>aps-environment</key>
 	<string>development</string>
 	<string>development</string>
+	<key>com.apple.security.application-groups</key>
+	<array>
+		<string>group.radrivers</string>
+	</array>
 </dict>
 </dict>
 </plist>
 </plist>

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

@@ -150,6 +150,8 @@
     }];
     }];
     [application registerForRemoteNotifications];
     [application registerForRemoteNotifications];
     
     
+    NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.radrivers"];
+    [userDefaults setObject:@"Haha" forKey:@"test"];
     
     
     return YES;
     return YES;
 }
 }

+ 7 - 0
Redant Drivers/Apex And Drivers/Info.plist

@@ -56,5 +56,12 @@
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
 	</array>
+    
+    <key>NSAppTransportSecurity</key>
+    <dict>
+        <key>NSAllowsArbitraryLoads</key>
+        <true/>
+    </dict>
+    
 </dict>
 </dict>
 </plist>
 </plist>

+ 10 - 5
Redant Drivers/RADriversNotificationService/NotificationService.m

@@ -27,12 +27,17 @@
     
     
 //    NSDictionary *userInfo = self.bestAttemptContent.userInfo;
 //    NSDictionary *userInfo = self.bestAttemptContent.userInfo;
 //    NSLog(@"receive notification userInfo: %@",userInfo);
 //    NSLog(@"receive notification userInfo: %@",userInfo);
+//    
+//    self.bestAttemptContent.userInfo = @{
+//                                         @"alert" : @"",
+//                                         @"content-available" : @1,
+//                                         @"report-location" : @1
+//                                         };
     
     
-    self.bestAttemptContent.userInfo = @{
-                                         @"alert" : @"",
-                                         @"content-available" : @1,
-                                         @"report-location" : @1
-                                         };
+    NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.radrivers"];
+    NSString *obj = [userDefaults objectForKey:@"test"];
+    NSLog(@"obj: %@",obj);
+    self.bestAttemptContent.title = obj;
     
     
     self.contentHandler(self.bestAttemptContent);
     self.contentHandler(self.bestAttemptContent);
 }
 }

+ 10 - 0
Redant Drivers/RADriversNotificationService/RADriversNotificationService.entitlements

@@ -0,0 +1,10 @@
+<?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>com.apple.security.application-groups</key>
+	<array>
+		<string>group.radrivers</string>
+	</array>
+</dict>
+</plist>