├── .gitignore ├── LocPushSample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── LocPushSample ├── AppDelegate.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── LocalPush │ ├── LocalPush.swift │ └── UIApplication+CurrentScreen.swift ├── SceneDelegate.swift └── ViewController.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /LocPushSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 450F09272596478D005ADCFF /* UIApplication+CurrentScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 450F09262596478D005ADCFF /* UIApplication+CurrentScreen.swift */; }; 11 | 45EB46272593B26500458E77 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EB46262593B26500458E77 /* AppDelegate.swift */; }; 12 | 45EB46292593B26500458E77 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EB46282593B26500458E77 /* SceneDelegate.swift */; }; 13 | 45EB462B2593B26500458E77 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EB462A2593B26500458E77 /* ViewController.swift */; }; 14 | 45EB462E2593B26500458E77 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45EB462C2593B26500458E77 /* Main.storyboard */; }; 15 | 45EB46302593B26600458E77 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 45EB462F2593B26600458E77 /* Assets.xcassets */; }; 16 | 45EB46332593B26600458E77 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45EB46312593B26600458E77 /* LaunchScreen.storyboard */; }; 17 | 45EB463C2593B3F900458E77 /* LocalPush.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45EB463B2593B3F900458E77 /* LocalPush.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 450F09262596478D005ADCFF /* UIApplication+CurrentScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+CurrentScreen.swift"; sourceTree = ""; }; 22 | 45EB46232593B26500458E77 /* LocPushSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LocPushSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 45EB46262593B26500458E77 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | 45EB46282593B26500458E77 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 25 | 45EB462A2593B26500458E77 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 26 | 45EB462D2593B26500458E77 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | 45EB462F2593B26600458E77 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 45EB46322593B26600458E77 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | 45EB46342593B26600458E77 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 45EB463B2593B3F900458E77 /* LocalPush.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalPush.swift; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 45EB46202593B26500458E77 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 45D14F392594420700B1298C /* LocalPush */ = { 45 | isa = PBXGroup; 46 | children = ( 47 | 45EB463B2593B3F900458E77 /* LocalPush.swift */, 48 | 450F09262596478D005ADCFF /* UIApplication+CurrentScreen.swift */, 49 | ); 50 | path = LocalPush; 51 | sourceTree = ""; 52 | }; 53 | 45EB461A2593B26500458E77 = { 54 | isa = PBXGroup; 55 | children = ( 56 | 45EB46252593B26500458E77 /* LocPushSample */, 57 | 45EB46242593B26500458E77 /* Products */, 58 | ); 59 | sourceTree = ""; 60 | }; 61 | 45EB46242593B26500458E77 /* Products */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 45EB46232593B26500458E77 /* LocPushSample.app */, 65 | ); 66 | name = Products; 67 | sourceTree = ""; 68 | }; 69 | 45EB46252593B26500458E77 /* LocPushSample */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 45D14F392594420700B1298C /* LocalPush */, 73 | 45EB46262593B26500458E77 /* AppDelegate.swift */, 74 | 45EB46282593B26500458E77 /* SceneDelegate.swift */, 75 | 45EB462A2593B26500458E77 /* ViewController.swift */, 76 | 45EB462C2593B26500458E77 /* Main.storyboard */, 77 | 45EB462F2593B26600458E77 /* Assets.xcassets */, 78 | 45EB46312593B26600458E77 /* LaunchScreen.storyboard */, 79 | 45EB46342593B26600458E77 /* Info.plist */, 80 | ); 81 | path = LocPushSample; 82 | sourceTree = ""; 83 | }; 84 | /* End PBXGroup section */ 85 | 86 | /* Begin PBXNativeTarget section */ 87 | 45EB46222593B26500458E77 /* LocPushSample */ = { 88 | isa = PBXNativeTarget; 89 | buildConfigurationList = 45EB46372593B26600458E77 /* Build configuration list for PBXNativeTarget "LocPushSample" */; 90 | buildPhases = ( 91 | 45EB461F2593B26500458E77 /* Sources */, 92 | 45EB46202593B26500458E77 /* Frameworks */, 93 | 45EB46212593B26500458E77 /* Resources */, 94 | ); 95 | buildRules = ( 96 | ); 97 | dependencies = ( 98 | ); 99 | name = LocPushSample; 100 | productName = LocPushSample; 101 | productReference = 45EB46232593B26500458E77 /* LocPushSample.app */; 102 | productType = "com.apple.product-type.application"; 103 | }; 104 | /* End PBXNativeTarget section */ 105 | 106 | /* Begin PBXProject section */ 107 | 45EB461B2593B26500458E77 /* Project object */ = { 108 | isa = PBXProject; 109 | attributes = { 110 | LastSwiftUpdateCheck = 1220; 111 | LastUpgradeCheck = 1220; 112 | TargetAttributes = { 113 | 45EB46222593B26500458E77 = { 114 | CreatedOnToolsVersion = 12.2; 115 | }; 116 | }; 117 | }; 118 | buildConfigurationList = 45EB461E2593B26500458E77 /* Build configuration list for PBXProject "LocPushSample" */; 119 | compatibilityVersion = "Xcode 9.3"; 120 | developmentRegion = en; 121 | hasScannedForEncodings = 0; 122 | knownRegions = ( 123 | en, 124 | Base, 125 | ); 126 | mainGroup = 45EB461A2593B26500458E77; 127 | productRefGroup = 45EB46242593B26500458E77 /* Products */; 128 | projectDirPath = ""; 129 | projectRoot = ""; 130 | targets = ( 131 | 45EB46222593B26500458E77 /* LocPushSample */, 132 | ); 133 | }; 134 | /* End PBXProject section */ 135 | 136 | /* Begin PBXResourcesBuildPhase section */ 137 | 45EB46212593B26500458E77 /* Resources */ = { 138 | isa = PBXResourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | 45EB46332593B26600458E77 /* LaunchScreen.storyboard in Resources */, 142 | 45EB46302593B26600458E77 /* Assets.xcassets in Resources */, 143 | 45EB462E2593B26500458E77 /* Main.storyboard in Resources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXResourcesBuildPhase section */ 148 | 149 | /* Begin PBXSourcesBuildPhase section */ 150 | 45EB461F2593B26500458E77 /* Sources */ = { 151 | isa = PBXSourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 45EB462B2593B26500458E77 /* ViewController.swift in Sources */, 155 | 450F09272596478D005ADCFF /* UIApplication+CurrentScreen.swift in Sources */, 156 | 45EB463C2593B3F900458E77 /* LocalPush.swift in Sources */, 157 | 45EB46272593B26500458E77 /* AppDelegate.swift in Sources */, 158 | 45EB46292593B26500458E77 /* SceneDelegate.swift in Sources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXSourcesBuildPhase section */ 163 | 164 | /* Begin PBXVariantGroup section */ 165 | 45EB462C2593B26500458E77 /* Main.storyboard */ = { 166 | isa = PBXVariantGroup; 167 | children = ( 168 | 45EB462D2593B26500458E77 /* Base */, 169 | ); 170 | name = Main.storyboard; 171 | sourceTree = ""; 172 | }; 173 | 45EB46312593B26600458E77 /* LaunchScreen.storyboard */ = { 174 | isa = PBXVariantGroup; 175 | children = ( 176 | 45EB46322593B26600458E77 /* Base */, 177 | ); 178 | name = LaunchScreen.storyboard; 179 | sourceTree = ""; 180 | }; 181 | /* End PBXVariantGroup section */ 182 | 183 | /* Begin XCBuildConfiguration section */ 184 | 45EB46352593B26600458E77 /* Debug */ = { 185 | isa = XCBuildConfiguration; 186 | buildSettings = { 187 | ALWAYS_SEARCH_USER_PATHS = NO; 188 | CLANG_ANALYZER_NONNULL = YES; 189 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 190 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 191 | CLANG_CXX_LIBRARY = "libc++"; 192 | CLANG_ENABLE_MODULES = YES; 193 | CLANG_ENABLE_OBJC_ARC = YES; 194 | CLANG_ENABLE_OBJC_WEAK = YES; 195 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_COMMA = YES; 198 | CLANG_WARN_CONSTANT_CONVERSION = YES; 199 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 200 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 201 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 202 | CLANG_WARN_EMPTY_BODY = YES; 203 | CLANG_WARN_ENUM_CONVERSION = YES; 204 | CLANG_WARN_INFINITE_RECURSION = YES; 205 | CLANG_WARN_INT_CONVERSION = YES; 206 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 207 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 208 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 209 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 210 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 211 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 212 | CLANG_WARN_STRICT_PROTOTYPES = YES; 213 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 214 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 215 | CLANG_WARN_UNREACHABLE_CODE = YES; 216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 217 | COPY_PHASE_STRIP = NO; 218 | DEBUG_INFORMATION_FORMAT = dwarf; 219 | ENABLE_STRICT_OBJC_MSGSEND = YES; 220 | ENABLE_TESTABILITY = YES; 221 | GCC_C_LANGUAGE_STANDARD = gnu11; 222 | GCC_DYNAMIC_NO_PIC = NO; 223 | GCC_NO_COMMON_BLOCKS = YES; 224 | GCC_OPTIMIZATION_LEVEL = 0; 225 | GCC_PREPROCESSOR_DEFINITIONS = ( 226 | "DEBUG=1", 227 | "$(inherited)", 228 | ); 229 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 230 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 231 | GCC_WARN_UNDECLARED_SELECTOR = YES; 232 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 233 | GCC_WARN_UNUSED_FUNCTION = YES; 234 | GCC_WARN_UNUSED_VARIABLE = YES; 235 | IPHONEOS_DEPLOYMENT_TARGET = 14.2; 236 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 237 | MTL_FAST_MATH = YES; 238 | ONLY_ACTIVE_ARCH = YES; 239 | SDKROOT = iphoneos; 240 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 241 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 242 | }; 243 | name = Debug; 244 | }; 245 | 45EB46362593B26600458E77 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_ANALYZER_NONNULL = YES; 250 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_ENABLE_OBJC_WEAK = YES; 256 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_COMMA = YES; 259 | CLANG_WARN_CONSTANT_CONVERSION = YES; 260 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 272 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 273 | CLANG_WARN_STRICT_PROTOTYPES = YES; 274 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 275 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 276 | CLANG_WARN_UNREACHABLE_CODE = YES; 277 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 278 | COPY_PHASE_STRIP = NO; 279 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 280 | ENABLE_NS_ASSERTIONS = NO; 281 | ENABLE_STRICT_OBJC_MSGSEND = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu11; 283 | GCC_NO_COMMON_BLOCKS = YES; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | IPHONEOS_DEPLOYMENT_TARGET = 14.2; 291 | MTL_ENABLE_DEBUG_INFO = NO; 292 | MTL_FAST_MATH = YES; 293 | SDKROOT = iphoneos; 294 | SWIFT_COMPILATION_MODE = wholemodule; 295 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 296 | VALIDATE_PRODUCT = YES; 297 | }; 298 | name = Release; 299 | }; 300 | 45EB46382593B26600458E77 /* Debug */ = { 301 | isa = XCBuildConfiguration; 302 | buildSettings = { 303 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 304 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 305 | CODE_SIGN_STYLE = Automatic; 306 | DEVELOPMENT_TEAM = RE4YFXSB23; 307 | INFOPLIST_FILE = LocPushSample/Info.plist; 308 | LD_RUNPATH_SEARCH_PATHS = ( 309 | "$(inherited)", 310 | "@executable_path/Frameworks", 311 | ); 312 | PRODUCT_BUNDLE_IDENTIFIER = com.glennposadas.sampleapps.LocPushSample23; 313 | PRODUCT_NAME = "$(TARGET_NAME)"; 314 | SWIFT_VERSION = 5.0; 315 | TARGETED_DEVICE_FAMILY = "1,2"; 316 | }; 317 | name = Debug; 318 | }; 319 | 45EB46392593B26600458E77 /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 323 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 324 | CODE_SIGN_STYLE = Automatic; 325 | DEVELOPMENT_TEAM = RE4YFXSB23; 326 | INFOPLIST_FILE = LocPushSample/Info.plist; 327 | LD_RUNPATH_SEARCH_PATHS = ( 328 | "$(inherited)", 329 | "@executable_path/Frameworks", 330 | ); 331 | PRODUCT_BUNDLE_IDENTIFIER = com.glennposadas.sampleapps.LocPushSample23; 332 | PRODUCT_NAME = "$(TARGET_NAME)"; 333 | SWIFT_VERSION = 5.0; 334 | TARGETED_DEVICE_FAMILY = "1,2"; 335 | }; 336 | name = Release; 337 | }; 338 | /* End XCBuildConfiguration section */ 339 | 340 | /* Begin XCConfigurationList section */ 341 | 45EB461E2593B26500458E77 /* Build configuration list for PBXProject "LocPushSample" */ = { 342 | isa = XCConfigurationList; 343 | buildConfigurations = ( 344 | 45EB46352593B26600458E77 /* Debug */, 345 | 45EB46362593B26600458E77 /* Release */, 346 | ); 347 | defaultConfigurationIsVisible = 0; 348 | defaultConfigurationName = Release; 349 | }; 350 | 45EB46372593B26600458E77 /* Build configuration list for PBXNativeTarget "LocPushSample" */ = { 351 | isa = XCConfigurationList; 352 | buildConfigurations = ( 353 | 45EB46382593B26600458E77 /* Debug */, 354 | 45EB46392593B26600458E77 /* Release */, 355 | ); 356 | defaultConfigurationIsVisible = 0; 357 | defaultConfigurationName = Release; 358 | }; 359 | /* End XCConfigurationList section */ 360 | }; 361 | rootObject = 45EB461B2593B26500458E77 /* Project object */; 362 | } 363 | -------------------------------------------------------------------------------- /LocPushSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LocPushSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LocPushSample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LocPushSample 4 | // 5 | // Created by Glenn Posadas on 12/24/20. 6 | // 7 | 8 | import UIKit 9 | import UserNotifications 10 | 11 | @main 12 | class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate { 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 15 | // Override point for customization after application launch. 16 | return true 17 | } 18 | 19 | // MARK: UISceneSession Lifecycle 20 | 21 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 22 | // Called when a new scene session is being created. 23 | // Use this method to select a configuration to create the new scene with. 24 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 25 | } 26 | 27 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 28 | // Called when the user discards a scene session. 29 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 30 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 31 | } 32 | 33 | 34 | func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { 35 | 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /LocPushSample/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /LocPushSample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /LocPushSample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LocPushSample/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 | -------------------------------------------------------------------------------- /LocPushSample/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 | -------------------------------------------------------------------------------- /LocPushSample/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 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UIApplicationSupportsIndirectInputEvents 43 | 44 | UILaunchStoryboardName 45 | LaunchScreen 46 | UIMainStoryboardFile 47 | Main 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UISupportedInterfaceOrientations~ipad 59 | 60 | UIInterfaceOrientationPortrait 61 | UIInterfaceOrientationPortraitUpsideDown 62 | UIInterfaceOrientationLandscapeLeft 63 | UIInterfaceOrientationLandscapeRight 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /LocPushSample/LocalPush/LocalPush.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LocalPush.swift 3 | // LocPushSample 4 | // 5 | // Created by Glenn Posadas on 12/24/20. 6 | // 7 | 8 | import UIKit 9 | import UserNotifications 10 | 11 | /** 12 | A simple wrapper for scheduling local push notification. 13 | 14 | #IMPORTANT!: 15 | - Conform your `AppDelegate` to `UNUserNotificationCenterDelegate`. 16 | - Implement `optional func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)` 17 | */ 18 | class LocalPush { 19 | 20 | // MARK: - Properties 21 | 22 | static let shared = LocalPush() 23 | 24 | // MARK: Functions 25 | 26 | private init () { } 27 | 28 | // MARK: Start 29 | 30 | /// The block called by `requestPush`. 31 | typealias RequestAuthorizationCompletionBlock = ((_ success: Bool, _ error: Error?) -> Void) 32 | ///Start by requesting authorization for push notification. 33 | func requestPush(block: @escaping RequestAuthorizationCompletionBlock) { 34 | let options: UNAuthorizationOptions = [.alert, .badge, .sound] 35 | UNUserNotificationCenter.current().requestAuthorization(options: options, completionHandler: block) 36 | } 37 | 38 | /// Start scheduling local push notification. This calls the `requestPush`. 39 | /// Only present an alert when there's an error. User may decline the permission request but there'd be no use for an alert. 40 | func start() { 41 | requestPush { (success, error) in 42 | if let error = error { 43 | self.alert("An error has occured: \(error.localizedDescription)") 44 | } 45 | } 46 | } 47 | 48 | // MARK: - Canceling 49 | 50 | /// Remove a scheduled local push by id. 51 | func removePush(_ id: String) { 52 | UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [id]) 53 | } 54 | 55 | /// Remove all scheduled local push 56 | func removeAllScheduled() { 57 | UNUserNotificationCenter.current().removeAllPendingNotificationRequests() 58 | } 59 | 60 | /// Remove all delivered push. 61 | func removeAllDelivered() { 62 | UNUserNotificationCenter.current().removeAllDeliveredNotifications() 63 | } 64 | 65 | /// Remove all delivered and scheduled push. 66 | func removeAllDeliveredAndScheduled() { 67 | removeAllDelivered() 68 | removeAllScheduled() 69 | } 70 | 71 | // MARK: - Scheduling 72 | 73 | /// Schedule a default push, using trigger. 74 | func schedulePush( 75 | id: String = UUID().uuidString, 76 | title: String, 77 | subtitle: String?, 78 | sound: UNNotificationSound = .default, 79 | trigger: UNNotificationTrigger?) { 80 | 81 | let content = UNMutableNotificationContent() 82 | content.title = title 83 | 84 | if let subtitle = subtitle { 85 | content.subtitle = subtitle 86 | } 87 | 88 | content.sound = UNNotificationSound.default 89 | 90 | // choose a random identifier 91 | let request = UNNotificationRequest( 92 | identifier: id, 93 | content: content, 94 | trigger: trigger 95 | ) 96 | 97 | // add our notification request 98 | UNUserNotificationCenter.current().add(request) 99 | } 100 | 101 | /// Schedule a default push, with all the parameters involved. 102 | func schedulePush( 103 | id: String, 104 | title: String, 105 | subtitle: String?, 106 | sound: UNNotificationSound = .default, 107 | interval: TimeInterval, 108 | repeats: Bool) { 109 | 110 | let trigger = getTrigger(timeInterval: interval, repeats: repeats) 111 | 112 | schedulePush(id: id, title: title, subtitle: subtitle, trigger: trigger) 113 | } 114 | 115 | /// Schedule a push using hour and minute. 116 | func schedulePush( 117 | id: String = UUID().uuidString, 118 | title: String, 119 | subtitle: String?, 120 | hour: Int, 121 | minute: Int, 122 | repeats: Bool) { 123 | 124 | var dateComponents = DateComponents() 125 | dateComponents.calendar = Calendar.current 126 | 127 | dateComponents.hour = hour 128 | dateComponents.minute = minute 129 | 130 | // Create the trigger as a repeating event. 131 | let trigger = UNCalendarNotificationTrigger( 132 | dateMatching: dateComponents, 133 | repeats: repeats 134 | ) 135 | 136 | schedulePush(id: id, title: title, subtitle: subtitle, trigger: trigger) 137 | } 138 | 139 | // MARK: - Private 140 | 141 | /// Get a trigger using `TimeInterval`. 142 | private func getTrigger(timeInterval: TimeInterval, repeats: Bool) -> UNTimeIntervalNotificationTrigger { 143 | let trigger = UNTimeIntervalNotificationTrigger( 144 | timeInterval: timeInterval, 145 | repeats: repeats 146 | ) 147 | 148 | return trigger 149 | } 150 | 151 | /// Present an alert from the `UIApplication.shared.currentScreen()`. 152 | private func alert(_ message: String) { 153 | let alert = UIAlertController( 154 | title: nil, 155 | message: message, 156 | preferredStyle: .alert 157 | ) 158 | 159 | let ok = UIAlertAction(title: "OK", style: .default, handler: nil) 160 | 161 | alert.addAction(ok) 162 | 163 | UIApplication.shared.currentScreen()? 164 | .present(alert, animated: true, completion: nil) 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /LocPushSample/LocalPush/UIApplication+CurrentScreen.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+CurrentScreen.swift 3 | // LocPushSample 4 | // 5 | // Created by Glenn Posadas on 12/24/20. 6 | // 7 | 8 | import UIKit 9 | 10 | extension UIApplication { 11 | static var windowRootController: UIViewController? { 12 | if #available(iOS 13.0, *) { 13 | let windowScene = UIApplication.shared 14 | .connectedScenes 15 | .filter { $0.activationState == .foregroundActive } 16 | .first 17 | 18 | if let window = windowScene as? UIWindowScene { 19 | return window.windows.last?.rootViewController 20 | } 21 | 22 | return UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController 23 | } else { 24 | return UIApplication.shared.keyWindow?.rootViewController 25 | } 26 | } 27 | 28 | func currentScreen(controller: UIViewController? = windowRootController) -> UIViewController? { 29 | if let navigationController = controller as? UINavigationController { 30 | return currentScreen(controller: navigationController.visibleViewController) 31 | } 32 | if let tabController = controller as? UITabBarController { 33 | if let selected = tabController.selectedViewController { 34 | return currentScreen(controller: selected) 35 | } 36 | } 37 | if let presented = controller?.presentedViewController { 38 | return currentScreen(controller: presented) 39 | } 40 | return controller 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LocPushSample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // LocPushSample 4 | // 5 | // Created by Glenn Posadas on 12/24/20. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /LocPushSample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // LocPushSample 4 | // 5 | // Created by Glenn Posadas on 12/24/20. 6 | // 7 | 8 | import UIKit 9 | import UserNotifications 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | LocalPush.shared.start() 17 | 18 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) { 19 | 20 | let content = UNMutableNotificationContent() 21 | content.title = "112221Without sub Feed the cat + \(Int.random(in: 0..<5))!" 22 | content.subtitle = "It looks hungry2" 23 | content.sound = UNNotificationSound.default 24 | 25 | // show this notification five seconds from now 26 | let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false) 27 | 28 | // choose a random identifier 29 | let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) 30 | 31 | // add our notification request 32 | UNUserNotificationCenter.current().add(request) 33 | 34 | 35 | } 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LocalPush 2 | 3 | A super simple local push notification helper. 4 | 5 | Sample usage: 6 | 7 | override func viewDidLoad() { 8 | super.viewDidLoad() 9 | 10 | LocalPush.shared.start() 11 | 12 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { 13 | LocalPush.shared.schedulePush( 14 | title: "Hello local push!🙇🏻‍♂️ ", 15 | subtitle: "This is a local push! Check out https://github.com/glennposadas/locpush-ios", 16 | hour: 23, 17 | minute: 19, 18 | repeats: true 19 | ) 20 | } 21 | } 22 | 23 | 24 | 25 | ![enter image description here](https://i.imgur.com/yvNntoW.png) 26 | 27 | --------------------------------------------------------------------------------