├── .gitignore ├── .swift-version ├── .travis.yml ├── Assets └── banner.png ├── DLLocalNotifications.podspec ├── DLLocalNotifications.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── deveshlaungani.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcshareddata │ └── xcschemes │ ├── DLLocalNotifications.xcscheme │ └── DLLocalNotificationsHost.xcscheme ├── DLLocalNotifications ├── DLCategory.swift ├── DLLocalNotifications.h ├── DLLocalNotifications.swift ├── DLNotification.swift ├── DLQueue.swift └── Info.plist ├── DLLocalNotificationsHost ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── test.imageset │ │ ├── Contents.json │ │ └── test.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── DLLocalNotificationsHostUITests ├── DLLocalNotificationsHostUITests.swift └── Info.plist ├── DLLocalNotificationsTests ├── DLLocalNotificationsTests.swift ├── DLSchedulerTests.swift └── Info.plist ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.3 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: swift 2 | 3 | script: 4 | - xcodebuild clean build -project DLLocalNotifications.xcodeproj -scheme DLLocalNotifications -sdk iphonesimulator 5 | - xcodebuild test -project DLLocalNotifications.xcodeproj -scheme "DLLocalNotificationsHost" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=14.2' 6 | - xcodebuild test -project DLLocalNotifications.xcodeproj -scheme "DLLocalNotifications" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=14.2' 7 | 8 | osx_image: xcode12.2 9 | xcode_sdk: iphonesimulator14.0 10 | -------------------------------------------------------------------------------- /Assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d7laungani/DLLocalNotifications/24df54f93310cda8a7e952345de8b9c0fbcda1fe/Assets/banner.png -------------------------------------------------------------------------------- /DLLocalNotifications.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | 4 | s.name = "DLLocalNotifications" 5 | s.version = "0.09" 6 | s.summary = "Local Notification Helper for User Notifications framework" 7 | 8 | 9 | s.description = <<-DESC 10 | "DLLocalNotifications makes it extremely easy to setup a local notification, while making it easy to repeat notifications, and encapsulating away the intricacies of the User Notifications Framework." 11 | DESC 12 | 13 | s.homepage = "https://github.com/d7laungani/DLLocalNotifications" 14 | s.license = { :type => "MIT", :file => "LICENSE" } 15 | s.author = "Devesh Laungani" 16 | 17 | 18 | 19 | s.platform = :ios 20 | s.source = { :git => "https://github.com/d7laungani/DLLocalNotifications.git", :tag => s.version} 21 | s.ios.deployment_target = '10.0' 22 | 23 | s.source_files = "DLLocalNotifications", "DLLocalNotifications/**/*.{h,m,swift}" 24 | 25 | 26 | end 27 | -------------------------------------------------------------------------------- /DLLocalNotifications.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5526CB9620CDF6FB000B3E38 /* DLCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5526CB9520CDF6FB000B3E38 /* DLCategory.swift */; }; 11 | 5526CB9820CDF722000B3E38 /* DLQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5526CB9720CDF722000B3E38 /* DLQueue.swift */; }; 12 | 5526CB9C20CDF770000B3E38 /* DLNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5526CB9B20CDF770000B3E38 /* DLNotification.swift */; }; 13 | 55EC96C81E01D63900833C1A /* DLLocalNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55EC96BE1E01D63800833C1A /* DLLocalNotifications.framework */; }; 14 | 55EC96CD1E01D63900833C1A /* DLLocalNotificationsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55EC96CC1E01D63900833C1A /* DLLocalNotificationsTests.swift */; }; 15 | 55EC96CF1E01D63900833C1A /* DLLocalNotifications.h in Headers */ = {isa = PBXBuildFile; fileRef = 55EC96C11E01D63800833C1A /* DLLocalNotifications.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | 55EC97751E01D8C600833C1A /* DLLocalNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55EC97741E01D8C600833C1A /* DLLocalNotifications.swift */; }; 17 | FA9BB71925B7CFD0009F25DA /* DLLocalNotificationsHostUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9BB71825B7CFD0009F25DA /* DLLocalNotificationsHostUITests.swift */; }; 18 | FAE044B221EBFA1B005D94F9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE044B121EBFA1B005D94F9 /* AppDelegate.swift */; }; 19 | FAE044B421EBFA1B005D94F9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE044B321EBFA1B005D94F9 /* ViewController.swift */; }; 20 | FAE044B721EBFA1B005D94F9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FAE044B521EBFA1B005D94F9 /* Main.storyboard */; }; 21 | FAE044B921EBFA1C005D94F9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FAE044B821EBFA1C005D94F9 /* Assets.xcassets */; }; 22 | FAE044BC21EBFA1C005D94F9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FAE044BA21EBFA1C005D94F9 /* LaunchScreen.storyboard */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 55EC96C91E01D63900833C1A /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 55EC96B51E01D63800833C1A /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 55EC96BD1E01D63800833C1A; 31 | remoteInfo = DLLocalNotifications; 32 | }; 33 | FA9BB71B25B7CFD0009F25DA /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 55EC96B51E01D63800833C1A /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = FAE044AE21EBFA1B005D94F9; 38 | remoteInfo = DLLocalNotificationsHost; 39 | }; 40 | FAE044C121EBFA36005D94F9 /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = 55EC96B51E01D63800833C1A /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = FAE044AE21EBFA1B005D94F9; 45 | remoteInfo = DLLocalNotificationsHost; 46 | }; 47 | /* End PBXContainerItemProxy section */ 48 | 49 | /* Begin PBXFileReference section */ 50 | 5526CB9520CDF6FB000B3E38 /* DLCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DLCategory.swift; sourceTree = ""; }; 51 | 5526CB9720CDF722000B3E38 /* DLQueue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DLQueue.swift; sourceTree = ""; }; 52 | 5526CB9B20CDF770000B3E38 /* DLNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DLNotification.swift; sourceTree = ""; }; 53 | 55EC96BE1E01D63800833C1A /* DLLocalNotifications.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DLLocalNotifications.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 55EC96C11E01D63800833C1A /* DLLocalNotifications.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DLLocalNotifications.h; sourceTree = ""; }; 55 | 55EC96C21E01D63800833C1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 55EC96C71E01D63900833C1A /* DLLocalNotificationsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DLLocalNotificationsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | 55EC96CC1E01D63900833C1A /* DLLocalNotificationsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DLLocalNotificationsTests.swift; sourceTree = ""; }; 58 | 55EC96CE1E01D63900833C1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 55EC97741E01D8C600833C1A /* DLLocalNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DLLocalNotifications.swift; sourceTree = ""; }; 60 | FA9BB71625B7CFD0009F25DA /* DLLocalNotificationsHostUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DLLocalNotificationsHostUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | FA9BB71825B7CFD0009F25DA /* DLLocalNotificationsHostUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DLLocalNotificationsHostUITests.swift; sourceTree = ""; }; 62 | FA9BB71A25B7CFD0009F25DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 63 | FAE044AF21EBFA1B005D94F9 /* DLLocalNotificationsHost.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DLLocalNotificationsHost.app; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | FAE044B121EBFA1B005D94F9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 65 | FAE044B321EBFA1B005D94F9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 66 | FAE044B621EBFA1B005D94F9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 67 | FAE044B821EBFA1C005D94F9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 68 | FAE044BB21EBFA1C005D94F9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 69 | FAE044BD21EBFA1C005D94F9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | /* End PBXFileReference section */ 71 | 72 | /* Begin PBXFrameworksBuildPhase section */ 73 | 55EC96BA1E01D63800833C1A /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | 55EC96C41E01D63900833C1A /* Frameworks */ = { 81 | isa = PBXFrameworksBuildPhase; 82 | buildActionMask = 2147483647; 83 | files = ( 84 | 55EC96C81E01D63900833C1A /* DLLocalNotifications.framework in Frameworks */, 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | FA9BB71325B7CFD0009F25DA /* Frameworks */ = { 89 | isa = PBXFrameworksBuildPhase; 90 | buildActionMask = 2147483647; 91 | files = ( 92 | ); 93 | runOnlyForDeploymentPostprocessing = 0; 94 | }; 95 | FAE044AC21EBFA1B005D94F9 /* Frameworks */ = { 96 | isa = PBXFrameworksBuildPhase; 97 | buildActionMask = 2147483647; 98 | files = ( 99 | ); 100 | runOnlyForDeploymentPostprocessing = 0; 101 | }; 102 | /* End PBXFrameworksBuildPhase section */ 103 | 104 | /* Begin PBXGroup section */ 105 | 55EC96B41E01D63800833C1A = { 106 | isa = PBXGroup; 107 | children = ( 108 | 55EC96C01E01D63800833C1A /* DLLocalNotifications */, 109 | 55EC96CB1E01D63900833C1A /* DLLocalNotificationsTests */, 110 | FAE044B021EBFA1B005D94F9 /* DLLocalNotificationsHost */, 111 | FA9BB71725B7CFD0009F25DA /* DLLocalNotificationsHostUITests */, 112 | 55EC96BF1E01D63800833C1A /* Products */, 113 | ); 114 | sourceTree = ""; 115 | }; 116 | 55EC96BF1E01D63800833C1A /* Products */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 55EC96BE1E01D63800833C1A /* DLLocalNotifications.framework */, 120 | 55EC96C71E01D63900833C1A /* DLLocalNotificationsTests.xctest */, 121 | FAE044AF21EBFA1B005D94F9 /* DLLocalNotificationsHost.app */, 122 | FA9BB71625B7CFD0009F25DA /* DLLocalNotificationsHostUITests.xctest */, 123 | ); 124 | name = Products; 125 | sourceTree = ""; 126 | }; 127 | 55EC96C01E01D63800833C1A /* DLLocalNotifications */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 55EC96C11E01D63800833C1A /* DLLocalNotifications.h */, 131 | 55EC96C21E01D63800833C1A /* Info.plist */, 132 | 55EC97741E01D8C600833C1A /* DLLocalNotifications.swift */, 133 | 5526CB9520CDF6FB000B3E38 /* DLCategory.swift */, 134 | 5526CB9720CDF722000B3E38 /* DLQueue.swift */, 135 | 5526CB9B20CDF770000B3E38 /* DLNotification.swift */, 136 | ); 137 | path = DLLocalNotifications; 138 | sourceTree = ""; 139 | }; 140 | 55EC96CB1E01D63900833C1A /* DLLocalNotificationsTests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 55EC96CC1E01D63900833C1A /* DLLocalNotificationsTests.swift */, 144 | 55EC96CE1E01D63900833C1A /* Info.plist */, 145 | ); 146 | path = DLLocalNotificationsTests; 147 | sourceTree = ""; 148 | }; 149 | FA9BB71725B7CFD0009F25DA /* DLLocalNotificationsHostUITests */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | FA9BB71825B7CFD0009F25DA /* DLLocalNotificationsHostUITests.swift */, 153 | FA9BB71A25B7CFD0009F25DA /* Info.plist */, 154 | ); 155 | path = DLLocalNotificationsHostUITests; 156 | sourceTree = ""; 157 | }; 158 | FAE044B021EBFA1B005D94F9 /* DLLocalNotificationsHost */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | FAE044B121EBFA1B005D94F9 /* AppDelegate.swift */, 162 | FAE044B321EBFA1B005D94F9 /* ViewController.swift */, 163 | FAE044B521EBFA1B005D94F9 /* Main.storyboard */, 164 | FAE044B821EBFA1C005D94F9 /* Assets.xcassets */, 165 | FAE044BA21EBFA1C005D94F9 /* LaunchScreen.storyboard */, 166 | FAE044BD21EBFA1C005D94F9 /* Info.plist */, 167 | ); 168 | path = DLLocalNotificationsHost; 169 | sourceTree = ""; 170 | }; 171 | /* End PBXGroup section */ 172 | 173 | /* Begin PBXHeadersBuildPhase section */ 174 | 55EC96BB1E01D63800833C1A /* Headers */ = { 175 | isa = PBXHeadersBuildPhase; 176 | buildActionMask = 2147483647; 177 | files = ( 178 | 55EC96CF1E01D63900833C1A /* DLLocalNotifications.h in Headers */, 179 | ); 180 | runOnlyForDeploymentPostprocessing = 0; 181 | }; 182 | /* End PBXHeadersBuildPhase section */ 183 | 184 | /* Begin PBXNativeTarget section */ 185 | 55EC96BD1E01D63800833C1A /* DLLocalNotifications */ = { 186 | isa = PBXNativeTarget; 187 | buildConfigurationList = 55EC96D21E01D63900833C1A /* Build configuration list for PBXNativeTarget "DLLocalNotifications" */; 188 | buildPhases = ( 189 | 55EC96B91E01D63800833C1A /* Sources */, 190 | 55EC96BA1E01D63800833C1A /* Frameworks */, 191 | 55EC96BB1E01D63800833C1A /* Headers */, 192 | 55EC96BC1E01D63800833C1A /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | ); 198 | name = DLLocalNotifications; 199 | productName = DLLocalNotifications; 200 | productReference = 55EC96BE1E01D63800833C1A /* DLLocalNotifications.framework */; 201 | productType = "com.apple.product-type.framework"; 202 | }; 203 | 55EC96C61E01D63900833C1A /* DLLocalNotificationsTests */ = { 204 | isa = PBXNativeTarget; 205 | buildConfigurationList = 55EC96D51E01D63900833C1A /* Build configuration list for PBXNativeTarget "DLLocalNotificationsTests" */; 206 | buildPhases = ( 207 | 55EC96C31E01D63900833C1A /* Sources */, 208 | 55EC96C41E01D63900833C1A /* Frameworks */, 209 | 55EC96C51E01D63900833C1A /* Resources */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | 55EC96CA1E01D63900833C1A /* PBXTargetDependency */, 215 | FAE044C221EBFA36005D94F9 /* PBXTargetDependency */, 216 | ); 217 | name = DLLocalNotificationsTests; 218 | productName = DLLocalNotificationsTests; 219 | productReference = 55EC96C71E01D63900833C1A /* DLLocalNotificationsTests.xctest */; 220 | productType = "com.apple.product-type.bundle.unit-test"; 221 | }; 222 | FA9BB71525B7CFD0009F25DA /* DLLocalNotificationsHostUITests */ = { 223 | isa = PBXNativeTarget; 224 | buildConfigurationList = FA9BB71D25B7CFD0009F25DA /* Build configuration list for PBXNativeTarget "DLLocalNotificationsHostUITests" */; 225 | buildPhases = ( 226 | FA9BB71225B7CFD0009F25DA /* Sources */, 227 | FA9BB71325B7CFD0009F25DA /* Frameworks */, 228 | FA9BB71425B7CFD0009F25DA /* Resources */, 229 | ); 230 | buildRules = ( 231 | ); 232 | dependencies = ( 233 | FA9BB71C25B7CFD0009F25DA /* PBXTargetDependency */, 234 | ); 235 | name = DLLocalNotificationsHostUITests; 236 | productName = DLLocalNotificationsHostUITests; 237 | productReference = FA9BB71625B7CFD0009F25DA /* DLLocalNotificationsHostUITests.xctest */; 238 | productType = "com.apple.product-type.bundle.ui-testing"; 239 | }; 240 | FAE044AE21EBFA1B005D94F9 /* DLLocalNotificationsHost */ = { 241 | isa = PBXNativeTarget; 242 | buildConfigurationList = FAE044BE21EBFA1C005D94F9 /* Build configuration list for PBXNativeTarget "DLLocalNotificationsHost" */; 243 | buildPhases = ( 244 | FAE044AB21EBFA1B005D94F9 /* Sources */, 245 | FAE044AC21EBFA1B005D94F9 /* Frameworks */, 246 | FAE044AD21EBFA1B005D94F9 /* Resources */, 247 | ); 248 | buildRules = ( 249 | ); 250 | dependencies = ( 251 | ); 252 | name = DLLocalNotificationsHost; 253 | productName = DLLocalNotificationsHost; 254 | productReference = FAE044AF21EBFA1B005D94F9 /* DLLocalNotificationsHost.app */; 255 | productType = "com.apple.product-type.application"; 256 | }; 257 | /* End PBXNativeTarget section */ 258 | 259 | /* Begin PBXProject section */ 260 | 55EC96B51E01D63800833C1A /* Project object */ = { 261 | isa = PBXProject; 262 | attributes = { 263 | LastSwiftUpdateCheck = 1200; 264 | LastUpgradeCheck = 0820; 265 | ORGANIZATIONNAME = "Devesh Laungani"; 266 | TargetAttributes = { 267 | 55EC96BD1E01D63800833C1A = { 268 | CreatedOnToolsVersion = 8.2; 269 | DevelopmentTeam = 3FNKL5DKHS; 270 | LastSwiftMigration = 0910; 271 | ProvisioningStyle = Automatic; 272 | }; 273 | 55EC96C61E01D63900833C1A = { 274 | CreatedOnToolsVersion = 8.2; 275 | DevelopmentTeam = 3FNKL5DKHS; 276 | LastSwiftMigration = 0910; 277 | ProvisioningStyle = Automatic; 278 | TestTargetID = FAE044AE21EBFA1B005D94F9; 279 | }; 280 | FA9BB71525B7CFD0009F25DA = { 281 | CreatedOnToolsVersion = 12.0; 282 | ProvisioningStyle = Automatic; 283 | TestTargetID = FAE044AE21EBFA1B005D94F9; 284 | }; 285 | FAE044AE21EBFA1B005D94F9 = { 286 | CreatedOnToolsVersion = 10.0; 287 | DevelopmentTeam = 8878VL7H9L; 288 | ProvisioningStyle = Automatic; 289 | }; 290 | }; 291 | }; 292 | buildConfigurationList = 55EC96B81E01D63800833C1A /* Build configuration list for PBXProject "DLLocalNotifications" */; 293 | compatibilityVersion = "Xcode 3.2"; 294 | developmentRegion = English; 295 | hasScannedForEncodings = 0; 296 | knownRegions = ( 297 | English, 298 | en, 299 | Base, 300 | ); 301 | mainGroup = 55EC96B41E01D63800833C1A; 302 | productRefGroup = 55EC96BF1E01D63800833C1A /* Products */; 303 | projectDirPath = ""; 304 | projectRoot = ""; 305 | targets = ( 306 | 55EC96BD1E01D63800833C1A /* DLLocalNotifications */, 307 | 55EC96C61E01D63900833C1A /* DLLocalNotificationsTests */, 308 | FAE044AE21EBFA1B005D94F9 /* DLLocalNotificationsHost */, 309 | FA9BB71525B7CFD0009F25DA /* DLLocalNotificationsHostUITests */, 310 | ); 311 | }; 312 | /* End PBXProject section */ 313 | 314 | /* Begin PBXResourcesBuildPhase section */ 315 | 55EC96BC1E01D63800833C1A /* Resources */ = { 316 | isa = PBXResourcesBuildPhase; 317 | buildActionMask = 2147483647; 318 | files = ( 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | 55EC96C51E01D63900833C1A /* Resources */ = { 323 | isa = PBXResourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | }; 329 | FA9BB71425B7CFD0009F25DA /* Resources */ = { 330 | isa = PBXResourcesBuildPhase; 331 | buildActionMask = 2147483647; 332 | files = ( 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | FAE044AD21EBFA1B005D94F9 /* Resources */ = { 337 | isa = PBXResourcesBuildPhase; 338 | buildActionMask = 2147483647; 339 | files = ( 340 | FAE044BC21EBFA1C005D94F9 /* LaunchScreen.storyboard in Resources */, 341 | FAE044B921EBFA1C005D94F9 /* Assets.xcassets in Resources */, 342 | FAE044B721EBFA1B005D94F9 /* Main.storyboard in Resources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | /* End PBXResourcesBuildPhase section */ 347 | 348 | /* Begin PBXSourcesBuildPhase section */ 349 | 55EC96B91E01D63800833C1A /* Sources */ = { 350 | isa = PBXSourcesBuildPhase; 351 | buildActionMask = 2147483647; 352 | files = ( 353 | 55EC97751E01D8C600833C1A /* DLLocalNotifications.swift in Sources */, 354 | 5526CB9620CDF6FB000B3E38 /* DLCategory.swift in Sources */, 355 | 5526CB9C20CDF770000B3E38 /* DLNotification.swift in Sources */, 356 | 5526CB9820CDF722000B3E38 /* DLQueue.swift in Sources */, 357 | ); 358 | runOnlyForDeploymentPostprocessing = 0; 359 | }; 360 | 55EC96C31E01D63900833C1A /* Sources */ = { 361 | isa = PBXSourcesBuildPhase; 362 | buildActionMask = 2147483647; 363 | files = ( 364 | 55EC96CD1E01D63900833C1A /* DLLocalNotificationsTests.swift in Sources */, 365 | ); 366 | runOnlyForDeploymentPostprocessing = 0; 367 | }; 368 | FA9BB71225B7CFD0009F25DA /* Sources */ = { 369 | isa = PBXSourcesBuildPhase; 370 | buildActionMask = 2147483647; 371 | files = ( 372 | FA9BB71925B7CFD0009F25DA /* DLLocalNotificationsHostUITests.swift in Sources */, 373 | ); 374 | runOnlyForDeploymentPostprocessing = 0; 375 | }; 376 | FAE044AB21EBFA1B005D94F9 /* Sources */ = { 377 | isa = PBXSourcesBuildPhase; 378 | buildActionMask = 2147483647; 379 | files = ( 380 | FAE044B421EBFA1B005D94F9 /* ViewController.swift in Sources */, 381 | FAE044B221EBFA1B005D94F9 /* AppDelegate.swift in Sources */, 382 | ); 383 | runOnlyForDeploymentPostprocessing = 0; 384 | }; 385 | /* End PBXSourcesBuildPhase section */ 386 | 387 | /* Begin PBXTargetDependency section */ 388 | 55EC96CA1E01D63900833C1A /* PBXTargetDependency */ = { 389 | isa = PBXTargetDependency; 390 | target = 55EC96BD1E01D63800833C1A /* DLLocalNotifications */; 391 | targetProxy = 55EC96C91E01D63900833C1A /* PBXContainerItemProxy */; 392 | }; 393 | FA9BB71C25B7CFD0009F25DA /* PBXTargetDependency */ = { 394 | isa = PBXTargetDependency; 395 | target = FAE044AE21EBFA1B005D94F9 /* DLLocalNotificationsHost */; 396 | targetProxy = FA9BB71B25B7CFD0009F25DA /* PBXContainerItemProxy */; 397 | }; 398 | FAE044C221EBFA36005D94F9 /* PBXTargetDependency */ = { 399 | isa = PBXTargetDependency; 400 | target = FAE044AE21EBFA1B005D94F9 /* DLLocalNotificationsHost */; 401 | targetProxy = FAE044C121EBFA36005D94F9 /* PBXContainerItemProxy */; 402 | }; 403 | /* End PBXTargetDependency section */ 404 | 405 | /* Begin PBXVariantGroup section */ 406 | FAE044B521EBFA1B005D94F9 /* Main.storyboard */ = { 407 | isa = PBXVariantGroup; 408 | children = ( 409 | FAE044B621EBFA1B005D94F9 /* Base */, 410 | ); 411 | name = Main.storyboard; 412 | sourceTree = ""; 413 | }; 414 | FAE044BA21EBFA1C005D94F9 /* LaunchScreen.storyboard */ = { 415 | isa = PBXVariantGroup; 416 | children = ( 417 | FAE044BB21EBFA1C005D94F9 /* Base */, 418 | ); 419 | name = LaunchScreen.storyboard; 420 | sourceTree = ""; 421 | }; 422 | /* End PBXVariantGroup section */ 423 | 424 | /* Begin XCBuildConfiguration section */ 425 | 55EC96D01E01D63900833C1A /* Debug */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | ALWAYS_SEARCH_USER_PATHS = NO; 429 | CLANG_ANALYZER_NONNULL = YES; 430 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 431 | CLANG_CXX_LIBRARY = "libc++"; 432 | CLANG_ENABLE_MODULES = YES; 433 | CLANG_ENABLE_OBJC_ARC = YES; 434 | CLANG_WARN_BOOL_CONVERSION = YES; 435 | CLANG_WARN_CONSTANT_CONVERSION = YES; 436 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 437 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 438 | CLANG_WARN_EMPTY_BODY = YES; 439 | CLANG_WARN_ENUM_CONVERSION = YES; 440 | CLANG_WARN_INFINITE_RECURSION = YES; 441 | CLANG_WARN_INT_CONVERSION = YES; 442 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 443 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 444 | CLANG_WARN_UNREACHABLE_CODE = YES; 445 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 446 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 447 | COPY_PHASE_STRIP = NO; 448 | CURRENT_PROJECT_VERSION = 1; 449 | DEBUG_INFORMATION_FORMAT = dwarf; 450 | ENABLE_STRICT_OBJC_MSGSEND = YES; 451 | ENABLE_TESTABILITY = YES; 452 | GCC_C_LANGUAGE_STANDARD = gnu99; 453 | GCC_DYNAMIC_NO_PIC = NO; 454 | GCC_NO_COMMON_BLOCKS = YES; 455 | GCC_OPTIMIZATION_LEVEL = 0; 456 | GCC_PREPROCESSOR_DEFINITIONS = ( 457 | "DEBUG=1", 458 | "$(inherited)", 459 | ); 460 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 461 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 462 | GCC_WARN_UNDECLARED_SELECTOR = YES; 463 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 464 | GCC_WARN_UNUSED_FUNCTION = YES; 465 | GCC_WARN_UNUSED_VARIABLE = YES; 466 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 467 | MTL_ENABLE_DEBUG_INFO = YES; 468 | ONLY_ACTIVE_ARCH = YES; 469 | SDKROOT = iphoneos; 470 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 471 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 472 | TARGETED_DEVICE_FAMILY = "1,2"; 473 | VERSIONING_SYSTEM = "apple-generic"; 474 | VERSION_INFO_PREFIX = ""; 475 | }; 476 | name = Debug; 477 | }; 478 | 55EC96D11E01D63900833C1A /* Release */ = { 479 | isa = XCBuildConfiguration; 480 | buildSettings = { 481 | ALWAYS_SEARCH_USER_PATHS = NO; 482 | CLANG_ANALYZER_NONNULL = YES; 483 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 484 | CLANG_CXX_LIBRARY = "libc++"; 485 | CLANG_ENABLE_MODULES = YES; 486 | CLANG_ENABLE_OBJC_ARC = YES; 487 | CLANG_WARN_BOOL_CONVERSION = YES; 488 | CLANG_WARN_CONSTANT_CONVERSION = YES; 489 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 490 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 491 | CLANG_WARN_EMPTY_BODY = YES; 492 | CLANG_WARN_ENUM_CONVERSION = YES; 493 | CLANG_WARN_INFINITE_RECURSION = YES; 494 | CLANG_WARN_INT_CONVERSION = YES; 495 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 496 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 497 | CLANG_WARN_UNREACHABLE_CODE = YES; 498 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 499 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 500 | COPY_PHASE_STRIP = NO; 501 | CURRENT_PROJECT_VERSION = 1; 502 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 503 | ENABLE_NS_ASSERTIONS = NO; 504 | ENABLE_STRICT_OBJC_MSGSEND = YES; 505 | GCC_C_LANGUAGE_STANDARD = gnu99; 506 | GCC_NO_COMMON_BLOCKS = YES; 507 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 508 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 509 | GCC_WARN_UNDECLARED_SELECTOR = YES; 510 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 511 | GCC_WARN_UNUSED_FUNCTION = YES; 512 | GCC_WARN_UNUSED_VARIABLE = YES; 513 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 514 | MTL_ENABLE_DEBUG_INFO = NO; 515 | SDKROOT = iphoneos; 516 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 517 | TARGETED_DEVICE_FAMILY = "1,2"; 518 | VALIDATE_PRODUCT = YES; 519 | VERSIONING_SYSTEM = "apple-generic"; 520 | VERSION_INFO_PREFIX = ""; 521 | }; 522 | name = Release; 523 | }; 524 | 55EC96D31E01D63900833C1A /* Debug */ = { 525 | isa = XCBuildConfiguration; 526 | buildSettings = { 527 | CLANG_ENABLE_MODULES = YES; 528 | CODE_SIGN_IDENTITY = ""; 529 | DEFINES_MODULE = YES; 530 | DEVELOPMENT_TEAM = 3FNKL5DKHS; 531 | DYLIB_COMPATIBILITY_VERSION = 1; 532 | DYLIB_CURRENT_VERSION = 1; 533 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 534 | INFOPLIST_FILE = DLLocalNotifications/Info.plist; 535 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 536 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 537 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 538 | PRODUCT_BUNDLE_IDENTIFIER = "open-source.DLLocalNotifications"; 539 | PRODUCT_NAME = "$(TARGET_NAME)"; 540 | SKIP_INSTALL = YES; 541 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 542 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 543 | SWIFT_VERSION = 4.2; 544 | }; 545 | name = Debug; 546 | }; 547 | 55EC96D41E01D63900833C1A /* Release */ = { 548 | isa = XCBuildConfiguration; 549 | buildSettings = { 550 | CLANG_ENABLE_MODULES = YES; 551 | CODE_SIGN_IDENTITY = ""; 552 | DEFINES_MODULE = YES; 553 | DEVELOPMENT_TEAM = 3FNKL5DKHS; 554 | DYLIB_COMPATIBILITY_VERSION = 1; 555 | DYLIB_CURRENT_VERSION = 1; 556 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 557 | INFOPLIST_FILE = DLLocalNotifications/Info.plist; 558 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 559 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 560 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 561 | PRODUCT_BUNDLE_IDENTIFIER = "open-source.DLLocalNotifications"; 562 | PRODUCT_NAME = "$(TARGET_NAME)"; 563 | SKIP_INSTALL = YES; 564 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 565 | SWIFT_VERSION = 4.2; 566 | }; 567 | name = Release; 568 | }; 569 | 55EC96D61E01D63900833C1A /* Debug */ = { 570 | isa = XCBuildConfiguration; 571 | buildSettings = { 572 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 573 | DEVELOPMENT_TEAM = 3FNKL5DKHS; 574 | INFOPLIST_FILE = DLLocalNotificationsTests/Info.plist; 575 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 576 | PRODUCT_BUNDLE_IDENTIFIER = "open-source.DLLocalNotificationsTests"; 577 | PRODUCT_NAME = "$(TARGET_NAME)"; 578 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 579 | SWIFT_VERSION = 4.0; 580 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DLLocalNotificationsHost.app/DLLocalNotificationsHost"; 581 | }; 582 | name = Debug; 583 | }; 584 | 55EC96D71E01D63900833C1A /* Release */ = { 585 | isa = XCBuildConfiguration; 586 | buildSettings = { 587 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 588 | DEVELOPMENT_TEAM = 3FNKL5DKHS; 589 | INFOPLIST_FILE = DLLocalNotificationsTests/Info.plist; 590 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 591 | PRODUCT_BUNDLE_IDENTIFIER = "open-source.DLLocalNotificationsTests"; 592 | PRODUCT_NAME = "$(TARGET_NAME)"; 593 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 594 | SWIFT_VERSION = 4.0; 595 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DLLocalNotificationsHost.app/DLLocalNotificationsHost"; 596 | }; 597 | name = Release; 598 | }; 599 | FA9BB71E25B7CFD0009F25DA /* Debug */ = { 600 | isa = XCBuildConfiguration; 601 | buildSettings = { 602 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 603 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 604 | CLANG_ENABLE_OBJC_WEAK = YES; 605 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 606 | CLANG_WARN_COMMA = YES; 607 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 608 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 609 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 610 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 611 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 612 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 613 | CLANG_WARN_STRICT_PROTOTYPES = YES; 614 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 615 | CODE_SIGN_STYLE = Automatic; 616 | GCC_C_LANGUAGE_STANDARD = gnu11; 617 | INFOPLIST_FILE = DLLocalNotificationsHostUITests/Info.plist; 618 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 619 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 620 | MTL_FAST_MATH = YES; 621 | PRODUCT_BUNDLE_IDENTIFIER = com.devesh.tutorials.DLLocalNotificationsHostUITests; 622 | PRODUCT_NAME = "$(TARGET_NAME)"; 623 | SWIFT_VERSION = 5.0; 624 | TARGETED_DEVICE_FAMILY = "1,2"; 625 | TEST_TARGET_NAME = DLLocalNotificationsHost; 626 | }; 627 | name = Debug; 628 | }; 629 | FA9BB71F25B7CFD0009F25DA /* Release */ = { 630 | isa = XCBuildConfiguration; 631 | buildSettings = { 632 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 633 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 634 | CLANG_ENABLE_OBJC_WEAK = YES; 635 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 636 | CLANG_WARN_COMMA = YES; 637 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 638 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 639 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 640 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 641 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 642 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 643 | CLANG_WARN_STRICT_PROTOTYPES = YES; 644 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 645 | CODE_SIGN_STYLE = Automatic; 646 | GCC_C_LANGUAGE_STANDARD = gnu11; 647 | INFOPLIST_FILE = DLLocalNotificationsHostUITests/Info.plist; 648 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 649 | MTL_FAST_MATH = YES; 650 | PRODUCT_BUNDLE_IDENTIFIER = com.devesh.tutorials.DLLocalNotificationsHostUITests; 651 | PRODUCT_NAME = "$(TARGET_NAME)"; 652 | SWIFT_VERSION = 5.0; 653 | TARGETED_DEVICE_FAMILY = "1,2"; 654 | TEST_TARGET_NAME = DLLocalNotificationsHost; 655 | }; 656 | name = Release; 657 | }; 658 | FAE044BF21EBFA1C005D94F9 /* Debug */ = { 659 | isa = XCBuildConfiguration; 660 | buildSettings = { 661 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 662 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 663 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 664 | CLANG_ENABLE_OBJC_WEAK = YES; 665 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 666 | CLANG_WARN_COMMA = YES; 667 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 668 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 669 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 670 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 671 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 672 | CLANG_WARN_STRICT_PROTOTYPES = YES; 673 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 674 | CODE_SIGN_IDENTITY = "iPhone Developer"; 675 | CODE_SIGN_STYLE = Automatic; 676 | DEVELOPMENT_TEAM = 8878VL7H9L; 677 | GCC_C_LANGUAGE_STANDARD = gnu11; 678 | INFOPLIST_FILE = DLLocalNotificationsHost/Info.plist; 679 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 680 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 681 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 682 | MTL_FAST_MATH = YES; 683 | PRODUCT_BUNDLE_IDENTIFIER = com.devesh.opensource.DLLocalNotificationsHost; 684 | PRODUCT_NAME = "$(TARGET_NAME)"; 685 | SWIFT_VERSION = 4.2; 686 | TARGETED_DEVICE_FAMILY = "1,2"; 687 | }; 688 | name = Debug; 689 | }; 690 | FAE044C021EBFA1C005D94F9 /* Release */ = { 691 | isa = XCBuildConfiguration; 692 | buildSettings = { 693 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 694 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 695 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 696 | CLANG_ENABLE_OBJC_WEAK = YES; 697 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 698 | CLANG_WARN_COMMA = YES; 699 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 700 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 701 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 702 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 703 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 704 | CLANG_WARN_STRICT_PROTOTYPES = YES; 705 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 706 | CODE_SIGN_IDENTITY = "iPhone Developer"; 707 | CODE_SIGN_STYLE = Automatic; 708 | DEVELOPMENT_TEAM = 8878VL7H9L; 709 | GCC_C_LANGUAGE_STANDARD = gnu11; 710 | INFOPLIST_FILE = DLLocalNotificationsHost/Info.plist; 711 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 712 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 713 | MTL_FAST_MATH = YES; 714 | PRODUCT_BUNDLE_IDENTIFIER = com.devesh.opensource.DLLocalNotificationsHost; 715 | PRODUCT_NAME = "$(TARGET_NAME)"; 716 | SWIFT_VERSION = 4.2; 717 | TARGETED_DEVICE_FAMILY = "1,2"; 718 | }; 719 | name = Release; 720 | }; 721 | /* End XCBuildConfiguration section */ 722 | 723 | /* Begin XCConfigurationList section */ 724 | 55EC96B81E01D63800833C1A /* Build configuration list for PBXProject "DLLocalNotifications" */ = { 725 | isa = XCConfigurationList; 726 | buildConfigurations = ( 727 | 55EC96D01E01D63900833C1A /* Debug */, 728 | 55EC96D11E01D63900833C1A /* Release */, 729 | ); 730 | defaultConfigurationIsVisible = 0; 731 | defaultConfigurationName = Release; 732 | }; 733 | 55EC96D21E01D63900833C1A /* Build configuration list for PBXNativeTarget "DLLocalNotifications" */ = { 734 | isa = XCConfigurationList; 735 | buildConfigurations = ( 736 | 55EC96D31E01D63900833C1A /* Debug */, 737 | 55EC96D41E01D63900833C1A /* Release */, 738 | ); 739 | defaultConfigurationIsVisible = 0; 740 | defaultConfigurationName = Release; 741 | }; 742 | 55EC96D51E01D63900833C1A /* Build configuration list for PBXNativeTarget "DLLocalNotificationsTests" */ = { 743 | isa = XCConfigurationList; 744 | buildConfigurations = ( 745 | 55EC96D61E01D63900833C1A /* Debug */, 746 | 55EC96D71E01D63900833C1A /* Release */, 747 | ); 748 | defaultConfigurationIsVisible = 0; 749 | defaultConfigurationName = Release; 750 | }; 751 | FA9BB71D25B7CFD0009F25DA /* Build configuration list for PBXNativeTarget "DLLocalNotificationsHostUITests" */ = { 752 | isa = XCConfigurationList; 753 | buildConfigurations = ( 754 | FA9BB71E25B7CFD0009F25DA /* Debug */, 755 | FA9BB71F25B7CFD0009F25DA /* Release */, 756 | ); 757 | defaultConfigurationIsVisible = 0; 758 | defaultConfigurationName = Release; 759 | }; 760 | FAE044BE21EBFA1C005D94F9 /* Build configuration list for PBXNativeTarget "DLLocalNotificationsHost" */ = { 761 | isa = XCConfigurationList; 762 | buildConfigurations = ( 763 | FAE044BF21EBFA1C005D94F9 /* Debug */, 764 | FAE044C021EBFA1C005D94F9 /* Release */, 765 | ); 766 | defaultConfigurationIsVisible = 0; 767 | defaultConfigurationName = Release; 768 | }; 769 | /* End XCConfigurationList section */ 770 | }; 771 | rootObject = 55EC96B51E01D63800833C1A /* Project object */; 772 | } 773 | -------------------------------------------------------------------------------- /DLLocalNotifications.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DLLocalNotifications.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DLLocalNotifications.xcodeproj/project.xcworkspace/xcuserdata/deveshlaungani.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d7laungani/DLLocalNotifications/24df54f93310cda8a7e952345de8b9c0fbcda1fe/DLLocalNotifications.xcodeproj/project.xcworkspace/xcuserdata/deveshlaungani.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DLLocalNotifications.xcodeproj/xcshareddata/xcschemes/DLLocalNotifications.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 42 | 48 | 49 | 50 | 51 | 52 | 62 | 63 | 69 | 70 | 71 | 72 | 78 | 79 | 85 | 86 | 87 | 88 | 90 | 91 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /DLLocalNotifications.xcodeproj/xcshareddata/xcschemes/DLLocalNotificationsHost.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /DLLocalNotifications/DLCategory.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLCategory.swift 3 | // DLLocalNotifications 4 | // 5 | // Created by Devesh Laungani on 6/10/18. 6 | // Copyright © 2018 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | // A wrapper class for creating a Category 10 | import Foundation 11 | import UserNotifications 12 | 13 | @available(iOS 10.0, *) 14 | public class DLCategory { 15 | 16 | // Holds the actions you want available for this category type 17 | private var actions: [UNNotificationAction]? 18 | 19 | // Hold the actual cateogry 20 | internal var categoryInstance: UNNotificationCategory? 21 | 22 | // Holds the identifier of the category type 23 | var identifier: String 24 | 25 | public init (categoryIdentifier: String) { 26 | 27 | identifier = categoryIdentifier 28 | actions = [UNNotificationAction]() 29 | 30 | } 31 | 32 | public func addActionButton(identifier: String?, title: String?) { 33 | 34 | let action = UNNotificationAction(identifier: identifier!, title: title!, options: []) 35 | actions?.append(action) 36 | categoryInstance = UNNotificationCategory(identifier: self.identifier, actions: self.actions!, intentIdentifiers: [], options: []) 37 | 38 | } 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /DLLocalNotifications/DLLocalNotifications.h: -------------------------------------------------------------------------------- 1 | // 2 | // DLLocalNotifications.h 3 | // DLLocalNotifications 4 | // 5 | // Created by Devesh Laungani on 12/14/16. 6 | // Copyright © 2016 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for DLLocalNotifications. 12 | FOUNDATION_EXPORT double DLLocalNotificationsVersionNumber; 13 | 14 | //! Project version string for DLLocalNotifications. 15 | FOUNDATION_EXPORT const unsigned char DLLocalNotificationsVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /DLLocalNotifications/DLLocalNotifications.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLLocalNotifications.swift 3 | // DLLocalNotifications 4 | // 5 | // Created by Devesh Laungani on 12/14/16. 6 | // Copyright © 2016 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UserNotifications 11 | 12 | let MAX_ALLOWED_NOTIFICATIONS = 64 13 | 14 | @available(iOS 10.0, *) 15 | public class DLNotificationScheduler { 16 | 17 | // Apple allows you to only schedule 64 notifications at a time 18 | static let maximumScheduledNotifications = 60 19 | 20 | public init () {} 21 | 22 | public func cancelAlllNotifications () { 23 | 24 | UNUserNotificationCenter.current().removeAllPendingNotificationRequests() 25 | DLQueue.queue.clear() 26 | saveQueue() 27 | 28 | } 29 | 30 | 31 | // Returns all notifications in the notifications queue. 32 | public func notificationsQueue() -> [DLNotification] { 33 | return DLQueue.queue.notificationsQueue() 34 | } 35 | 36 | 37 | 38 | // Cancel the notification if scheduled or queued 39 | public func cancelNotification (notification: DLNotification) { 40 | 41 | let identifier = (notification.localNotificationRequest != nil) ? notification.localNotificationRequest?.identifier : notification.identifier 42 | 43 | cancelNotificationWithIdentifier(identifier: identifier!) 44 | notification.scheduled = false 45 | } 46 | 47 | // Cancel the notification if scheduled or queued 48 | public func cancelNotification (identifier : String) { 49 | 50 | 51 | cancelNotificationWithIdentifier(identifier: identifier) 52 | } 53 | 54 | private func cancelNotificationWithIdentifier (identifier: String) { 55 | UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [identifier]) 56 | 57 | let queue = DLQueue.queue.notificationsQueue() 58 | var i = 0 59 | for noti in queue { 60 | if identifier == noti.identifier { 61 | DLQueue.queue.removeAtIndex(i) 62 | break 63 | } 64 | i += 1 65 | } 66 | 67 | } 68 | 69 | public func getScheduledNotifications(handler:@escaping (_ request:[UNNotificationRequest]?)-> Void) { 70 | 71 | UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (requests) in 72 | handler(requests) 73 | }) 74 | 75 | } 76 | 77 | 78 | 79 | public func getScheduledNotification(with identifier: String, handler:@escaping (_ request:UNNotificationRequest?)-> Void) { 80 | 81 | 82 | var foundNotification:UNNotificationRequest? = nil 83 | UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (requests) in 84 | 85 | for request in requests { 86 | if let request1 = request.trigger as? UNTimeIntervalNotificationTrigger { 87 | if (request.identifier == identifier) { 88 | print("Timer interval notificaiton: \(request1.nextTriggerDate().debugDescription)") 89 | handler(request) 90 | } 91 | break 92 | 93 | } 94 | if let request2 = request.trigger as? UNCalendarNotificationTrigger { 95 | if (request.identifier == identifier) { 96 | handler(request) 97 | if(request2.repeats) { 98 | print(request) 99 | print("Calendar notification: \(request2.nextTriggerDate().debugDescription) and repeats") 100 | } else { 101 | print("Calendar notification: \(request2.nextTriggerDate().debugDescription) does not repeat") 102 | } 103 | break 104 | } 105 | 106 | } 107 | if let request3 = request.trigger as? UNLocationNotificationTrigger { 108 | 109 | print("Location notification: \(request3.region.debugDescription)") 110 | } 111 | } 112 | }) 113 | 114 | } 115 | 116 | public func printAllNotifications () { 117 | 118 | print("printing all notifications") 119 | UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (requests) in 120 | print(requests.count) 121 | for request in requests { 122 | if let request1 = request.trigger as? UNTimeIntervalNotificationTrigger { 123 | print("Timer interval notificaiton: \(request1.nextTriggerDate().debugDescription)") 124 | } 125 | if let request2 = request.trigger as? UNCalendarNotificationTrigger { 126 | if(request2.repeats) { 127 | print(request) 128 | print("Calendar notification: \(request2.nextTriggerDate().debugDescription) and repeats") 129 | } else { 130 | print("Calendar notification: \(request2.nextTriggerDate().debugDescription) does not repeat") 131 | } 132 | } 133 | if let request3 = request.trigger as? UNLocationNotificationTrigger { 134 | 135 | print("Location notification: \(request3.region.debugDescription)") 136 | } 137 | } 138 | }) 139 | } 140 | 141 | private func convertToNotificationDateComponent (notification: DLNotification, repeatInterval: RepeatingInterval ) -> DateComponents { 142 | 143 | print(notification.fromDateComponents != nil) 144 | let dateFromDateComponents = Calendar.current.date(from: notification.fromDateComponents!) 145 | var newComponents = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second ], from: dateFromDateComponents!) 146 | 147 | if repeatInterval != .none { 148 | 149 | switch repeatInterval { 150 | case .minute: 151 | newComponents = Calendar.current.dateComponents([ .second], from: dateFromDateComponents!) 152 | case .hourly: 153 | newComponents = Calendar.current.dateComponents([ .minute], from: dateFromDateComponents!) 154 | case .daily: 155 | newComponents = Calendar.current.dateComponents([.hour, .minute], from: dateFromDateComponents!) 156 | case .weekly: 157 | newComponents = Calendar.current.dateComponents([.hour, .minute, .weekday], from: dateFromDateComponents!) 158 | case .monthly: 159 | newComponents = Calendar.current.dateComponents([.hour, .minute, .day], from: dateFromDateComponents!) 160 | case .yearly: 161 | newComponents = Calendar.current.dateComponents([.hour, .minute, .day, .month], from: dateFromDateComponents!) 162 | default: 163 | break 164 | } 165 | } 166 | 167 | print(newComponents.debugDescription) 168 | return newComponents 169 | } 170 | 171 | fileprivate func queueNotification (notification: DLNotification) -> String? { 172 | 173 | if notification.scheduled { 174 | return nil 175 | } else { 176 | DLQueue.queue.push(notification) 177 | } 178 | 179 | return notification.identifier 180 | } 181 | 182 | public func scheduleNotification ( notification: DLNotification) { 183 | 184 | queueNotification(notification: notification) 185 | 186 | } 187 | 188 | public func scheduleAllNotifications () { 189 | 190 | let queue = DLQueue.queue.notificationsQueue() 191 | 192 | var count = 0 193 | for _ in queue { 194 | 195 | if count < min(DLNotificationScheduler.maximumScheduledNotifications, MAX_ALLOWED_NOTIFICATIONS) { 196 | let popped = DLQueue.queue.pop() 197 | scheduleNotificationInternal(notification: popped) 198 | count += 1 199 | } else { break } 200 | 201 | } 202 | } 203 | 204 | // Refactored for backwards compatability 205 | fileprivate func scheduleNotificationInternal ( notification: DLNotification) -> String? { 206 | 207 | if notification.scheduled { 208 | return nil 209 | } else { 210 | 211 | var trigger: UNNotificationTrigger? 212 | 213 | if (notification.region != nil) { 214 | trigger = UNLocationNotificationTrigger(region: notification.region!, repeats: false) 215 | 216 | 217 | } else { 218 | 219 | 220 | if let repeatInterval = notification.repeatInterval as? RepeatingInterval , let dateComponents = notification.fromDateComponents as? DateComponents { 221 | // If RepeatingInterval Notification 222 | trigger = UNCalendarNotificationTrigger(dateMatching: convertToNotificationDateComponent(notification: notification, repeatInterval: notification.repeatInterval), repeats: notification.repeats) 223 | } 224 | // If Date based notification 225 | else if let fireDate = notification.fireDate{ 226 | //trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: fireDate.timeIntervalSince(Date()), repeats: notification.repeats) 227 | 228 | if (notification.repeatInterval == .none) { 229 | trigger = UNCalendarNotificationTrigger(dateMatching: Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second ], from: fireDate) , repeats: notification.repeats) 230 | } 231 | } 232 | /* 233 | if (notification.repeatInterval == .minute) { 234 | trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: (TimeInterval(60)), repeats: notification.repeats) 235 | 236 | } 237 | 238 | if (notification.repeatInterval == .hourly) { 239 | trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: (TimeInterval(3600)), repeats: false) 240 | 241 | } 242 | */ 243 | 244 | 245 | 246 | 247 | } 248 | let content = UNMutableNotificationContent() 249 | 250 | content.title = notification.alertTitle! 251 | 252 | content.body = notification.alertBody! 253 | 254 | content.sound = notification.soundName == "" ? UNNotificationSound.default : UNNotificationSound.init(named: UNNotificationSoundName(rawValue: notification.soundName)) 255 | 256 | 257 | if (notification.soundName == "1") { content.sound = nil} 258 | 259 | if !(notification.attachments == nil) { content.attachments = notification.attachments! } 260 | 261 | if !(notification.launchImageName == nil) { content.launchImageName = notification.launchImageName! } 262 | 263 | if !(notification.category == nil) { content.categoryIdentifier = notification.category! } 264 | 265 | notification.localNotificationRequest = UNNotificationRequest(identifier: notification.identifier!, content: content, trigger: trigger!) 266 | 267 | let center = UNUserNotificationCenter.current() 268 | center.add(notification.localNotificationRequest!, withCompletionHandler: {(error) in 269 | if error != nil { 270 | print(error.debugDescription) 271 | } 272 | }) 273 | 274 | notification.scheduled = true 275 | } 276 | 277 | return notification.identifier 278 | 279 | } 280 | 281 | ///Persists the notifications queue to the disk 282 | ///> Call this method whenever you need to save changes done to the queue and/or before terminating the app. 283 | public func saveQueue() -> Bool { 284 | return DLQueue.queue.save() 285 | } 286 | ///- returns: Count of scheduled notifications by iOS. 287 | func scheduledCount(completion: @escaping (Int) -> Void) { 288 | UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (localNotifications) in 289 | completion(localNotifications.count) 290 | }) 291 | 292 | } 293 | 294 | // You have to manually keep in mind ios 64 notification limit 295 | 296 | public func repeatsFromToDate (identifier: String, alertTitle: String, alertBody: String, fromDate: Date, toDate: Date, interval: Double, repeats: RepeatingInterval, category: String = "åa", sound: String = " ") { 297 | 298 | 299 | // Create multiple Notifications 300 | 301 | let intervalDifference = Int( toDate.timeIntervalSince(fromDate) / interval ) 302 | 303 | var nextDate = fromDate 304 | 305 | 306 | for i in 0..() 327 | 328 | for category in categories { 329 | 330 | guard let categoryInstance = category.categoryInstance else { continue } 331 | notificationCategories.insert(categoryInstance) 332 | 333 | } 334 | 335 | UNUserNotificationCenter.current().setNotificationCategories(notificationCategories) 336 | 337 | } 338 | 339 | } 340 | 341 | // Repeating Interval Times 342 | 343 | public enum RepeatingInterval: String { 344 | case none, minute, hourly, daily, weekly, monthly, yearly 345 | } 346 | 347 | extension Date { 348 | 349 | func removeSeconds() -> Date { 350 | let calendar = Calendar.current 351 | let components = (calendar as NSCalendar).components([.year, .month, .day, .hour, .minute], from: self) 352 | return calendar.date(from: components)! 353 | } 354 | } 355 | 356 | -------------------------------------------------------------------------------- /DLLocalNotifications/DLNotification.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLNotification.swift 3 | // DLLocalNotifications 4 | // 5 | // Created by Devesh Laungani on 6/10/18. 6 | // Copyright © 2018 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | // A wrapper class for creating a User Notification 10 | import UserNotifications 11 | import MapKit 12 | 13 | @available(iOS 10.0, *) 14 | public class DLNotification { 15 | 16 | // Contains the internal instance of the notification 17 | internal var localNotificationRequest: UNNotificationRequest? 18 | 19 | // Holds the repeat interval of the notification with Enum Type Repeats 20 | var repeatInterval: RepeatingInterval = .none 21 | 22 | // Holds the body of the message of the notification 23 | var alertBody: String? 24 | 25 | // Holds the title of the message of the notification 26 | var alertTitle: String? 27 | 28 | // Holds name of the music file of the notification 29 | var soundName: String = "" 30 | 31 | // Holds the date that the notification will be first fired 32 | var fireDate: Date? 33 | 34 | // Know if a notification repeats from this value 35 | var repeats: Bool = false 36 | 37 | // Keep track if a notification is scheduled 38 | var scheduled: Bool = false 39 | 40 | // Hold the identifier of the notification to keep track of it 41 | public var identifier: String? 42 | 43 | // Hold the attachments for the notifications 44 | var attachments: [UNNotificationAttachment]? 45 | 46 | // Hold the launch image of a notification 47 | var launchImageName: String? 48 | 49 | // Hold the category of the notification if you want to set one 50 | public var category: String? 51 | 52 | // If it is a region based notification then you can access the notification 53 | var region: CLRegion? 54 | 55 | // Internal variable needed when changint Notification types 56 | var hasDataFromBefore = false 57 | 58 | // Holds date components for a repeating notification 59 | public var fromDateComponents: DateComponents? 60 | 61 | enum CodingKeys: String, CodingKey { 62 | case localNotificationRequest 63 | case repeatInterval 64 | case alertBody 65 | case alertTitle 66 | case soundName 67 | case fireDate 68 | case repeats 69 | case scheduled 70 | case identifier 71 | case attachments 72 | case launchImageName 73 | case category 74 | case region 75 | case hasDataFromBefore 76 | case fromDateComponents 77 | } 78 | 79 | 80 | public init(request: UNNotificationRequest) { 81 | 82 | self.hasDataFromBefore = true 83 | self.localNotificationRequest = request 84 | if let calendarTrigger = request.trigger as? UNCalendarNotificationTrigger { 85 | self.fireDate = calendarTrigger.nextTriggerDate() 86 | } else if let intervalTrigger = request.trigger as? UNTimeIntervalNotificationTrigger { 87 | self.fireDate = intervalTrigger.nextTriggerDate() 88 | } 89 | } 90 | 91 | public init (identifier: String, alertTitle: String, alertBody: String, fromDateComponents: DateComponents, repeatInterval: RepeatingInterval ) { 92 | 93 | self.alertBody = alertBody 94 | self.alertTitle = alertTitle 95 | self.repeatInterval = repeatInterval 96 | self.identifier = identifier 97 | self.fromDateComponents = fromDateComponents 98 | if (repeats == .none) { 99 | self.repeats = false 100 | } else { 101 | self.repeats = true 102 | } 103 | 104 | } 105 | 106 | public init (identifier: String, alertTitle: String, alertBody: String, date: Date ) { 107 | 108 | self.alertBody = alertBody 109 | self.alertTitle = alertTitle 110 | self.fireDate = date 111 | self.repeatInterval = .none 112 | self.identifier = identifier 113 | self.repeats = false 114 | 115 | } 116 | 117 | 118 | // Region based notification 119 | // Default notifyOnExit is false and notifyOnEntry is true 120 | 121 | public init (identifier: String, alertTitle: String, alertBody: String, region: CLRegion ) { 122 | 123 | self.alertBody = alertBody 124 | self.alertTitle = alertTitle 125 | self.identifier = identifier 126 | region.notifyOnExit = false 127 | region.notifyOnEntry = true 128 | self.region = region 129 | 130 | } 131 | 132 | init(from decoder: Decoder) throws { 133 | 134 | let container = try decoder.container(keyedBy: CodingKeys.self) 135 | let repeatString = try container.decode(String.self, forKey: .repeatInterval) 136 | self.repeatInterval = RepeatingInterval(rawValue: repeatString)! 137 | self.alertTitle = try container.decodeIfPresent(String.self, forKey: .alertTitle) 138 | self.alertBody = try container.decodeIfPresent(String.self, forKey: .alertBody) 139 | self.soundName = try container.decode(String.self, forKey: .soundName) 140 | self.fireDate = try container.decodeIfPresent(Date.self, forKey: .fireDate) 141 | self.repeats = try container.decode(Bool.self, forKey: .repeats) 142 | self.scheduled = try container.decode(Bool.self, forKey: .scheduled) 143 | self.identifier = try container.decodeIfPresent(String.self, forKey: .identifier) 144 | self.launchImageName = try container.decodeIfPresent(String.self, forKey: .launchImageName) 145 | self.category = try container.decodeIfPresent(String.self, forKey: .category) 146 | self.hasDataFromBefore = try container.decode(Bool.self, forKey: .hasDataFromBefore) 147 | //self.fromDateComponents = try container.decode(DateComponents.self, forKey: .fromDateComponents) 148 | 149 | } 150 | func encode(to encoder: Encoder) throws 151 | { 152 | var container = encoder.container(keyedBy: CodingKeys.self) 153 | 154 | 155 | try container.encode(repeatInterval.rawValue, forKey: CodingKeys.repeatInterval) 156 | try container.encode(alertTitle, forKey: .alertTitle) 157 | try container.encode(alertBody, forKey: .alertBody) 158 | try container.encode(soundName, forKey: .soundName) 159 | try container.encode(fireDate, forKey: .fireDate) 160 | try container.encode(repeats, forKey: .repeats) 161 | try container.encode(scheduled, forKey: .scheduled) 162 | try container.encode(identifier, forKey: .identifier) 163 | try container.encode(launchImageName, forKey: .launchImageName) 164 | try container.encode(category, forKey: .category) 165 | try container.encode(hasDataFromBefore, forKey: .hasDataFromBefore) 166 | //try container.encode(fromDateComponents, forKey: .fromDateComponents) 167 | 168 | } 169 | 170 | public var debugDescription : String { 171 | 172 | return "" 173 | } 174 | } 175 | 176 | 177 | -------------------------------------------------------------------------------- /DLLocalNotifications/DLQueue.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLQueue.swift 3 | // DLLocalNotifications 4 | // 5 | // Created by Devesh Laungani on 6/10/18. 6 | // Copyright © 2018 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | 10 | @available(iOS 10.0, *) 11 | public 12 | class DLQueue: NSObject { 13 | 14 | internal var notifQueue = [DLNotification]() 15 | static let queue = DLQueue() 16 | let ArchiveURL = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("notifications.dlqueue") 17 | 18 | override init() { 19 | super.init() 20 | if let notificationQueue = self.load() { 21 | notifQueue = notificationQueue 22 | } 23 | } 24 | 25 | internal func push(_ notification: DLNotification) { 26 | notifQueue.insert(notification, at: findInsertionPoint(notification)) 27 | } 28 | 29 | /// Finds the position at which the new DLNotification is inserted in the queue. 30 | /// - seealso: [swift-algorithm-club](https://github.com/hollance/swift-algorithm-club/tree/master/Ordered%20Array) 31 | internal func findInsertionPoint(_ notification: DLNotification) -> Int { 32 | let range = 0.. DLNotification { 52 | return notifQueue.removeFirst() 53 | } 54 | 55 | //Returns the head of the queue. 56 | 57 | internal func peek() -> DLNotification? { 58 | return notifQueue.last 59 | } 60 | 61 | ///Clears the queue. 62 | 63 | internal func clear() { 64 | notifQueue.removeAll() 65 | } 66 | 67 | ///Called when a DLLocalnotification is cancelled. 68 | 69 | internal func removeAtIndex(_ index: Int) { 70 | notifQueue.remove(at: index) 71 | } 72 | 73 | // Returns Count of DLNotifications in the queue. 74 | internal func count() -> Int { 75 | return notifQueue.count 76 | } 77 | 78 | // Returns The notifications queue. 79 | internal func notificationsQueue() -> [DLNotification] { 80 | let queue = notifQueue 81 | return queue 82 | } 83 | 84 | // Returns DLLocalnotifcation if found, nil otherwise. 85 | internal func notificationWithIdentifier(_ identifier: String) -> DLNotification? { 86 | for note in notifQueue { 87 | if note.identifier == identifier { 88 | return note 89 | } 90 | } 91 | return nil 92 | } 93 | 94 | 95 | ///Save queue on disk. 96 | 97 | internal func save() -> Bool { 98 | return NSKeyedArchiver.archiveRootObject(self.notifQueue, toFile: ArchiveURL.path) 99 | } 100 | 101 | ///Load queue from disk. 102 | ///Called first when instantiating the DLQueue singleton. 103 | ///You do not need to manually call this method 104 | 105 | internal func load() -> [DLNotification]? { 106 | return NSKeyedUnarchiver.unarchiveObject(withFile: ArchiveURL.path) as? [DLNotification] 107 | } 108 | 109 | } 110 | 111 | 112 | // Helper function to compare notification types 113 | 114 | @available(iOS 10.0, *) 115 | public func <(lhs: DLNotification, rhs: DLNotification) -> Bool { 116 | return lhs.fireDate?.compare(rhs.fireDate!) == ComparisonResult.orderedAscending 117 | } 118 | @available(iOS 10.0, *) 119 | public func ==(lhs: DLNotification, rhs: DLNotification) -> Bool { 120 | return lhs.identifier == rhs.identifier 121 | } 122 | -------------------------------------------------------------------------------- /DLLocalNotifications/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | DLUserNotifications 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /DLLocalNotificationsHost/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DLLocalNotificationsHost 4 | // 5 | // Created by Devesh Laungani on 1/13/19. 6 | // Copyright © 2019 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in 20 | if success { 21 | print("All set!") 22 | } else if let error = error { 23 | print(error.localizedDescription) 24 | } 25 | } 26 | return true 27 | } 28 | 29 | func applicationWillResignActive(_ application: UIApplication) { 30 | // 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. 31 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 32 | } 33 | 34 | func applicationDidEnterBackground(_ application: UIApplication) { 35 | // 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. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | func applicationWillEnterForeground(_ application: UIApplication) { 40 | // 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. 41 | } 42 | 43 | func applicationDidBecomeActive(_ application: UIApplication) { 44 | // 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. 45 | } 46 | 47 | func applicationWillTerminate(_ application: UIApplication) { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /DLLocalNotificationsHost/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 | } -------------------------------------------------------------------------------- /DLLocalNotificationsHost/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /DLLocalNotificationsHost/Assets.xcassets/test.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "test.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DLLocalNotificationsHost/Assets.xcassets/test.imageset/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d7laungani/DLLocalNotifications/24df54f93310cda8a7e952345de8b9c0fbcda1fe/DLLocalNotificationsHost/Assets.xcassets/test.imageset/test.png -------------------------------------------------------------------------------- /DLLocalNotificationsHost/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 | -------------------------------------------------------------------------------- /DLLocalNotificationsHost/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 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DLLocalNotificationsHost/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 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DLLocalNotificationsHost/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DLLocalNotificationsHost 4 | // 5 | // Created by Devesh Laungani on 1/13/19. 6 | // Copyright © 2019 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | 17 | } 18 | 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /DLLocalNotificationsHostUITests/DLLocalNotificationsHostUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLLocalNotificationsHostUITests.swift 3 | // DLLocalNotificationsHostUITests 4 | // 5 | // Created by Devesh Laungani on 1/19/21. 6 | // Copyright © 2021 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class DLLocalNotificationsHostUITests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | continueAfterFailure = false 18 | 19 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 20 | 21 | 22 | 23 | } 24 | 25 | override func tearDownWithError() throws { 26 | // Put teardown code here. This method is called after the invocation of each test method in the class. 27 | } 28 | 29 | func testExample() throws { 30 | // UI tests must launch the application that they test. 31 | let app = XCUIApplication() 32 | addUIInterruptionMonitor(withDescription: "Notification Permission") { 33 | (alert) -> Bool in 34 | alert.buttons["Allow"].tap() 35 | return true 36 | } 37 | app.launch() 38 | app.tap() 39 | // Use recording to get started writing UI tests. 40 | // Use XCTAssert and related functions to verify your tests produce the correct results. 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DLLocalNotificationsHostUITests/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 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /DLLocalNotificationsTests/DLLocalNotificationsTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLLocalNotificationsTests.swift 3 | // DLLocalNotificationsTests 4 | // 5 | // Created by Devesh Laungani on 12/14/16. 6 | // Copyright © 2016 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import DLLocalNotifications 11 | import UserNotifications 12 | 13 | class DLLocalNotificationsTests: XCTestCase { 14 | 15 | let scheduler = DLNotificationScheduler() 16 | 17 | 18 | override func setUp() { 19 | super.setUp() 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | scheduler.cancelAlllNotifications() 23 | } 24 | 25 | override func tearDown() { 26 | // Put teardown code here. This method is called after the invocation of each test method in the class. 27 | super.tearDown() 28 | scheduler.cancelAlllNotifications() 29 | } 30 | 31 | func testBasicNotification() { 32 | 33 | let content = UNMutableNotificationContent() 34 | content.title = "Feed the cat" 35 | content.subtitle = "It looks hungry" 36 | content.sound = UNNotificationSound.default() 37 | 38 | // show this notification five seconds from now 39 | let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false) 40 | 41 | // choose a random identifier 42 | let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) 43 | 44 | // add our notification request 45 | //UNUserNotificationCenter.current().add(request) 46 | let center = UNUserNotificationCenter.current() 47 | center.add(request) { (error) in 48 | print(error.debugDescription) 49 | } 50 | 51 | let expectationTemp = expectation(description: "Notification not scheduled") 52 | 53 | UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (requests) in 54 | XCTAssertEqual(1, requests.count) 55 | expectationTemp.fulfill() 56 | 57 | }) 58 | 59 | waitForExpectations(timeout: 10, handler: nil) 60 | 61 | } 62 | 63 | func testSingleFireNotification() { 64 | // This is an example of a functional test case. 65 | // Use XCTAssert and related functions to verify your tests produce the correct results. 66 | // The date you would like the notification to fire at 30 second mark of every minute 67 | let triggerDate = Date().addingTimeInterval(300) 68 | 69 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", date: triggerDate) 70 | 71 | scheduler.scheduleNotification(notification: firstNotification) 72 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 73 | scheduler.scheduleAllNotifications() 74 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 75 | XCTAssertEqual(true, firstNotification.scheduled) 76 | 77 | 78 | let expectationTemp = expectation(description: "Notification not scheduled") 79 | 80 | 81 | scheduler.getScheduledNotification(with: firstNotification.identifier!){ (request) -> Void in 82 | if let request = request{ 83 | 84 | let trigger = request.trigger as? UNCalendarNotificationTrigger 85 | XCTAssertEqual(request.identifier, firstNotification.identifier) 86 | XCTAssertEqual(triggerDate.timeIntervalSince1970.rounded(), (trigger?.nextTriggerDate()?.timeIntervalSince1970.rounded())!, accuracy: 0.002) 87 | XCTAssertFalse(trigger!.repeats) 88 | 89 | expectationTemp.fulfill() 90 | } 91 | } 92 | 93 | waitForExpectations(timeout: 10, handler: nil) 94 | 95 | } 96 | 97 | func testRepeatingNotificationMinute() { 98 | // This is an example of a functional test case. 99 | // Use XCTAssert and related functions to verify your tests produce the correct results. 100 | 101 | // The date you would like the notification to fire at 30 second mark of every minute 102 | var dateComponents = DateComponents() 103 | dateComponents.second = 30 104 | 105 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", fromDateComponents: dateComponents, repeatInterval: .minute) 106 | 107 | scheduler.scheduleNotification(notification: firstNotification) 108 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 109 | scheduler.scheduleAllNotifications() 110 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 111 | XCTAssertEqual(true, firstNotification.scheduled) 112 | 113 | let expectationTemp = expectation(description: "Next Trigger Date Does not match expectation") 114 | 115 | 116 | scheduler.getScheduledNotification(with: firstNotification.identifier!){ (request) -> Void in 117 | if let request = request{ 118 | let trigger = request.trigger as? UNCalendarNotificationTrigger 119 | 120 | var actualTriggerTime = Calendar.current.dateComponents([ .second], from: (trigger!.nextTriggerDate())!) 121 | 122 | 123 | XCTAssertEqual(dateComponents,actualTriggerTime) 124 | XCTAssertTrue(trigger!.repeats) 125 | 126 | expectationTemp.fulfill() 127 | } 128 | } 129 | 130 | waitForExpectations(timeout: 10, handler: nil) 131 | 132 | 133 | 134 | } 135 | 136 | func testRepeatingNotificationHour() { 137 | // This is an example of a functional test case. 138 | // Use XCTAssert and related functions to verify your tests produce the correct results. 139 | 140 | // The date you would like the notification to fire at :30 mins every hour 141 | 142 | var dateComponents = DateComponents() 143 | dateComponents.minute = 30 144 | dateComponents.second = 0 145 | 146 | let firstNotification = DLNotification(identifier: "hourlyNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", fromDateComponents: dateComponents, repeatInterval: .hourly) 147 | 148 | scheduler.scheduleNotification(notification: firstNotification) 149 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 150 | scheduler.scheduleAllNotifications() 151 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 152 | XCTAssertEqual(true, firstNotification.scheduled) 153 | 154 | let expectationTemp = expectation(description: "Next Trigger Date Does not match expectation") 155 | scheduler.getScheduledNotification(with: firstNotification.identifier!){ (request) -> Void in 156 | if let request = request{ 157 | let trigger = request.trigger as? UNCalendarNotificationTrigger 158 | 159 | 160 | var actualTriggerTime = Calendar.current.dateComponents([ .minute, .second], from: (trigger!.nextTriggerDate())!) 161 | 162 | 163 | XCTAssertEqual(dateComponents,actualTriggerTime) 164 | XCTAssertTrue(trigger!.repeats) 165 | 166 | 167 | expectationTemp.fulfill() 168 | } 169 | } 170 | 171 | waitForExpectations(timeout: 20, handler: nil) 172 | 173 | 174 | 175 | } 176 | 177 | 178 | func testNotificationCancel() { 179 | let triggerDate = Date().addingTimeInterval(300) 180 | 181 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", date: triggerDate) 182 | 183 | scheduler.scheduleNotification(notification: firstNotification) 184 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 185 | scheduler.scheduleAllNotifications() 186 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 187 | XCTAssertEqual(true, firstNotification.scheduled) 188 | 189 | let expectationTemp1 = expectation(description: "Initial Notification exists") 190 | 191 | scheduler.getScheduledNotifications { (requests) in 192 | XCTAssertEqual(1, requests?.count) 193 | expectationTemp1.fulfill() 194 | } 195 | 196 | 197 | scheduler.cancelNotification(notification: firstNotification) 198 | XCTAssertEqual(false, firstNotification.scheduled) 199 | 200 | let expectationTemp = expectation(description: "Removed from apple notification queue") 201 | 202 | scheduler.getScheduledNotifications { (requests) in 203 | XCTAssertEqual(0, requests?.count) 204 | expectationTemp.fulfill() 205 | } 206 | 207 | 208 | waitForExpectations(timeout: 10, handler: nil) 209 | 210 | 211 | 212 | } 213 | 214 | func testNotificationCancelWithIdentifier() { 215 | let triggerDate = Date().addingTimeInterval(300) 216 | let identifier = "firstNotification" 217 | let firstNotification = DLNotification(identifier: identifier, alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", date: triggerDate) 218 | 219 | scheduler.scheduleNotification(notification: firstNotification) 220 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 221 | scheduler.scheduleAllNotifications() 222 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 223 | XCTAssertEqual(true, firstNotification.scheduled) 224 | 225 | let expectationTemp1 = expectation(description: "Initial Notification exists") 226 | 227 | scheduler.getScheduledNotifications { (requests) in 228 | XCTAssertEqual(1, requests?.count) 229 | expectationTemp1.fulfill() 230 | } 231 | 232 | 233 | scheduler.cancelNotification(identifier: identifier) 234 | 235 | let expectationTemp = expectation(description: "Removed from apple notification queue") 236 | 237 | scheduler.getScheduledNotifications { (requests) in 238 | XCTAssertEqual(0, requests?.count) 239 | expectationTemp.fulfill() 240 | } 241 | 242 | 243 | waitForExpectations(timeout: 10, handler: nil) 244 | 245 | 246 | 247 | } 248 | 249 | 250 | 251 | // Regression tests 252 | 253 | 254 | // Issue #26 255 | func testSettingALaunchImage() { 256 | // This is an example of a functional test case. 257 | // Use XCTAssert and related functions to verify your tests produce the correct results. 258 | // The date you would like the notification to fire at 259 | let triggerDate = Date().addingTimeInterval(20) 260 | 261 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", date: triggerDate) 262 | 263 | firstNotification.launchImageName = "test.png" 264 | 265 | scheduler.scheduleNotification(notification: firstNotification) 266 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 267 | scheduler.scheduleAllNotifications() 268 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 269 | XCTAssertEqual(true, firstNotification.scheduled) 270 | 271 | let expectationTemp = expectation(description: "Launch Image is set on notification") 272 | 273 | scheduler.getScheduledNotification(with: firstNotification.identifier!){ (request) -> Void in 274 | if let request = request{ 275 | 276 | XCTAssertNotNil(request.content.launchImageName) 277 | 278 | expectationTemp.fulfill() 279 | } 280 | } 281 | 282 | waitForExpectations(timeout: 10, handler: nil) 283 | 284 | } 285 | 286 | 287 | // Issue #25 288 | public func testRepeatEvery3Hrs() { 289 | 290 | // Repeats at 9am, 12pm, and 3pm and 6pm 291 | // if you don't want 6pm then remove a minute from the end date 292 | let triggerDate9am = Calendar.current.date(bySettingHour: 9, minute: 0, second: 0, of: Date())! 293 | let triggerDate6pm = Calendar.current.date(bySettingHour: 18, minute: 0, second: 0, of: Date())! 294 | 295 | scheduler.repeatsFromToDate(identifier: "First Notification", alertTitle: "Multiple Notifications", alertBody: "Progress", fromDate: triggerDate9am, toDate: triggerDate6pm , interval: 10800, repeats: .daily ) 296 | 297 | XCTAssertEqual(4, scheduler.notificationsQueue().count) 298 | scheduler.scheduleAllNotifications() 299 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 300 | 301 | let calendar = Calendar.current 302 | 303 | 304 | let expectationTemp = expectation(description: "All Notifications scheduled") 305 | scheduler.getScheduledNotifications { (requests) in 306 | 307 | XCTAssertEqual(4, requests?.count) 308 | 309 | let triggerDate12pm = calendar.date(bySettingHour: 12, minute: 0, second: 0, of: Date())! 310 | let triggerDate3pm = calendar.date(bySettingHour: 15, minute: 0, second: 0, of: Date())! 311 | 312 | var expectedDates:[Date] = [triggerDate6pm, triggerDate3pm, triggerDate12pm,triggerDate9am] 313 | 314 | for (index, request) in requests!.enumerated() { 315 | 316 | var trigger = request.trigger as? UNCalendarNotificationTrigger 317 | var expectedTriggerTime = calendar.dateComponents([.hour, .minute], from: expectedDates[index]) 318 | var actualTriggerTime = calendar.dateComponents([.hour, .minute], from: (trigger?.nextTriggerDate())!) 319 | XCTAssertEqual(expectedTriggerTime,actualTriggerTime) 320 | 321 | 322 | 323 | } 324 | 325 | 326 | 327 | expectationTemp.fulfill() 328 | } 329 | 330 | waitForExpectations(timeout: 10, handler: nil) 331 | 332 | 333 | } 334 | 335 | /* 336 | // Issue #15 337 | public func testDelayedNotificationFiringImmediatelyForMinuteRepetition() { 338 | 339 | // The date you would like the notification to fire at 30 second mark of every minute 340 | var dateComponents = DateComponents() 341 | dateComponents.seconds = 30 342 | 343 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", fromDateComponents: dateComponents, repeatInterval: .minute) 344 | 345 | let scheduler = DLNotificationScheduler() 346 | scheduler.scheduleNotification(notification: firstNotification) 347 | 348 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 349 | scheduler.scheduleAllNotifications() 350 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 351 | 352 | let calendar = Calendar.current 353 | 354 | 355 | let expectationTemp = expectation(description: "All Notifications scheduled") 356 | scheduler.getScheduledNotifications { (requests) in 357 | 358 | 359 | if let request = requests?[safe: 0] { 360 | if let request2 = request.trigger as? UNCalendarNotificationTrigger { 361 | 362 | var expectedTriggerTime = calendar.dateComponents([.hour, .minute], from: triggerDate) 363 | var actualTriggerTime = calendar.dateComponents([.hour, .minute], from: (request2.nextTriggerDate())!) 364 | 365 | print("expected :" + triggerDate.debugDescription) 366 | print("actual :" + request2.nextTriggerDate().debugDescription) 367 | 368 | XCTAssertEqual(expectedTriggerTime,actualTriggerTime) 369 | 370 | 371 | expectationTemp.fulfill() 372 | 373 | }} 374 | 375 | } 376 | 377 | waitForExpectations(timeout: 10, handler: nil) 378 | 379 | 380 | 381 | } 382 | 383 | // Issue #15 384 | public func testDelayedNotificationFiringImmediatelyForDailyDelayedRepetition() { 385 | 386 | let triggerDate = Date().addingTimeInterval(3*24*60*60) 387 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", date: triggerDate, repeats: .daily) 388 | 389 | let scheduler = DLNotificationScheduler() 390 | scheduler.scheduleNotification(notification: firstNotification) 391 | 392 | XCTAssertEqual(1, scheduler.notificationsQueue().count) 393 | scheduler.scheduleAllNotifications() 394 | XCTAssertEqual(0, scheduler.notificationsQueue().count) 395 | 396 | let calendar = Calendar.current 397 | 398 | 399 | let expectationTemp = expectation(description: "All Notifications scheduled") 400 | scheduler.getScheduledNotifications { (requests) in 401 | 402 | if let request = requests?[safe: 0] { 403 | if let request2 = request.trigger as? UNCalendarNotificationTrigger { 404 | 405 | var expectedTriggerTime = calendar.dateComponents([.hour, .minute], from: triggerDate) 406 | var actualTriggerTime = calendar.dateComponents([.hour, .minute], from: (request2.nextTriggerDate())!) 407 | 408 | print("expected :" + triggerDate.debugDescription) 409 | print("actual :" + request2.nextTriggerDate().debugDescription) 410 | 411 | XCTAssertEqual(expectedTriggerTime,actualTriggerTime) 412 | 413 | XCTAssertEqual(request2.nextTriggerDate()!.days(from: triggerDate), 1) 414 | expectationTemp.fulfill() 415 | 416 | 417 | }} 418 | 419 | } 420 | 421 | waitForExpectations(timeout: 10, handler: nil) 422 | 423 | 424 | 425 | } 426 | */ 427 | } 428 | 429 | extension Collection { 430 | 431 | /// Returns the element at the specified index if it is within bounds, otherwise nil. 432 | subscript (safe index: Index) -> Element? { 433 | return indices.contains(index) ? self[index] : nil 434 | } 435 | } 436 | extension Date { 437 | 438 | /// Returns the amount of days from another date 439 | func days(from date: Date) -> Int { 440 | return Calendar.current.dateComponents([.day], from: date, to: self).day ?? 0 441 | } 442 | 443 | } 444 | -------------------------------------------------------------------------------- /DLLocalNotificationsTests/DLSchedulerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DLSchedulerTests.swift 3 | // DLLocalNotifications 4 | // 5 | // Created by Devesh Laungani on 1/16/17. 6 | // Copyright © 2017 Devesh Laungani. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | -------------------------------------------------------------------------------- /DLLocalNotificationsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Devesh Laungani 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | 6 | [![Swift Version][swift-image]][swift-url] 7 | [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/DLLocalNotifications.svg)][podLink] 8 | ![Platform](https://img.shields.io/badge/platforms-iOS%2010.0+-333333.svg) 9 | [![Build Status](https://travis-ci.org/d7laungani/DLLocalNotifications.svg?branch=master)](https://travis-ci.org/d7laungani/DLLocalNotifications) 10 | [![License][license-image]][license-url] 11 | 12 | In IOS 10, apple updated their library for Notifications and separated Local and push notifications to a new framework: 13 | 14 | [User Notifications](https://developer.apple.com/reference/usernotifications) 15 | 16 | This library makes it easy to setup a local notification and also includes easy configuration for repeating notifications using [ .None, .Minute, .Hourly, .Daily, .Monthly, .Yearly] . 17 | 18 | It also includes all the new features, including inserting attachments and changing the launch image of a notification. 19 | 20 | 1. [Features](#features) 21 | 2. [Requirements](#requirements) 22 | 3. [Installation](#installation) 23 | - [CocoaPods](#cocoapods) 24 | - [Manually](#manually) 25 | 4. [Usage](#usage) 26 | - [Single Fire Notification](#single-fire-notification) 27 | - [Repeating Notification starting at a Date](#repeating-notification-starting-at-a-date) 28 | - [Notification that repeats from one Date to another with a time interval period](#notification-that-repeats-from-one-date-to-another-with-a-time-interval-period) 29 | - [Modifying elements of the notification](#modifying-elements-of-the-notification) 30 | - [Location Based Notification](#location-based-notification) 31 | - [Action Buttons](#adding-action-buttons-to-a-notification) 32 | 5. [Contribute](#contribute) 33 | 34 | ## Features 35 | 36 | - [x] Easily Repeat Notifications 37 | - [x] Location Based Notifications 38 | - [x] Category Action buttons 39 | - [x] Queue to enforce 64 notification limit 40 | 41 | ## Requirements 42 | 43 | - iOS 10.0+ 44 | - Xcode 8.0+ 45 | 46 | ## Installation 47 | 48 | #### CocoaPods 49 | You can use [CocoaPods](http://cocoapods.org/) to install `DLLocalNotifications` by adding it to your `Podfile`: 50 | 51 | ```ruby 52 | platform :ios, '10.0' 53 | use_frameworks! 54 | 55 | target 'MyApp' do 56 | pod 'DLLocalNotifications' 57 | end 58 | ``` 59 | Note: your iOS deployment target must be 10.0+ 60 | 61 | ## Usage 62 | 63 | ### Single fire notification (any date) 64 | 65 | Notification that fires once at the date time inputted 66 | 67 | Note: If you want the notification to repeat then you need to create a 68 | notification based on date components 69 | 70 | ```swift 71 | 72 | // The date you would like the notification to fire at 73 | let triggerDate = Date().addingTimeInterval(300) 74 | 75 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", date: triggerDate) 76 | 77 | let scheduler = DLNotificationScheduler() 78 | scheduler.scheduleNotification(notification: firstNotification) 79 | scheduler.scheduleAllNotifications() 80 | ``` 81 | 82 | ### Repeating Notification based on date components 83 | 84 | The configuration of the repetition is chosen in the repeats parameter that can be [ .none, .minute, .hourly, .daily, .monthly, .yearly] . 85 | 86 | ```swift 87 | 88 | // The date you would like the notification to fire at :35 mins every hour 89 | 90 | var dateComponents = DateComponents() 91 | dateComponents.minute = 35 92 | dateComponents.second = 0 93 | 94 | let firstNotification = DLNotification(identifier: "hourlyNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", fromDateComponents: dateComponents, repeatInterval: .hourly) 95 | 96 | let scheduler = DLNotificationScheduler() 97 | scheduler.scheduleNotification(notification: firstNotification) 98 | scheduler.scheduleAllNotifications() 99 | ``` 100 | 101 | ### Notification that repeats from one Date to another with a time interval period 102 | 103 | This is useful to setup notifications to repeat every specific time interval for in a specific time period of the day. 104 | ```swift 105 | 106 | let scheduler = DLNotificationScheduler() 107 | 108 | // This notification repeats every 15 seconds from a time period starting from 15 seconds from the current time till 5 minutes from the current time 109 | 110 | scheduler.repeatsFromToDate(identifier: "First Notification", alertTitle: "Multiple Notifications", alertBody: "Progress", fromDate: Date().addingTimeInterval(15), toDate: Date().addingTimeInterval(300) , interval: 15, repeats: .none ) 111 | scheduler.scheduleAllNotifications() 112 | 113 | ``` 114 | Note: Since this library takes care of the 64 notification limit you would want to call scheduler.scheduleAllNotifications() in your AppDelegate file as well. 115 | 116 | ### Modifying elements of the notification 117 | 118 | You can modify elements of the notification before scheduling. Publically accessible variables include: 119 | 120 | repeatInterval, alertBody, alertTitle, soundName, fireDate, attachments, launchImageName, category 121 | 122 | ```swift 123 | 124 | let firstNotification = DLNotification(identifier: "firstNotification", alertTitle: "Notification Alert", alertBody: "You have successfully created a notification", date: Date(), repeats: .minute) 125 | 126 | // You can now change the repeat interval here 127 | firstNotification.repeatInterval = .yearly 128 | 129 | // You can add a launch image name 130 | firstNotification.launchImageName = "Hello.png" 131 | 132 | let scheduler = DLNotificationScheduler() 133 | scheduler.scheduleNotification(notification: firstNotification) 134 | scheduler.scheduleAllNotifications() 135 | ``` 136 | ### Location Based Notification 137 | 138 | The notification is triggered when a user enters a geo-fenced area. 139 | 140 | ```swift 141 | 142 | let center = CLLocationCoordinate2D(latitude: 37.335400, longitude: -122.009201) 143 | let region = CLCircularRegion(center: center, radius: 2000.0, identifier: "Headquarters") 144 | region.notifyOnEntry = true 145 | region.notifyOnExit = false 146 | 147 | let locationNotification = DLNotification(identifier: "LocationNotification", alertTitle: "Notification Alert", alertBody: "You have reached work", region: region ) 148 | 149 | let scheduler = DLNotificationScheduler() 150 | scheduler.scheduleNotification(notification: locationNotification) 151 | scheduler.scheduleAllNotifications() 152 | ``` 153 | 154 | ### Adding action buttons to a notification 155 | 156 | ```swift 157 | 158 | let scheduler = DLNotificationScheduler() 159 | 160 | let standingCategory = DLCategory(categoryIdentifier: "standingReminder") 161 | 162 | standingCategory.addActionButton(identifier: "willStand", title: "Ok, got it") 163 | standingCategory.addActionButton(identifier: "willNotStand", title: "Cannot") 164 | 165 | scheduler.scheduleCategories(categories: [standingCategory]) 166 | 167 | ``` 168 | Don't forget to the set the notification category before scheduling the notification using 169 | 170 | ```swift 171 | notification.category = "standingReminder" 172 | ``` 173 | 174 | ### Cancelling a notification 175 | 176 | ```swift 177 | 178 | scheduler.cancelNotification(notification: notification) 179 | 180 | 181 | ``` 182 | 183 | 184 | ## Contribute 185 | 186 | We would love for you to contribute to **DLLocalNotifications**, check the ``LICENSE`` file for more info. 187 | 188 | ## Meta 189 | 190 | Devesh Laungani – [@d7laungani](https://twitter.com/d7laungani) 191 | 192 | Distributed under the MIT license. See ``LICENSE`` for more information 193 | 194 | [https://github.com/d7laungani/](https://github.com/d7laungani/) 195 | 196 | [Hire Me](http://deveshlaungani.com/) 197 | 198 | [swift-image]:https://img.shields.io/badge/swift-4.2-orange.svg 199 | [swift-url]: https://swift.org/ 200 | [license-image]: https://img.shields.io/badge/License-MIT-blue.svg 201 | [license-url]: LICENSE 202 | [podLink]:https://cocoapods.org/pods/DLLocalNotifications 203 | --------------------------------------------------------------------------------