├── LICENSE ├── NotificationExtensionDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── liuguangqiang.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── NotificationExtensionDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── NotificationSE ├── Info.plist ├── NotificationService.h └── NotificationService.m └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NotificationExtensionDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9CCDA13D214F54D1005914FE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CCDA13C214F54D1005914FE /* AppDelegate.m */; }; 11 | 9CCDA140214F54D1005914FE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CCDA13F214F54D1005914FE /* ViewController.m */; }; 12 | 9CCDA143214F54D1005914FE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9CCDA141214F54D1005914FE /* Main.storyboard */; }; 13 | 9CCDA145214F54D2005914FE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9CCDA144214F54D2005914FE /* Assets.xcassets */; }; 14 | 9CCDA148214F54D2005914FE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9CCDA146214F54D2005914FE /* LaunchScreen.storyboard */; }; 15 | 9CCDA14B214F54D2005914FE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CCDA14A214F54D2005914FE /* main.m */; }; 16 | 9CCDA159214F5614005914FE /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CCDA158214F5614005914FE /* NotificationService.m */; }; 17 | 9CCDA15D214F5614005914FE /* NotificationSE.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 9CCDA155214F5614005914FE /* NotificationSE.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 9CCDA15B214F5614005914FE /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 9CCDA130214F54D1005914FE /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 9CCDA154214F5614005914FE; 26 | remoteInfo = NotificationSE; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXCopyFilesBuildPhase section */ 31 | 9CCDA161214F5614005914FE /* Embed App Extensions */ = { 32 | isa = PBXCopyFilesBuildPhase; 33 | buildActionMask = 2147483647; 34 | dstPath = ""; 35 | dstSubfolderSpec = 13; 36 | files = ( 37 | 9CCDA15D214F5614005914FE /* NotificationSE.appex in Embed App Extensions */, 38 | ); 39 | name = "Embed App Extensions"; 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXCopyFilesBuildPhase section */ 43 | 44 | /* Begin PBXFileReference section */ 45 | 9CCDA138214F54D1005914FE /* NotificationExtensionDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NotificationExtensionDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 9CCDA13B214F54D1005914FE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 47 | 9CCDA13C214F54D1005914FE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 48 | 9CCDA13E214F54D1005914FE /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 49 | 9CCDA13F214F54D1005914FE /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 50 | 9CCDA142214F54D1005914FE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 51 | 9CCDA144214F54D2005914FE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 52 | 9CCDA147214F54D2005914FE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 53 | 9CCDA149214F54D2005914FE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 9CCDA14A214F54D2005914FE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 55 | 9CCDA155214F5614005914FE /* NotificationSE.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationSE.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 9CCDA157214F5614005914FE /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = ""; }; 57 | 9CCDA158214F5614005914FE /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = ""; }; 58 | 9CCDA15A214F5614005914FE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 9CCDA135214F54D1005914FE /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 9CCDA152214F5614005914FE /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | /* End PBXFrameworksBuildPhase section */ 77 | 78 | /* Begin PBXGroup section */ 79 | 9CCDA12F214F54D1005914FE = { 80 | isa = PBXGroup; 81 | children = ( 82 | 9CCDA13A214F54D1005914FE /* NotificationExtensionDemo */, 83 | 9CCDA156214F5614005914FE /* NotificationSE */, 84 | 9CCDA139214F54D1005914FE /* Products */, 85 | ); 86 | sourceTree = ""; 87 | }; 88 | 9CCDA139214F54D1005914FE /* Products */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 9CCDA138214F54D1005914FE /* NotificationExtensionDemo.app */, 92 | 9CCDA155214F5614005914FE /* NotificationSE.appex */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | 9CCDA13A214F54D1005914FE /* NotificationExtensionDemo */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 9CCDA13B214F54D1005914FE /* AppDelegate.h */, 101 | 9CCDA13C214F54D1005914FE /* AppDelegate.m */, 102 | 9CCDA13E214F54D1005914FE /* ViewController.h */, 103 | 9CCDA13F214F54D1005914FE /* ViewController.m */, 104 | 9CCDA141214F54D1005914FE /* Main.storyboard */, 105 | 9CCDA144214F54D2005914FE /* Assets.xcassets */, 106 | 9CCDA146214F54D2005914FE /* LaunchScreen.storyboard */, 107 | 9CCDA149214F54D2005914FE /* Info.plist */, 108 | 9CCDA14A214F54D2005914FE /* main.m */, 109 | ); 110 | path = NotificationExtensionDemo; 111 | sourceTree = ""; 112 | }; 113 | 9CCDA156214F5614005914FE /* NotificationSE */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 9CCDA157214F5614005914FE /* NotificationService.h */, 117 | 9CCDA158214F5614005914FE /* NotificationService.m */, 118 | 9CCDA15A214F5614005914FE /* Info.plist */, 119 | ); 120 | path = NotificationSE; 121 | sourceTree = ""; 122 | }; 123 | /* End PBXGroup section */ 124 | 125 | /* Begin PBXNativeTarget section */ 126 | 9CCDA137214F54D1005914FE /* NotificationExtensionDemo */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = 9CCDA14E214F54D2005914FE /* Build configuration list for PBXNativeTarget "NotificationExtensionDemo" */; 129 | buildPhases = ( 130 | 9CCDA134214F54D1005914FE /* Sources */, 131 | 9CCDA135214F54D1005914FE /* Frameworks */, 132 | 9CCDA136214F54D1005914FE /* Resources */, 133 | 9CCDA161214F5614005914FE /* Embed App Extensions */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | 9CCDA15C214F5614005914FE /* PBXTargetDependency */, 139 | ); 140 | name = NotificationExtensionDemo; 141 | productName = NotificationExtensionDemo; 142 | productReference = 9CCDA138214F54D1005914FE /* NotificationExtensionDemo.app */; 143 | productType = "com.apple.product-type.application"; 144 | }; 145 | 9CCDA154214F5614005914FE /* NotificationSE */ = { 146 | isa = PBXNativeTarget; 147 | buildConfigurationList = 9CCDA15E214F5614005914FE /* Build configuration list for PBXNativeTarget "NotificationSE" */; 148 | buildPhases = ( 149 | 9CCDA151214F5614005914FE /* Sources */, 150 | 9CCDA152214F5614005914FE /* Frameworks */, 151 | 9CCDA153214F5614005914FE /* Resources */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | ); 157 | name = NotificationSE; 158 | productName = NotificationSE; 159 | productReference = 9CCDA155214F5614005914FE /* NotificationSE.appex */; 160 | productType = "com.apple.product-type.app-extension"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | 9CCDA130214F54D1005914FE /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastUpgradeCheck = 0940; 169 | ORGANIZATIONNAME = quangqiang; 170 | TargetAttributes = { 171 | 9CCDA137214F54D1005914FE = { 172 | CreatedOnToolsVersion = 9.4.1; 173 | SystemCapabilities = { 174 | com.apple.BackgroundModes = { 175 | enabled = 1; 176 | }; 177 | }; 178 | }; 179 | 9CCDA154214F5614005914FE = { 180 | CreatedOnToolsVersion = 9.4.1; 181 | }; 182 | }; 183 | }; 184 | buildConfigurationList = 9CCDA133214F54D1005914FE /* Build configuration list for PBXProject "NotificationExtensionDemo" */; 185 | compatibilityVersion = "Xcode 9.3"; 186 | developmentRegion = en; 187 | hasScannedForEncodings = 0; 188 | knownRegions = ( 189 | en, 190 | Base, 191 | ); 192 | mainGroup = 9CCDA12F214F54D1005914FE; 193 | productRefGroup = 9CCDA139214F54D1005914FE /* Products */; 194 | projectDirPath = ""; 195 | projectRoot = ""; 196 | targets = ( 197 | 9CCDA137214F54D1005914FE /* NotificationExtensionDemo */, 198 | 9CCDA154214F5614005914FE /* NotificationSE */, 199 | ); 200 | }; 201 | /* End PBXProject section */ 202 | 203 | /* Begin PBXResourcesBuildPhase section */ 204 | 9CCDA136214F54D1005914FE /* Resources */ = { 205 | isa = PBXResourcesBuildPhase; 206 | buildActionMask = 2147483647; 207 | files = ( 208 | 9CCDA148214F54D2005914FE /* LaunchScreen.storyboard in Resources */, 209 | 9CCDA145214F54D2005914FE /* Assets.xcassets in Resources */, 210 | 9CCDA143214F54D1005914FE /* Main.storyboard in Resources */, 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | 9CCDA153214F5614005914FE /* Resources */ = { 215 | isa = PBXResourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXResourcesBuildPhase section */ 222 | 223 | /* Begin PBXSourcesBuildPhase section */ 224 | 9CCDA134214F54D1005914FE /* Sources */ = { 225 | isa = PBXSourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | 9CCDA140214F54D1005914FE /* ViewController.m in Sources */, 229 | 9CCDA14B214F54D2005914FE /* main.m in Sources */, 230 | 9CCDA13D214F54D1005914FE /* AppDelegate.m in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | 9CCDA151214F5614005914FE /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 9CCDA159214F5614005914FE /* NotificationService.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXTargetDependency section */ 245 | 9CCDA15C214F5614005914FE /* PBXTargetDependency */ = { 246 | isa = PBXTargetDependency; 247 | target = 9CCDA154214F5614005914FE /* NotificationSE */; 248 | targetProxy = 9CCDA15B214F5614005914FE /* PBXContainerItemProxy */; 249 | }; 250 | /* End PBXTargetDependency section */ 251 | 252 | /* Begin PBXVariantGroup section */ 253 | 9CCDA141214F54D1005914FE /* Main.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | 9CCDA142214F54D1005914FE /* Base */, 257 | ); 258 | name = Main.storyboard; 259 | sourceTree = ""; 260 | }; 261 | 9CCDA146214F54D2005914FE /* LaunchScreen.storyboard */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | 9CCDA147214F54D2005914FE /* Base */, 265 | ); 266 | name = LaunchScreen.storyboard; 267 | sourceTree = ""; 268 | }; 269 | /* End PBXVariantGroup section */ 270 | 271 | /* Begin XCBuildConfiguration section */ 272 | 9CCDA14C214F54D2005914FE /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_ANALYZER_NONNULL = YES; 277 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 278 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 279 | CLANG_CXX_LIBRARY = "libc++"; 280 | CLANG_ENABLE_MODULES = YES; 281 | CLANG_ENABLE_OBJC_ARC = YES; 282 | CLANG_ENABLE_OBJC_WEAK = YES; 283 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 284 | CLANG_WARN_BOOL_CONVERSION = YES; 285 | CLANG_WARN_COMMA = YES; 286 | CLANG_WARN_CONSTANT_CONVERSION = YES; 287 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 288 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 289 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 290 | CLANG_WARN_EMPTY_BODY = YES; 291 | CLANG_WARN_ENUM_CONVERSION = YES; 292 | CLANG_WARN_INFINITE_RECURSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 295 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 296 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 297 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 298 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 299 | CLANG_WARN_STRICT_PROTOTYPES = YES; 300 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 301 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 302 | CLANG_WARN_UNREACHABLE_CODE = YES; 303 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 304 | CODE_SIGN_IDENTITY = "iPhone Developer"; 305 | COPY_PHASE_STRIP = NO; 306 | DEBUG_INFORMATION_FORMAT = dwarf; 307 | ENABLE_STRICT_OBJC_MSGSEND = YES; 308 | ENABLE_TESTABILITY = YES; 309 | GCC_C_LANGUAGE_STANDARD = gnu11; 310 | GCC_DYNAMIC_NO_PIC = NO; 311 | GCC_NO_COMMON_BLOCKS = YES; 312 | GCC_OPTIMIZATION_LEVEL = 0; 313 | GCC_PREPROCESSOR_DEFINITIONS = ( 314 | "DEBUG=1", 315 | "$(inherited)", 316 | ); 317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 318 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 319 | GCC_WARN_UNDECLARED_SELECTOR = YES; 320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 321 | GCC_WARN_UNUSED_FUNCTION = YES; 322 | GCC_WARN_UNUSED_VARIABLE = YES; 323 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 324 | MTL_ENABLE_DEBUG_INFO = YES; 325 | ONLY_ACTIVE_ARCH = YES; 326 | SDKROOT = iphoneos; 327 | }; 328 | name = Debug; 329 | }; 330 | 9CCDA14D214F54D2005914FE /* Release */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | CLANG_ANALYZER_NONNULL = YES; 335 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 336 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 337 | CLANG_CXX_LIBRARY = "libc++"; 338 | CLANG_ENABLE_MODULES = YES; 339 | CLANG_ENABLE_OBJC_ARC = YES; 340 | CLANG_ENABLE_OBJC_WEAK = YES; 341 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 342 | CLANG_WARN_BOOL_CONVERSION = YES; 343 | CLANG_WARN_COMMA = YES; 344 | CLANG_WARN_CONSTANT_CONVERSION = YES; 345 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 347 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 348 | CLANG_WARN_EMPTY_BODY = YES; 349 | CLANG_WARN_ENUM_CONVERSION = YES; 350 | CLANG_WARN_INFINITE_RECURSION = YES; 351 | CLANG_WARN_INT_CONVERSION = YES; 352 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 353 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 354 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 355 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 356 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 357 | CLANG_WARN_STRICT_PROTOTYPES = YES; 358 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 359 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 360 | CLANG_WARN_UNREACHABLE_CODE = YES; 361 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 362 | CODE_SIGN_IDENTITY = "iPhone Developer"; 363 | COPY_PHASE_STRIP = NO; 364 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 365 | ENABLE_NS_ASSERTIONS = NO; 366 | ENABLE_STRICT_OBJC_MSGSEND = YES; 367 | GCC_C_LANGUAGE_STANDARD = gnu11; 368 | GCC_NO_COMMON_BLOCKS = YES; 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 376 | MTL_ENABLE_DEBUG_INFO = NO; 377 | SDKROOT = iphoneos; 378 | VALIDATE_PRODUCT = YES; 379 | }; 380 | name = Release; 381 | }; 382 | 9CCDA14F214F54D2005914FE /* Debug */ = { 383 | isa = XCBuildConfiguration; 384 | buildSettings = { 385 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 386 | CODE_SIGN_STYLE = Automatic; 387 | INFOPLIST_FILE = NotificationExtensionDemo/Info.plist; 388 | LD_RUNPATH_SEARCH_PATHS = ( 389 | "$(inherited)", 390 | "@executable_path/Frameworks", 391 | ); 392 | PRODUCT_BUNDLE_IDENTIFIER = quangqiang.NotificationExtensionDemo; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | TARGETED_DEVICE_FAMILY = "1,2"; 395 | }; 396 | name = Debug; 397 | }; 398 | 9CCDA150214F54D2005914FE /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 402 | CODE_SIGN_STYLE = Automatic; 403 | INFOPLIST_FILE = NotificationExtensionDemo/Info.plist; 404 | LD_RUNPATH_SEARCH_PATHS = ( 405 | "$(inherited)", 406 | "@executable_path/Frameworks", 407 | ); 408 | PRODUCT_BUNDLE_IDENTIFIER = quangqiang.NotificationExtensionDemo; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | TARGETED_DEVICE_FAMILY = "1,2"; 411 | }; 412 | name = Release; 413 | }; 414 | 9CCDA15F214F5614005914FE /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | CODE_SIGN_STYLE = Automatic; 418 | INFOPLIST_FILE = NotificationSE/Info.plist; 419 | LD_RUNPATH_SEARCH_PATHS = ( 420 | "$(inherited)", 421 | "@executable_path/Frameworks", 422 | "@executable_path/../../Frameworks", 423 | ); 424 | PRODUCT_BUNDLE_IDENTIFIER = quangqiang.NotificationExtensionDemo.NotificationSE; 425 | PRODUCT_NAME = "$(TARGET_NAME)"; 426 | SKIP_INSTALL = YES; 427 | TARGETED_DEVICE_FAMILY = "1,2"; 428 | }; 429 | name = Debug; 430 | }; 431 | 9CCDA160214F5614005914FE /* Release */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | CODE_SIGN_STYLE = Automatic; 435 | INFOPLIST_FILE = NotificationSE/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = ( 437 | "$(inherited)", 438 | "@executable_path/Frameworks", 439 | "@executable_path/../../Frameworks", 440 | ); 441 | PRODUCT_BUNDLE_IDENTIFIER = quangqiang.NotificationExtensionDemo.NotificationSE; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | SKIP_INSTALL = YES; 444 | TARGETED_DEVICE_FAMILY = "1,2"; 445 | }; 446 | name = Release; 447 | }; 448 | /* End XCBuildConfiguration section */ 449 | 450 | /* Begin XCConfigurationList section */ 451 | 9CCDA133214F54D1005914FE /* Build configuration list for PBXProject "NotificationExtensionDemo" */ = { 452 | isa = XCConfigurationList; 453 | buildConfigurations = ( 454 | 9CCDA14C214F54D2005914FE /* Debug */, 455 | 9CCDA14D214F54D2005914FE /* Release */, 456 | ); 457 | defaultConfigurationIsVisible = 0; 458 | defaultConfigurationName = Release; 459 | }; 460 | 9CCDA14E214F54D2005914FE /* Build configuration list for PBXNativeTarget "NotificationExtensionDemo" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | 9CCDA14F214F54D2005914FE /* Debug */, 464 | 9CCDA150214F54D2005914FE /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | defaultConfigurationName = Release; 468 | }; 469 | 9CCDA15E214F5614005914FE /* Build configuration list for PBXNativeTarget "NotificationSE" */ = { 470 | isa = XCConfigurationList; 471 | buildConfigurations = ( 472 | 9CCDA15F214F5614005914FE /* Debug */, 473 | 9CCDA160214F5614005914FE /* Release */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | /* End XCConfigurationList section */ 479 | }; 480 | rootObject = 9CCDA130214F54D1005914FE /* Project object */; 481 | } 482 | -------------------------------------------------------------------------------- /NotificationExtensionDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NotificationExtensionDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /NotificationExtensionDemo.xcodeproj/xcuserdata/liuguangqiang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NotificationExtensionDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | NotificationSE.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // NotificationExtensionDemo 4 | // 5 | // Created by 刘光强 on 2018/9/17. 6 | // Copyright © 2018年 quangqiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // NotificationExtensionDemo 4 | // 5 | // Created by 刘光强 on 2018/9/17. 6 | // Copyright © 2018年 quangqiang. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | 12 | @interface AppDelegate () 13 | 14 | @property (nonatomic, strong) AVSpeechSynthesisVoice *synthesisVoice; 15 | @property (nonatomic, strong) AVSpeechSynthesizer *synthesizer; 16 | @end 17 | 18 | @implementation AppDelegate 19 | 20 | 21 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 22 | // Override point for customization after application launch. 23 | return YES; 24 | } 25 | 26 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler { 27 | [self addOperation:userInfo[@"aps"][@"alert"][@"body"]]; 28 | } 29 | 30 | #pragma mark -队列管理推送通知 31 | - (void)addOperation:(NSString *)title { 32 | [[self mainQueue] addOperation:[self customOperation:title]]; 33 | } 34 | 35 | - (NSOperationQueue *)mainQueue { 36 | return [NSOperationQueue mainQueue]; 37 | } 38 | 39 | - (NSOperation *)customOperation:(NSString *)content { 40 | NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ 41 | AVSpeechUtterance *utterance = nil; 42 | @autoreleasepool { 43 | utterance = [AVSpeechUtterance speechUtteranceWithString:content]; 44 | utterance.rate = 0.5; 45 | } 46 | utterance.voice = self.synthesisVoice; 47 | [self.synthesizer speakUtterance:utterance]; 48 | }]; 49 | return operation; 50 | } 51 | 52 | - (AVSpeechSynthesisVoice *)synthesisVoice { 53 | if (!_synthesisVoice) { 54 | _synthesisVoice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"]; 55 | } 56 | return _synthesisVoice; 57 | } 58 | 59 | - (AVSpeechSynthesizer *)synthesizer { 60 | if (!_synthesizer) { 61 | _synthesizer = [[AVSpeechSynthesizer alloc] init]; 62 | } 63 | return _synthesizer; 64 | } 65 | 66 | 67 | - (void)applicationWillResignActive:(UIApplication *)application { 68 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 69 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 70 | } 71 | 72 | 73 | - (void)applicationDidEnterBackground:(UIApplication *)application { 74 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 75 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 76 | } 77 | 78 | 79 | - (void)applicationWillEnterForeground:(UIApplication *)application { 80 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 81 | } 82 | 83 | 84 | - (void)applicationDidBecomeActive:(UIApplication *)application { 85 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 86 | } 87 | 88 | 89 | - (void)applicationWillTerminate:(UIApplication *)application { 90 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 91 | } 92 | 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /NotificationExtensionDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /NotificationExtensionDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIBackgroundModes 24 | 25 | audio 26 | fetch 27 | remote-notification 28 | 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // NotificationExtensionDemo 4 | // 5 | // Created by 刘光强 on 2018/9/17. 6 | // Copyright © 2018年 quangqiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // NotificationExtensionDemo 4 | // 5 | // Created by 刘光强 on 2018/9/17. 6 | // Copyright © 2018年 quangqiang. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | self.view.backgroundColor = [UIColor magentaColor]; 21 | } 22 | 23 | 24 | - (void)didReceiveMemoryWarning { 25 | [super didReceiveMemoryWarning]; 26 | // Dispose of any resources that can be recreated. 27 | } 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /NotificationExtensionDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NotificationExtensionDemo 4 | // 5 | // Created by 刘光强 on 2018/9/17. 6 | // Copyright © 2018年 quangqiang. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /NotificationSE/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | NotificationSE 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | XPC! 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | NSExtension 24 | 25 | NSExtensionPointIdentifier 26 | com.apple.usernotifications.service 27 | NSExtensionPrincipalClass 28 | NotificationService 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /NotificationSE/NotificationService.h: -------------------------------------------------------------------------------- 1 | // 2 | // NotificationService.h 3 | // NotificationSE 4 | // 5 | // Created by 刘光强 on 2018/9/17. 6 | // Copyright © 2018年 quangqiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NotificationService : UNNotificationServiceExtension 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /NotificationSE/NotificationService.m: -------------------------------------------------------------------------------- 1 | // 2 | // NotificationService.m 3 | // NotificationSE 4 | // 5 | // Created by 刘光强 on 2018/9/17. 6 | // Copyright © 2018年 quangqiang. All rights reserved. 7 | // 8 | 9 | #import "NotificationService.h" 10 | #import 11 | #import 12 | 13 | @interface NotificationService () 14 | 15 | @property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); 16 | @property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent; 17 | 18 | @property (nonatomic, strong) AVSpeechSynthesisVoice *synthesisVoice; 19 | @property (nonatomic, strong) AVSpeechSynthesizer *synthesizer; 20 | @end 21 | 22 | @implementation NotificationService 23 | 24 | - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { 25 | self.contentHandler = contentHandler; 26 | self.bestAttemptContent = [request.content mutableCopy]; 27 | 28 | // 这个info 内容就是通知信息携带的数据,后面我们取语音播报的文案,通知栏的title,以及通知内容都是从这个info字段中获取 29 | NSDictionary *info = self.bestAttemptContent.userInfo; 30 | 31 | // 播报语音 32 | [self playVoiceWithContent: info[@"content"]]; 33 | 34 | // 这行代码需要注释,当我们想解决当同时推送了多条消息,这时我们想多条消息一条一条的挨个播报,我们就需要将此行代码注释 35 | // self.contentHandler(self.bestAttemptContent); 36 | } 37 | 38 | - (void)playVoiceWithContent:(NSString *)content { 39 | AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:content]; 40 | utterance.rate = 0.5; 41 | utterance.voice = self.synthesisVoice; 42 | [self.synthesizer speakUtterance:utterance]; 43 | } 44 | 45 | // 新增语音播放代理函数,在语音播报完成的代理函数中,我们添加下面的一行代码 46 | - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance { 47 | [self playVoice:@"调用了播放完成函数"]; 48 | 49 | // 每一条语音播放完成后,我们调用此代码,用来呼出通知栏 50 | self.contentHandler(self.bestAttemptContent); 51 | } 52 | 53 | - (void)serviceExtensionTimeWillExpire { 54 | // Called just before the extension will be terminated by the system. 55 | // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. 56 | self.contentHandler(self.bestAttemptContent); 57 | } 58 | 59 | // 调试,代替debug 60 | - (void)playVoice:(NSString *)info { 61 | AVSpeechSynthesizer *av = [[AVSpeechSynthesizer alloc] init]; 62 | AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"]; 63 | AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:info]; 64 | utterance.rate = 0.5; 65 | utterance.voice= voice; 66 | [av speakUtterance:utterance]; 67 | } 68 | 69 | - (AVSpeechSynthesisVoice *)synthesisVoice { 70 | if (!_synthesisVoice) { 71 | _synthesisVoice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"]; 72 | } 73 | return _synthesisVoice; 74 | } 75 | 76 | - (AVSpeechSynthesizer *)synthesizer { 77 | if (!_synthesizer) { 78 | _synthesizer = [[AVSpeechSynthesizer alloc] init]; 79 | _synthesizer.delegate = self; 80 | } 81 | return _synthesizer; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NotificationExtensionDemo 2 | iOS 10 处理杀进程语音播放,串行语音播报 3 | --------------------------------------------------------------------------------