├── .gitignore ├── .gitmodules ├── .swift-version ├── APNS.podspec ├── Framework ├── APNS.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── APNS.xcscheme ├── APNS │ ├── APNS.h │ └── Info.plist └── UnitTest │ ├── Info.plist │ └── UnitTest.swift ├── LICENSE ├── Package.swift ├── README.md ├── Source ├── APNS-Protobuf.swift ├── APNSNetwork.swift └── Apple.Apns.PushService.proto.swift ├── logo.png └── protobuf └── PushService.proto /.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 | .DS_Store 9 | Carthage 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata 21 | 22 | ## Other 23 | *.xccheckout 24 | *.moved-aside 25 | *.xcuserstate 26 | *.xcscmblueprint 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | 32 | ## Playgrounds 33 | timeline.xctimeline 34 | playground.xcworkspace 35 | 36 | # Swift Package Manager 37 | # 38 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 39 | # Packages/ 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 63 | 64 | fastlane/report.xml 65 | fastlane/screenshots 66 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexeyxo/swift-apns/a6bb08dd07ef2d5b82c71cef354dd5bd2a5da108/.gitmodules -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /APNS.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "APNS" 3 | s.version = "1.2.2" 4 | s.summary = "Swift Framework for sending Apple Push Notification over HTTP/2 API" 5 | s.homepage = "https://github.com/alexeyxo/swift-apns" 6 | s.license = "Apache 2.0" 7 | s.documentation_url = "https://github.com/alexeyxo/swift-apns" 8 | s.license = { :type => 'Apache License, Version 2.0', :text => 9 | <<-LICENSE 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | http://www.apache.org/licenses/LICENSE-2.0 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | Copyright 2008 Google Inc. 20 | LICENSE 21 | } 22 | 23 | s.author = { "Alexey Khokhlov" => "alexeyxo@gmail.com" } 24 | s.authors = { "Alexey Khokhlov" => "alexeyxo@gmail.com" } 25 | 26 | s.ios.deployment_target = '8.0' 27 | s.osx.deployment_target = '10.10' 28 | 29 | s.module_name = "APNS" 30 | s.source = { :git => "https://github.com/alexeyxo/swift-apns.git", :tag => s.version } 31 | s.source_files = 'Source/*.{swift}' 32 | s.requires_arc = true 33 | s.frameworks = 'Foundation', 'Security' 34 | s.dependency 'ProtocolBuffers-Swift' 35 | end 36 | -------------------------------------------------------------------------------- /Framework/APNS.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3F1968811E2107D80005FEA8 /* cert.p12 in Resources */ = {isa = PBXBuildFile; fileRef = 3F1968801E2107D80005FEA8 /* cert.p12 */; }; 11 | 3F3823431D42292500646806 /* APNSNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FBBC7F31C5CC25100EF69CC /* APNSNetwork.swift */; }; 12 | 3F388E141C5E1DC20000EDCE /* APNS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3FBBC7E71C5CC20F00EF69CC /* APNS.framework */; }; 13 | 3F388E221C5E35F20000EDCE /* UnitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F388E111C5E1DC20000EDCE /* UnitTest.swift */; }; 14 | 3FBBC7EB1C5CC20F00EF69CC /* APNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBBC7EA1C5CC20F00EF69CC /* APNS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXContainerItemProxy section */ 18 | 3F388E151C5E1DC20000EDCE /* PBXContainerItemProxy */ = { 19 | isa = PBXContainerItemProxy; 20 | containerPortal = 3FBBC7DE1C5CC20F00EF69CC /* Project object */; 21 | proxyType = 1; 22 | remoteGlobalIDString = 3FBBC7E61C5CC20F00EF69CC; 23 | remoteInfo = APNS; 24 | }; 25 | /* End PBXContainerItemProxy section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 3F1823371D403C0300022759 /* APNS-Protobuf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "APNS-Protobuf.swift"; path = "../../Source/APNS-Protobuf.swift"; sourceTree = ""; }; 29 | 3F1823381D403C0300022759 /* Apple.Apns.PushService.proto.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Apple.Apns.PushService.proto.swift; path = ../../Source/Apple.Apns.PushService.proto.swift; sourceTree = ""; }; 30 | 3F1968801E2107D80005FEA8 /* cert.p12 */ = {isa = PBXFileReference; lastKnownFileType = file; path = cert.p12; sourceTree = SOURCE_ROOT; }; 31 | 3F388E0F1C5E1DC20000EDCE /* UnitTest.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTest.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 3F388E111C5E1DC20000EDCE /* UnitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnitTest.swift; sourceTree = ""; }; 33 | 3F388E131C5E1DC20000EDCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 3FBBC7E71C5CC20F00EF69CC /* APNS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = APNS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 3FBBC7EA1C5CC20F00EF69CC /* APNS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APNS.h; sourceTree = ""; }; 36 | 3FBBC7EC1C5CC20F00EF69CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | 3FBBC7F31C5CC25100EF69CC /* APNSNetwork.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = APNSNetwork.swift; path = ../../Source/APNSNetwork.swift; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 3F388E0C1C5E1DC20000EDCE /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | 3F388E141C5E1DC20000EDCE /* APNS.framework in Frameworks */, 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | 3FBBC7E31C5CC20F00EF69CC /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | 3F388E101C5E1DC20000EDCE /* UnitTest */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | 3F1968801E2107D80005FEA8 /* cert.p12 */, 63 | 3F388E111C5E1DC20000EDCE /* UnitTest.swift */, 64 | 3F388E131C5E1DC20000EDCE /* Info.plist */, 65 | ); 66 | path = UnitTest; 67 | sourceTree = ""; 68 | }; 69 | 3FBBC7DD1C5CC20F00EF69CC = { 70 | isa = PBXGroup; 71 | children = ( 72 | 3FBBC7E91C5CC20F00EF69CC /* APNS */, 73 | 3F388E101C5E1DC20000EDCE /* UnitTest */, 74 | 3FBBC7E81C5CC20F00EF69CC /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 3FBBC7E81C5CC20F00EF69CC /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 3FBBC7E71C5CC20F00EF69CC /* APNS.framework */, 82 | 3F388E0F1C5E1DC20000EDCE /* UnitTest.xctest */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | 3FBBC7E91C5CC20F00EF69CC /* APNS */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 3F1823371D403C0300022759 /* APNS-Protobuf.swift */, 91 | 3F1823381D403C0300022759 /* Apple.Apns.PushService.proto.swift */, 92 | 3FBBC7F31C5CC25100EF69CC /* APNSNetwork.swift */, 93 | 3FBBC7EA1C5CC20F00EF69CC /* APNS.h */, 94 | 3FBBC7EC1C5CC20F00EF69CC /* Info.plist */, 95 | ); 96 | path = APNS; 97 | sourceTree = ""; 98 | }; 99 | /* End PBXGroup section */ 100 | 101 | /* Begin PBXHeadersBuildPhase section */ 102 | 3FBBC7E41C5CC20F00EF69CC /* Headers */ = { 103 | isa = PBXHeadersBuildPhase; 104 | buildActionMask = 2147483647; 105 | files = ( 106 | 3FBBC7EB1C5CC20F00EF69CC /* APNS.h in Headers */, 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | /* End PBXHeadersBuildPhase section */ 111 | 112 | /* Begin PBXNativeTarget section */ 113 | 3F388E0E1C5E1DC20000EDCE /* UnitTest */ = { 114 | isa = PBXNativeTarget; 115 | buildConfigurationList = 3F388E171C5E1DC20000EDCE /* Build configuration list for PBXNativeTarget "UnitTest" */; 116 | buildPhases = ( 117 | 3F388E0B1C5E1DC20000EDCE /* Sources */, 118 | 3F388E0C1C5E1DC20000EDCE /* Frameworks */, 119 | 3F388E0D1C5E1DC20000EDCE /* Resources */, 120 | ); 121 | buildRules = ( 122 | ); 123 | dependencies = ( 124 | 3F388E161C5E1DC20000EDCE /* PBXTargetDependency */, 125 | ); 126 | name = UnitTest; 127 | productName = UnitTest; 128 | productReference = 3F388E0F1C5E1DC20000EDCE /* UnitTest.xctest */; 129 | productType = "com.apple.product-type.bundle.unit-test"; 130 | }; 131 | 3FBBC7E61C5CC20F00EF69CC /* APNS */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = 3FBBC7EF1C5CC20F00EF69CC /* Build configuration list for PBXNativeTarget "APNS" */; 134 | buildPhases = ( 135 | 3FBBC7E21C5CC20F00EF69CC /* Sources */, 136 | 3FBBC7E31C5CC20F00EF69CC /* Frameworks */, 137 | 3FBBC7E41C5CC20F00EF69CC /* Headers */, 138 | 3FBBC7E51C5CC20F00EF69CC /* Resources */, 139 | ); 140 | buildRules = ( 141 | ); 142 | dependencies = ( 143 | ); 144 | name = APNS; 145 | productName = APNS; 146 | productReference = 3FBBC7E71C5CC20F00EF69CC /* APNS.framework */; 147 | productType = "com.apple.product-type.framework"; 148 | }; 149 | /* End PBXNativeTarget section */ 150 | 151 | /* Begin PBXProject section */ 152 | 3FBBC7DE1C5CC20F00EF69CC /* Project object */ = { 153 | isa = PBXProject; 154 | attributes = { 155 | LastSwiftUpdateCheck = 0720; 156 | LastUpgradeCheck = 0820; 157 | ORGANIZATIONNAME = "Alexey Khokhlov"; 158 | TargetAttributes = { 159 | 3F388E0E1C5E1DC20000EDCE = { 160 | CreatedOnToolsVersion = 7.2; 161 | LastSwiftMigration = 0800; 162 | }; 163 | 3FBBC7E61C5CC20F00EF69CC = { 164 | CreatedOnToolsVersion = 7.2; 165 | LastSwiftMigration = 0800; 166 | }; 167 | }; 168 | }; 169 | buildConfigurationList = 3FBBC7E11C5CC20F00EF69CC /* Build configuration list for PBXProject "APNS" */; 170 | compatibilityVersion = "Xcode 3.2"; 171 | developmentRegion = English; 172 | hasScannedForEncodings = 0; 173 | knownRegions = ( 174 | en, 175 | ); 176 | mainGroup = 3FBBC7DD1C5CC20F00EF69CC; 177 | productRefGroup = 3FBBC7E81C5CC20F00EF69CC /* Products */; 178 | projectDirPath = ""; 179 | projectRoot = ""; 180 | targets = ( 181 | 3FBBC7E61C5CC20F00EF69CC /* APNS */, 182 | 3F388E0E1C5E1DC20000EDCE /* UnitTest */, 183 | ); 184 | }; 185 | /* End PBXProject section */ 186 | 187 | /* Begin PBXResourcesBuildPhase section */ 188 | 3F388E0D1C5E1DC20000EDCE /* Resources */ = { 189 | isa = PBXResourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | 3F1968811E2107D80005FEA8 /* cert.p12 in Resources */, 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | }; 196 | 3FBBC7E51C5CC20F00EF69CC /* Resources */ = { 197 | isa = PBXResourcesBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | /* End PBXResourcesBuildPhase section */ 204 | 205 | /* Begin PBXSourcesBuildPhase section */ 206 | 3F388E0B1C5E1DC20000EDCE /* Sources */ = { 207 | isa = PBXSourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | 3F388E221C5E35F20000EDCE /* UnitTest.swift in Sources */, 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | 3FBBC7E21C5CC20F00EF69CC /* Sources */ = { 215 | isa = PBXSourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | 3F3823431D42292500646806 /* APNSNetwork.swift in Sources */, 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | }; 222 | /* End PBXSourcesBuildPhase section */ 223 | 224 | /* Begin PBXTargetDependency section */ 225 | 3F388E161C5E1DC20000EDCE /* PBXTargetDependency */ = { 226 | isa = PBXTargetDependency; 227 | target = 3FBBC7E61C5CC20F00EF69CC /* APNS */; 228 | targetProxy = 3F388E151C5E1DC20000EDCE /* PBXContainerItemProxy */; 229 | }; 230 | /* End PBXTargetDependency section */ 231 | 232 | /* Begin XCBuildConfiguration section */ 233 | 3F388E181C5E1DC20000EDCE /* Debug */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | COMBINE_HIDPI_IMAGES = YES; 237 | INFOPLIST_FILE = UnitTest/Info.plist; 238 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 239 | PRODUCT_BUNDLE_IDENTIFIER = com.alexeyxo.UnitTest; 240 | PRODUCT_NAME = "$(TARGET_NAME)"; 241 | SWIFT_VERSION = 3.0; 242 | }; 243 | name = Debug; 244 | }; 245 | 3F388E191C5E1DC20000EDCE /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | COMBINE_HIDPI_IMAGES = YES; 249 | INFOPLIST_FILE = UnitTest/Info.plist; 250 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 251 | PRODUCT_BUNDLE_IDENTIFIER = com.alexeyxo.UnitTest; 252 | PRODUCT_NAME = "$(TARGET_NAME)"; 253 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 254 | SWIFT_VERSION = 3.0; 255 | }; 256 | name = Release; 257 | }; 258 | 3FBBC7ED1C5CC20F00EF69CC /* Debug */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ALWAYS_SEARCH_USER_PATHS = NO; 262 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 263 | CLANG_CXX_LIBRARY = "libc++"; 264 | CLANG_ENABLE_MODULES = YES; 265 | CLANG_ENABLE_OBJC_ARC = YES; 266 | CLANG_WARN_BOOL_CONVERSION = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 269 | CLANG_WARN_EMPTY_BODY = YES; 270 | CLANG_WARN_ENUM_CONVERSION = YES; 271 | CLANG_WARN_INFINITE_RECURSION = YES; 272 | CLANG_WARN_INT_CONVERSION = YES; 273 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 274 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | CODE_SIGN_IDENTITY = "-"; 278 | COPY_PHASE_STRIP = NO; 279 | CURRENT_PROJECT_VERSION = 1; 280 | DEBUG_INFORMATION_FORMAT = dwarf; 281 | ENABLE_STRICT_OBJC_MSGSEND = YES; 282 | ENABLE_TESTABILITY = YES; 283 | GCC_C_LANGUAGE_STANDARD = gnu99; 284 | GCC_DYNAMIC_NO_PIC = NO; 285 | GCC_NO_COMMON_BLOCKS = YES; 286 | GCC_OPTIMIZATION_LEVEL = 0; 287 | GCC_PREPROCESSOR_DEFINITIONS = ( 288 | "DEBUG=1", 289 | "$(inherited)", 290 | ); 291 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 292 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 293 | GCC_WARN_UNDECLARED_SELECTOR = YES; 294 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 295 | GCC_WARN_UNUSED_FUNCTION = YES; 296 | GCC_WARN_UNUSED_VARIABLE = YES; 297 | MACOSX_DEPLOYMENT_TARGET = 10.11; 298 | MTL_ENABLE_DEBUG_INFO = YES; 299 | ONLY_ACTIVE_ARCH = YES; 300 | SDKROOT = macosx; 301 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 302 | VERSIONING_SYSTEM = "apple-generic"; 303 | VERSION_INFO_PREFIX = ""; 304 | }; 305 | name = Debug; 306 | }; 307 | 3FBBC7EE1C5CC20F00EF69CC /* Release */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ALWAYS_SEARCH_USER_PATHS = NO; 311 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 312 | CLANG_CXX_LIBRARY = "libc++"; 313 | CLANG_ENABLE_MODULES = YES; 314 | CLANG_ENABLE_OBJC_ARC = YES; 315 | CLANG_WARN_BOOL_CONVERSION = YES; 316 | CLANG_WARN_CONSTANT_CONVERSION = YES; 317 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 318 | CLANG_WARN_EMPTY_BODY = YES; 319 | CLANG_WARN_ENUM_CONVERSION = YES; 320 | CLANG_WARN_INFINITE_RECURSION = YES; 321 | CLANG_WARN_INT_CONVERSION = YES; 322 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 323 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 324 | CLANG_WARN_UNREACHABLE_CODE = YES; 325 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 326 | CODE_SIGN_IDENTITY = "-"; 327 | COPY_PHASE_STRIP = NO; 328 | CURRENT_PROJECT_VERSION = 1; 329 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 330 | ENABLE_NS_ASSERTIONS = NO; 331 | ENABLE_STRICT_OBJC_MSGSEND = YES; 332 | GCC_C_LANGUAGE_STANDARD = gnu99; 333 | GCC_NO_COMMON_BLOCKS = YES; 334 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 335 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 336 | GCC_WARN_UNDECLARED_SELECTOR = YES; 337 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 338 | GCC_WARN_UNUSED_FUNCTION = YES; 339 | GCC_WARN_UNUSED_VARIABLE = YES; 340 | MACOSX_DEPLOYMENT_TARGET = 10.11; 341 | MTL_ENABLE_DEBUG_INFO = NO; 342 | SDKROOT = macosx; 343 | VERSIONING_SYSTEM = "apple-generic"; 344 | VERSION_INFO_PREFIX = ""; 345 | }; 346 | name = Release; 347 | }; 348 | 3FBBC7F01C5CC20F00EF69CC /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | CLANG_ENABLE_MODULES = YES; 352 | COMBINE_HIDPI_IMAGES = YES; 353 | DEFINES_MODULE = YES; 354 | DYLIB_COMPATIBILITY_VERSION = 1; 355 | DYLIB_CURRENT_VERSION = 1; 356 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 357 | FRAMEWORK_SEARCH_PATHS = ( 358 | "$(SRCROOT)/Carthage/Build/Mac", 359 | "$(PROJECT_DIR)/Carthage/Build/Mac", 360 | ); 361 | FRAMEWORK_VERSION = A; 362 | INFOPLIST_FILE = APNS/Info.plist; 363 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 364 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 365 | PRODUCT_BUNDLE_IDENTIFIER = com.alexeyxo.APNS; 366 | PRODUCT_NAME = "$(TARGET_NAME)"; 367 | SKIP_INSTALL = YES; 368 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 369 | SWIFT_VERSION = 3.0; 370 | }; 371 | name = Debug; 372 | }; 373 | 3FBBC7F11C5CC20F00EF69CC /* Release */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | CLANG_ENABLE_MODULES = YES; 377 | COMBINE_HIDPI_IMAGES = YES; 378 | DEFINES_MODULE = YES; 379 | DYLIB_COMPATIBILITY_VERSION = 1; 380 | DYLIB_CURRENT_VERSION = 1; 381 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 382 | FRAMEWORK_SEARCH_PATHS = ( 383 | "$(SRCROOT)/Carthage/Build/Mac", 384 | "$(PROJECT_DIR)/Carthage/Build/Mac", 385 | ); 386 | FRAMEWORK_VERSION = A; 387 | INFOPLIST_FILE = APNS/Info.plist; 388 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = com.alexeyxo.APNS; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | SKIP_INSTALL = YES; 393 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 394 | SWIFT_VERSION = 3.0; 395 | }; 396 | name = Release; 397 | }; 398 | /* End XCBuildConfiguration section */ 399 | 400 | /* Begin XCConfigurationList section */ 401 | 3F388E171C5E1DC20000EDCE /* Build configuration list for PBXNativeTarget "UnitTest" */ = { 402 | isa = XCConfigurationList; 403 | buildConfigurations = ( 404 | 3F388E181C5E1DC20000EDCE /* Debug */, 405 | 3F388E191C5E1DC20000EDCE /* Release */, 406 | ); 407 | defaultConfigurationIsVisible = 0; 408 | defaultConfigurationName = Release; 409 | }; 410 | 3FBBC7E11C5CC20F00EF69CC /* Build configuration list for PBXProject "APNS" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | 3FBBC7ED1C5CC20F00EF69CC /* Debug */, 414 | 3FBBC7EE1C5CC20F00EF69CC /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | 3FBBC7EF1C5CC20F00EF69CC /* Build configuration list for PBXNativeTarget "APNS" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | 3FBBC7F01C5CC20F00EF69CC /* Debug */, 423 | 3FBBC7F11C5CC20F00EF69CC /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | /* End XCConfigurationList section */ 429 | }; 430 | rootObject = 3FBBC7DE1C5CC20F00EF69CC /* Project object */; 431 | } 432 | -------------------------------------------------------------------------------- /Framework/APNS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Framework/APNS.xcodeproj/xcshareddata/xcschemes/APNS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Framework/APNS/APNS.h: -------------------------------------------------------------------------------- 1 | // 2 | // APNS.h 3 | // APNS 4 | // 5 | // Created by Alexey Khokhlov on 30.01.16. 6 | // Copyright © 2016 Alexey Khokhlov. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for APNS. 12 | FOUNDATION_EXPORT double APNSVersionNumber; 13 | 14 | //! Project version string for APNS. 15 | FOUNDATION_EXPORT const unsigned char APNSVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Framework/APNS/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.2.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2016 Alexey Khokhlov. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Framework/UnitTest/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Framework/UnitTest/UnitTest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UnitTest.swift 3 | // UnitTest 4 | // 5 | // Created by Alexey Khokhlov on 31.01.16. 6 | // Copyright © 2016 Alexey Khokhlov. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import APNS 11 | class UnitTest: XCTestCase { 12 | var expectation:XCTestExpectation = XCTestExpectation() 13 | override func setUp() { 14 | super.setUp() 15 | self.expectation = self.expectation(description:"server response") 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | // func testSendProtobuf() { 24 | // let providerData = Apple.Apns.ProviderData.Builder() 25 | // providerData.bundle = "com.advisa.voipservice" 26 | // providerData.serviceIdentity = Apple.Apns.ProviderData.Identity.Development 27 | // providerData.priority = 10 28 | // providerData.certificatePath = NSBundle(forClass:UnitTest.self).pathForResource("push", ofType: "p12")! 29 | // providerData.certificatePassphrase = "123456" 30 | // providerData.token = "3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe" 31 | // 32 | // let aps = Apple.Apns.Push.Aps.Builder() 33 | // aps.badge = 1 34 | // aps.contentAvailable = 1 35 | // aps.sound = "default" 36 | // aps.alert = "testSendProtobuf()" 37 | // do { 38 | // let payload = try Apple.Apns.Push.Builder().setAps(aps.build()).build() 39 | // providerData.payload = payload 40 | // try APNSNetwork().sendPush(providerData.build(), responseBlock: { (response) -> () in 41 | // print(response) 42 | // XCTAssertTrue(response.statusCode == 200) 43 | // self.expectation.fulfill() 44 | // 45 | // }) 46 | // self.waitForExpectationsWithTimeout(5, handler: { (error) -> Void in 47 | // if (error != nil) { 48 | // XCTFail("Timeout error: \(error)") 49 | // } 50 | // }) 51 | // } catch { 52 | // 53 | // } 54 | // } 55 | 56 | 57 | func testPush() { 58 | 59 | let aps = ["sound":"default", "alert":"testPush()"] 60 | let payload = ["aps":aps] 61 | let str = Bundle(for:UnitTest.self).path(forResource: "cert", ofType: "p12")! 62 | var mess = ApplePushMessage(topic: "com.123.123", 63 | priority: 10, 64 | payload: payload, 65 | deviceToken: "e86ba7b98a8bbc2725481caed7c2b2d906dae1f11339bb11a6918095d6d14933", 66 | certificatePath:str, 67 | passphrase: "123456") 68 | 69 | mess.responseBlock = { response in 70 | XCTAssertTrue(response.serviceStatus.0 == 200) 71 | self.expectation.fulfill() 72 | } 73 | 74 | mess.networkError = { err in 75 | if (err != nil) { 76 | XCTFail("Timeout error: \(err)") 77 | } 78 | 79 | } 80 | _ = try! mess.send() 81 | 82 | self.waitForExpectations(timeout: 5, handler: { (error) -> Void in 83 | if (error != nil) { 84 | XCTFail("Timeout error: \(error)") 85 | } 86 | }) 87 | 88 | } 89 | 90 | func testPushFails() { 91 | 92 | let aps = ["sound":"default", "alert":"testPush()"] 93 | let payload = ["aps":aps] 94 | let str = Bundle(for:UnitTest.self).path(forResource: "cert", ofType: "p12")! 95 | var mess = ApplePushMessage(topic: "com.123.123", 96 | priority: 10, 97 | payload: payload, 98 | deviceToken: "e86ba7b98a8bbc27254ddd81caed7c2b2d906dae1f11339bb11a6918095d6d14933", 99 | certificatePath:str, 100 | passphrase: "123456") 101 | 102 | mess.responseBlock = { response in 103 | XCTAssertTrue(response.serviceStatus.1 == APNServiceStatus.badRequest) 104 | self.expectation.fulfill() 105 | } 106 | 107 | mess.networkError = { err in 108 | if (err != nil) { 109 | XCTFail("Timeout error: \(err)") 110 | } 111 | 112 | } 113 | _ = try! mess.send() 114 | 115 | self.waitForExpectations(timeout: 5, handler: { (error) -> Void in 116 | if (error != nil) { 117 | XCTFail("Timeout error: \(error)") 118 | } 119 | }) 120 | 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // APNS 2 | // 3 | // Copyright 2016 Alexey Khohklov(AlexeyXo). 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License") 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | import PackageDescription 18 | 19 | let package = Package( 20 | name: "APNS", 21 | targets: [], 22 | dependencies: [ 23 | .Package(url: "https://github.com/alexeyxo/protobuf-swift.git", 24 | majorVersion: 3), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Logo 4 | 5 |

6 | 7 |

8 | Simple framework for sending Apple Push Notifications. 9 |

10 | 11 |

12 | 13 | Carthage compatible 14 | 15 | Version 16 | 17 | Platform 18 | 19 |

20 | 21 | ## Table of Contents 22 | 23 | - [Installation](#installation) 24 | - [CocoaPods](#-cocoapods) 25 | - [Carthage](#-carthage) 26 | - [Usage](#usage) 27 | - [Simple Example](#simple-example) 28 | - [Using with "Protocol Buffers"](#using-with-protocol-buffers) 29 | - [Simple Example](#simple-example-1) 30 | - [Sending Custom Objects](#sending-custom-objects) 31 | - [Credits](#credits) 32 | 33 | ## Installation 34 | 35 | ### CocoaPods 36 | 37 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 38 | 39 | ```bash 40 | $ gem install cocoapods 41 | ``` 42 | 43 | To integrate *swift-apns* into your Xcode project using CocoaPods, specify it in your `Podfile`: 44 | 45 | ```ruby 46 | source 'https://github.com/CocoaPods/Specs.git' 47 | platform :ios, '9.0' 48 | use_frameworks! 49 | 50 | target '' do 51 | pod 'APNS', '~> 1.0' 52 | end 53 | ``` 54 | 55 | Then, run the following command: 56 | 57 | ```bash 58 | $ pod install 59 | ``` 60 | 61 | ### Carthage 62 | 63 | [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. 64 | 65 | You can install Carthage with [Homebrew](http://brew.sh/) using the following command: 66 | 67 | ```bash 68 | $ brew install carthage 69 | ``` 70 | 71 | To integrate *swift-apns* into your Xcode project using Carthage, specify it in your `Cartfile`: 72 | 73 | ```ogdl 74 | github "alexeyxo/swift-apns" 75 | ``` 76 | 77 | Run `carthage update` to build the framework and drag the built `.framework` file into your Xcode project. 78 | 79 | 80 | ## Usage 81 | 82 | ### Simple Example 83 | 84 | ```swift 85 | let aps = ["sound":"default", "alert":"testPush()"] 86 | let payload = ["aps":aps] 87 | _ = try! APNSNetwork().sendPush(topic: "com.asdasd.asdasdas", priority: 10, payload: payload, deviceToken: "3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe", certificatePath: Bundle(for:UnitTest.self).pathForResource("push", ofType: "p12")!, passphrase: "123456", sandbox: true, responseBlock: { (response) in 88 | XCTAssertTrue(response.serviceStatus.0 == 200) 89 | self.expectation.fulfill() 90 | }, networkError: { (error) in 91 | 92 | }) 93 | ``` 94 | 95 | ```swift 96 | 97 | let aps = ["sound":"default", "alert":"testPush()"] 98 | let payload = ["aps":aps] 99 | let str = Bundle(for:UnitTest.self).pathForResource("cert", ofType: "p12")! 100 | var mess = ApplePushMessage(topic: "com.tests.asdasdasd", 101 | priority: 10, 102 | payload: payload, 103 | deviceToken: "3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe", 104 | certificatePath:str, 105 | passphrase: "123456", 106 | sandbox: true, 107 | responseBlock:nil, 108 | networkError:nil, session: nil) 109 | 110 | mess.responseBlock = { response in 111 | } 112 | 113 | mess.networkError = { err in 114 | if (err != nil) { 115 | 116 | } 117 | } 118 | _ = try! mess.send() // OR try! mess.send(session:) 119 | 120 | 121 | ``` 122 | 123 | ### Using with "Protocol Buffers" 124 | 125 | > Required Protocol Buffers 3.0 and [protobuf-swift](https://github.com/alexeyxo/protobuf-swift). 126 | 127 | #### Simple Example 128 | ```swift 129 | let providerData = Apple.Apns.ProviderData.Builder() 130 | providerData.bundle = "com.aasdad.asdasdsdfa" 131 | providerData.serviceIdentity = Apple.Apns.ProviderData.Identity.Development 132 | providerData.priority = 10 133 | providerData.certificatePath = NSBundle(forClass:UnitTest.self).pathForResource("push", ofType: "p12")! 134 | providerData.certificatePassphrase = "123456" 135 | providerData.token = "3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe" 136 | 137 | let aps = Apple.Apns.Push.Aps.Builder() 138 | aps.badge = 1 139 | aps.contentAvailable = 1 140 | aps.sound = "default" 141 | aps.alert = "testSendProtobuf()" 142 | do { 143 | let payload = try Apple.Apns.Push.Builder().setAps(aps.build()).build() 144 | providerData.payload = payload 145 | try APNSNetwork().sendPush(providerData.build(), responseBlock: { (response) -> () in 146 | print(response) 147 | }) 148 | } catch { 149 | 150 | } 151 | ``` 152 | 153 | #### Sending Custom Objects 154 | 155 | 1. Edit ./Source/ProtoSource/PushService.proto: 156 | ```protobuf 157 | ... 158 | message Push { 159 | message Aps { 160 | string alert = 1; 161 | string sound = 2; 162 | int32 badge = 3; 163 | int32 content_available = 4; 164 | string category = 5; 165 | } 166 | 167 | message ExampleCustomObject { 168 | string objectId = 1; 169 | } 170 | 171 | Aps aps = 1; 172 | ExampleCustomObject customObject = 2; 173 | } 174 | ``` 175 | 176 | 2. Compile new object: 177 | ```bash 178 | protoc PushService.proto --swift_out="../" 179 | ``` 180 | 181 | ## Credits 182 | 183 | - The bird used in the logo - as well as the cloud - are borrowed respectively 184 | from the original *Swift* and *APNs* logos which have 185 | *All Rights Reserved to Apple Inc. 186 | 187 | - The font used in logo comes from the [San Francisco family](https://developer.apple.com/fonts/). 188 | -------------------------------------------------------------------------------- /Source/APNS-Protobuf.swift: -------------------------------------------------------------------------------- 1 | // 2 | // APNS-Protobuf.swift 3 | // APNS 4 | // 5 | // Created by Alexey Khokhlov on 30.01.16. 6 | // Copyright © 2016 Alexey Khokhlov. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | //extension 12 | 13 | extension APNSNetwork { 14 | 15 | public func sendPush(pushService:Apple.Apns.ProviderData, responseBlock:((_ response:Apple.Apns.Response) -> Void)?, networkError:((Error?) -> ())?) throws -> URLSessionDataTask? { 16 | 17 | let payload = try getPayload(push: pushService) 18 | var sandbox = true 19 | if pushService.serviceIdentity == .production { 20 | sandbox = false 21 | } 22 | let task = try sendPushWith(topic:pushService.bundle, 23 | priority: Int(pushService.priority), 24 | payload: payload, 25 | deviceToken: pushService.token, 26 | certificatePath: pushService.certificatePath, 27 | passphrase: pushService.certificatePassphrase, 28 | sandbox: sandbox, 29 | responseBlock: { (response) -> Void in 30 | let responseObject = APNServiceStatus.getResponseObject(response: response) 31 | responseBlock?(responseObject) 32 | }, networkError: networkError) 33 | return task 34 | } 35 | 36 | private func getIdentityWith(providerData:Apple.Apns.ProviderData) -> SecIdentity? { 37 | return getIdentityWith(certificatePath:providerData.certificatePath, passphrase: providerData.certificatePassphrase) 38 | } 39 | 40 | private func getPayload(push:Apple.Apns.ProviderData) throws -> Dictionary { 41 | var payload = try push.payload.encode() 42 | if var aps = payload["aps"] as? Dictionary { 43 | if let contentAvailable = aps["contentAvailable"] { 44 | aps["content-available"] = contentAvailable 45 | aps.removeValue(forKey:"contentAvailable") 46 | } 47 | if let mutableContent = aps["mutableContent"] { 48 | aps["mutable-content"] = mutableContent 49 | aps.removeValue(forKey: "mutableContent") 50 | } 51 | payload["aps"] = aps 52 | } 53 | return payload 54 | } 55 | 56 | 57 | } 58 | 59 | extension APNServiceStatus { 60 | public static func getResponseObject(response:APNServiceResponse) -> Apple.Apns.Response { 61 | let builder = Apple.Apns.Response.Builder() 62 | builder.statusCode = Int32(response.serviceStatus.0) 63 | if let reason = response.serviceErrorReason { 64 | builder.reason = reason.rawValue 65 | builder.reasonDescription = reason.getReasonDescription() 66 | } 67 | if let apnsId = response.apnsId { 68 | builder.apnsId = apnsId 69 | } 70 | return try! builder.build() 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Source/APNSNetwork.swift: -------------------------------------------------------------------------------- 1 | // 2 | // APNSNetwork.swift 3 | // APNS 4 | // 5 | // Created by Alexey Khokhlov on 25.01.16. 6 | // Copyright © 2016 Alexey Khokhlov. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Security 11 | 12 | public enum APNServiceErrorReason:String,CustomStringConvertible { 13 | case PayloadEmpty = "PayloadEmpty" 14 | case PayloadTooLarge = "PayloadTooLarge" 15 | case BadTopic = "BadTopic" 16 | case TopicDisallowed = "TopicDisallowed" 17 | case BadMessageId = "BadMessageId" 18 | case BadExpirationDate = "BadExpirationDate" 19 | case BadPriority = "BadPriority" 20 | case MissingDeviceToken = "MissingDeviceToken" 21 | case BadDeviceToken = "BadDeviceToken" 22 | case DeviceTokenNotForTopic = "DeviceTokenNotForTopic" 23 | case Unregistered = "Unregistered" 24 | case DuplicateHeaders = "DuplicateHeaders" 25 | case BadCertificateEnvironment = "BadCertificateEnvironment" 26 | case BadCertificate = "BadCertificate" 27 | case Forbidden = "Forbidden" 28 | case BadPath = "BadPath" 29 | case MethodNotAllowed = "MethodNotAllowed" 30 | case TooManyRequests = "TooManyRequests" 31 | case IdleTimeout = "IdleTimeout" 32 | case Shutdown = "Shutdown" 33 | case InternalServerError = "InternalServerError" 34 | case ServiceUnavailable = "ServiceUnavailable" 35 | case MissingTopic = "MissingTopic" 36 | 37 | public func getReasonDescription() -> String { 38 | switch self { 39 | case .PayloadEmpty: return "The message payload was empty." 40 | case .PayloadTooLarge: return "The message payload was too large. The maximum payload size is 4096 bytes." 41 | case .BadTopic: return "The apns-topic was invalid." 42 | case .TopicDisallowed: return "Pushing to this topic is not allowed." 43 | case .BadMessageId: return "The apns-id value is bad." 44 | case .BadExpirationDate: return "The apns-expiration value is bad." 45 | case .BadPriority: return "The apns-priority value is bad." 46 | case .MissingDeviceToken: return "The device token is not specified in the request :path. Verify that the :path header contains the device token." 47 | case .BadDeviceToken: return "The specified device token was bad. Verify that the request contains a valid token and that the token matches the environment." 48 | case .DeviceTokenNotForTopic: return "The device token does not match the specified topic." 49 | case .Unregistered: return "The device token is inactive for the specified topic." 50 | case .DuplicateHeaders: return "One or more headers were repeated." 51 | case .BadCertificateEnvironment: return "The client certificate was for the wrong environment." 52 | case .BadCertificate: return "The certificate was bad." 53 | case .Forbidden: return "The specified action is not allowed." 54 | case .BadPath: return "The request contained a bad :path value." 55 | case .MethodNotAllowed: return "The specified :method was not POST." 56 | case .TooManyRequests: return "Too many requests were made consecutively to the same device token." 57 | case .IdleTimeout: return "Idle time out." 58 | case .Shutdown: return "The server is shutting down." 59 | case .InternalServerError: return "An internal server error occurred." 60 | case .ServiceUnavailable: return "The service is unavailable." 61 | case .MissingTopic: return "The apns-topic header of the request was not specified and was required. The apns-topic header is mandatory when the client is connected using a certificate that supports multiple topics." 62 | } 63 | } 64 | 65 | public static func getServiceReasonBy(str:String) -> (APNServiceErrorReason, String) { 66 | let reason = APNServiceErrorReason(rawValue: str)! 67 | return (reason, reason.getReasonDescription()) 68 | } 69 | 70 | public var description: String { 71 | return self.rawValue + ": " + getReasonDescription() 72 | } 73 | } 74 | 75 | public struct APNServiceResponse { 76 | public var serviceStatus:(Int, APNServiceStatus) 77 | public var serviceErrorReason:APNServiceErrorReason? 78 | public var apnsId:String? 79 | } 80 | 81 | public enum APNServiceStatus: Error { 82 | case success 83 | case badRequest 84 | case badCertitficate 85 | case badMethod 86 | case deviceTokenIsNoLongerActive 87 | case badNotificationPayload 88 | case serverReceivedTooManyRequests 89 | case internalServerError 90 | case serverShutingDownOrUnavailable 91 | 92 | public static func statusCodeFrom(response:HTTPURLResponse) -> (Int, APNServiceStatus) { 93 | switch response.statusCode { 94 | case 400: 95 | return (response.statusCode,APNServiceStatus.badRequest) 96 | case 403: 97 | return (response.statusCode,APNServiceStatus.badCertitficate) 98 | case 405: 99 | return (response.statusCode,APNServiceStatus.badMethod) 100 | case 410: 101 | return (response.statusCode,APNServiceStatus.deviceTokenIsNoLongerActive) 102 | case 413: 103 | return (response.statusCode,APNServiceStatus.badNotificationPayload) 104 | case 429: 105 | return (response.statusCode,APNServiceStatus.serverReceivedTooManyRequests) 106 | case 500: 107 | return (response.statusCode,APNServiceStatus.internalServerError) 108 | case 503: 109 | return (response.statusCode,APNServiceStatus.serverShutingDownOrUnavailable) 110 | default: return (response.statusCode,APNServiceStatus.success) 111 | } 112 | } 113 | } 114 | 115 | /// Apple Push Notification Message 116 | public struct ApplePushMessage { 117 | /// Message Id 118 | public let messageId:String = UUID().uuidString 119 | /// Application BundleID 120 | public let topic:String 121 | /// APNS Priority 5 or 10 122 | public let priority:Int 123 | /// APNS Payload aps {...} 124 | public let payload:Dictionary 125 | /// Device Token without <> and whitespaces 126 | public let deviceToken:String 127 | /// Path for P12 certificate 128 | public let certificatePath:String 129 | /// Passphrase for certificate 130 | public let passphrase:String 131 | /// Use sandbox server URL or not 132 | public let sandbox:Bool 133 | /// Response Clousure 134 | public var responseBlock:((APNServiceResponse) -> ())? 135 | /// Network error Clousure 136 | public var networkError:((Error?)->())? 137 | /// Custom UrlSession 138 | public var session:URLSession? 139 | /// Send current message 140 | /// 141 | /// - throws: Method can throw error if payload data isn't parse. 142 | /// 143 | /// - returns: URLSessionDataTask 144 | public func send() throws -> URLSessionDataTask? { 145 | return try APNSNetwork(session:session).sendPushWith(message: self) 146 | } 147 | /// Send current message with custom URLSession 148 | /// 149 | /// - parameter session: URLSession 150 | /// 151 | /// - throws: Method can throw error if payload data isn't parse. 152 | /// 153 | /// - returns: URLSessionDataTask 154 | public func sendWith(session:URLSession?) throws -> URLSessionDataTask? { 155 | return try APNSNetwork(session:session).sendPushWith(message: self) 156 | } 157 | 158 | public init(topic:String, priority:Int, payload:Dictionary, deviceToken:String, certificatePath:String, passphrase:String, sandbox:Bool = true) { 159 | self.topic = topic 160 | self.priority = priority 161 | self.payload = payload 162 | self.deviceToken = deviceToken 163 | self.certificatePath = certificatePath 164 | self.passphrase = passphrase 165 | self.sandbox = sandbox 166 | } 167 | } 168 | 169 | 170 | open class APNSNetwork:NSObject { 171 | fileprivate var secIdentity:SecIdentity? 172 | static fileprivate var session:URLSession? 173 | public convenience override init() { 174 | self.init(session:nil) 175 | } 176 | 177 | public init(session:URLSession?) { 178 | super.init() 179 | guard let session = session else { 180 | let session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: OperationQueue.main) 181 | APNSNetwork.session = session 182 | return 183 | } 184 | APNSNetwork.session = session 185 | } 186 | 187 | 188 | open func sendPushWith(message:ApplePushMessage) throws -> URLSessionDataTask? { 189 | return try sendPushWith(topic: message.topic, 190 | priority: message.priority, 191 | payload: message.payload, 192 | deviceToken: message.deviceToken, 193 | certificatePath: message.certificatePath, 194 | passphrase: message.passphrase, 195 | sandbox: message.sandbox, 196 | responseBlock: message.responseBlock, 197 | networkError: message.networkError) 198 | } 199 | 200 | internal func sendPushWith(topic:String, priority:Int, payload:Dictionary, deviceToken:String, certificatePath:String, passphrase:String, sandbox:Bool, responseBlock:((APNServiceResponse) -> ())?, networkError:((Error?)->())?) throws -> URLSessionDataTask? { 201 | 202 | let url = serviceURLFor(sandbox: sandbox, token: deviceToken) 203 | var request = URLRequest(url: url) 204 | 205 | guard let ind = getIdentityWith(certificatePath: certificatePath, passphrase: passphrase) else { 206 | return nil 207 | } 208 | self.secIdentity = ind 209 | 210 | let data = try JSONSerialization.data(withJSONObject: payload, options: JSONSerialization.WritingOptions(rawValue: 0)) 211 | request.httpBody = data 212 | request.httpMethod = "POST" 213 | request.addValue(topic, forHTTPHeaderField: "apns-topic") 214 | request.addValue("\(priority)", forHTTPHeaderField: "apns-priority") 215 | 216 | let task = APNSNetwork.session?.dataTask(with: request, completionHandler:{ (data, response, err) -> Void in 217 | 218 | guard err == nil else { 219 | networkError?(err) 220 | return 221 | } 222 | guard let response = response as? HTTPURLResponse else { 223 | networkError?(err) 224 | return 225 | } 226 | 227 | let (statusCode, status) = APNServiceStatus.statusCodeFrom(response: response) 228 | let httpResponse = response 229 | let apnsId = httpResponse.allHeaderFields["apns-id"] as? String 230 | var responseStatus = APNServiceResponse(serviceStatus: (statusCode, status), serviceErrorReason: nil, apnsId: apnsId) 231 | 232 | guard status == .success else { 233 | let json = try? JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions(rawValue: 0)) 234 | guard let js = json as? Dictionary, 235 | let reason = js["reason"] as? String 236 | else { 237 | return 238 | } 239 | let serviceReason = APNServiceErrorReason(rawValue: reason) 240 | responseStatus.serviceErrorReason = serviceReason 241 | responseBlock?(responseStatus) 242 | return 243 | } 244 | responseStatus.apnsId = apnsId 245 | responseBlock?(responseStatus) 246 | }) 247 | task?.resume() 248 | return task 249 | 250 | } 251 | 252 | } 253 | 254 | extension APNSNetwork: URLSessionDelegate, URLSessionTaskDelegate { 255 | public func urlSession(_ session: URLSession, 256 | task: URLSessionTask, 257 | didReceive challenge: URLAuthenticationChallenge, 258 | completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { 259 | 260 | var cert : SecCertificate? 261 | SecIdentityCopyCertificate(self.secIdentity!, &cert) 262 | let credentials = URLCredential(identity: self.secIdentity!, certificates: [cert!], persistence: .forSession) 263 | completionHandler(.useCredential,credentials) 264 | } 265 | } 266 | 267 | extension APNSNetwork { 268 | internal func getIdentityWith(certificatePath:String, passphrase:String) -> SecIdentity? { 269 | let PKCS12Data = try? Data(contentsOf: URL(fileURLWithPath: certificatePath)) 270 | let key : String = kSecImportExportPassphrase as String 271 | let options = [key : passphrase] 272 | var items : CFArray? 273 | let ossStatus = SecPKCS12Import(PKCS12Data! as CFData, options as CFDictionary, &items) 274 | guard ossStatus == errSecSuccess else { 275 | return nil 276 | } 277 | let arr = items! 278 | if CFArrayGetCount(arr) > 0 { 279 | let newArray = arr as [AnyObject] 280 | let dictionary = newArray[0] 281 | let secIdentity = dictionary.value(forKey: kSecImportItemIdentity as String) as! SecIdentity 282 | return secIdentity 283 | } 284 | return nil 285 | } 286 | 287 | fileprivate func serviceURLFor(sandbox:Bool, token:String) -> URL { 288 | var serviceStrUrl:String? 289 | switch sandbox { 290 | case true: serviceStrUrl = "https://api.development.push.apple.com:443/3/device/" 291 | case false: serviceStrUrl = "https://api.push.apple.com:443/3/device/" 292 | } 293 | return URL(string: serviceStrUrl! + token)! 294 | } 295 | } 296 | 297 | 298 | 299 | -------------------------------------------------------------------------------- /Source/Apple.Apns.PushService.proto.swift: -------------------------------------------------------------------------------- 1 | // Generated by the Protocol Buffers 3.0 compiler. DO NOT EDIT! 2 | // Source file "PushService.proto" 3 | // Syntax "Proto3" 4 | 5 | import Foundation 6 | import ProtocolBuffers 7 | 8 | 9 | public struct Apple { public struct Apns { }} 10 | 11 | public extension Apple.Apns { 12 | public struct PushServiceRoot { 13 | public static let `default` = PushServiceRoot() 14 | public var extensionRegistry:ExtensionRegistry 15 | 16 | init() { 17 | extensionRegistry = ExtensionRegistry() 18 | registerAllExtensions(registry: extensionRegistry) 19 | } 20 | public func registerAllExtensions(registry: ExtensionRegistry) { 21 | } 22 | } 23 | 24 | final public class ProviderData : GeneratedMessage { 25 | 26 | public static func == (lhs: Apple.Apns.ProviderData, rhs: Apple.Apns.ProviderData) -> Bool { 27 | if (lhs === rhs) { 28 | return true 29 | } 30 | var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) 31 | fieldCheck = fieldCheck && (lhs.hasBundle == rhs.hasBundle) && (!lhs.hasBundle || lhs.bundle == rhs.bundle) 32 | fieldCheck = fieldCheck && (lhs.hasToken == rhs.hasToken) && (!lhs.hasToken || lhs.token == rhs.token) 33 | fieldCheck = fieldCheck && (lhs.hasPriority == rhs.hasPriority) && (!lhs.hasPriority || lhs.priority == rhs.priority) 34 | fieldCheck = fieldCheck && (lhs.hasPayload == rhs.hasPayload) && (!lhs.hasPayload || lhs.payload == rhs.payload) 35 | fieldCheck = fieldCheck && (lhs.hasServiceIdentity == rhs.hasServiceIdentity) && (!lhs.hasServiceIdentity || lhs.serviceIdentity == rhs.serviceIdentity) 36 | fieldCheck = fieldCheck && (lhs.hasCertificatePath == rhs.hasCertificatePath) && (!lhs.hasCertificatePath || lhs.certificatePath == rhs.certificatePath) 37 | fieldCheck = fieldCheck && (lhs.hasCertificatePassphrase == rhs.hasCertificatePassphrase) && (!lhs.hasCertificatePassphrase || lhs.certificatePassphrase == rhs.certificatePassphrase) 38 | fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) 39 | return fieldCheck 40 | } 41 | 42 | 43 | 44 | //Enum type declaration start 45 | 46 | public enum Identity:Int32, CustomDebugStringConvertible, CustomStringConvertible { 47 | case production = 0 48 | case development = 1 49 | public func toString() -> String { 50 | switch self { 51 | case .production: return "Production" 52 | case .development: return "Development" 53 | } 54 | } 55 | public static func fromString(str:String) throws -> Apple.Apns.ProviderData.Identity { 56 | switch str { 57 | case "Production": return .production 58 | case "Development": return .development 59 | default: throw ProtocolBuffersError.invalidProtocolBuffer("Conversion String to Enum has failed.") 60 | } 61 | } 62 | public var debugDescription:String { return getDescription() } 63 | public var description:String { return getDescription() } 64 | private func getDescription() -> String { 65 | switch self { 66 | case .production: return ".production" 67 | case .development: return ".development" 68 | } 69 | } 70 | } 71 | 72 | //Enum type declaration end 73 | 74 | public fileprivate(set) var bundle:String = "" 75 | public fileprivate(set) var hasBundle:Bool = false 76 | 77 | public fileprivate(set) var token:String = "" 78 | public fileprivate(set) var hasToken:Bool = false 79 | 80 | public fileprivate(set) var priority:UInt32 = UInt32(0) 81 | public fileprivate(set) var hasPriority:Bool = false 82 | 83 | public fileprivate(set) var payload:Apple.Apns.Push! 84 | public fileprivate(set) var hasPayload:Bool = false 85 | public fileprivate(set) var serviceIdentity:Apple.Apns.ProviderData.Identity = Apple.Apns.ProviderData.Identity.production 86 | public fileprivate(set) var hasServiceIdentity:Bool = false 87 | public fileprivate(set) var certificatePath:String = "" 88 | public fileprivate(set) var hasCertificatePath:Bool = false 89 | 90 | public fileprivate(set) var certificatePassphrase:String = "" 91 | public fileprivate(set) var hasCertificatePassphrase:Bool = false 92 | 93 | required public init() { 94 | super.init() 95 | } 96 | override public func isInitialized() -> Bool { 97 | return true 98 | } 99 | override public func writeTo(codedOutputStream: CodedOutputStream) throws { 100 | if hasBundle { 101 | try codedOutputStream.writeString(fieldNumber: 1, value:bundle) 102 | } 103 | if hasToken { 104 | try codedOutputStream.writeString(fieldNumber: 2, value:token) 105 | } 106 | if hasPriority { 107 | try codedOutputStream.writeUInt32(fieldNumber: 3, value:priority) 108 | } 109 | if hasPayload { 110 | try codedOutputStream.writeMessage(fieldNumber: 4, value:payload) 111 | } 112 | if hasServiceIdentity { 113 | try codedOutputStream.writeEnum(fieldNumber: 5, value:serviceIdentity.rawValue) 114 | } 115 | if hasCertificatePath { 116 | try codedOutputStream.writeString(fieldNumber: 6, value:certificatePath) 117 | } 118 | if hasCertificatePassphrase { 119 | try codedOutputStream.writeString(fieldNumber: 7, value:certificatePassphrase) 120 | } 121 | try unknownFields.writeTo(codedOutputStream: codedOutputStream) 122 | } 123 | override public func serializedSize() -> Int32 { 124 | var serialize_size:Int32 = memoizedSerializedSize 125 | if serialize_size != -1 { 126 | return serialize_size 127 | } 128 | 129 | serialize_size = 0 130 | if hasBundle { 131 | serialize_size += bundle.computeStringSize(fieldNumber: 1) 132 | } 133 | if hasToken { 134 | serialize_size += token.computeStringSize(fieldNumber: 2) 135 | } 136 | if hasPriority { 137 | serialize_size += priority.computeUInt32Size(fieldNumber: 3) 138 | } 139 | if hasPayload { 140 | if let varSizepayload = payload?.computeMessageSize(fieldNumber: 4) { 141 | serialize_size += varSizepayload 142 | } 143 | } 144 | if (hasServiceIdentity) { 145 | serialize_size += serviceIdentity.rawValue.computeEnumSize(fieldNumber: 5) 146 | } 147 | if hasCertificatePath { 148 | serialize_size += certificatePath.computeStringSize(fieldNumber: 6) 149 | } 150 | if hasCertificatePassphrase { 151 | serialize_size += certificatePassphrase.computeStringSize(fieldNumber: 7) 152 | } 153 | serialize_size += unknownFields.serializedSize() 154 | memoizedSerializedSize = serialize_size 155 | return serialize_size 156 | } 157 | public class func getBuilder() -> Apple.Apns.ProviderData.Builder { 158 | return Apple.Apns.ProviderData.classBuilder() as! Apple.Apns.ProviderData.Builder 159 | } 160 | public func getBuilder() -> Apple.Apns.ProviderData.Builder { 161 | return classBuilder() as! Apple.Apns.ProviderData.Builder 162 | } 163 | override public class func classBuilder() -> ProtocolBuffersMessageBuilder { 164 | return Apple.Apns.ProviderData.Builder() 165 | } 166 | override public func classBuilder() -> ProtocolBuffersMessageBuilder { 167 | return Apple.Apns.ProviderData.Builder() 168 | } 169 | public func toBuilder() throws -> Apple.Apns.ProviderData.Builder { 170 | return try Apple.Apns.ProviderData.builderWithPrototype(prototype:self) 171 | } 172 | public class func builderWithPrototype(prototype:Apple.Apns.ProviderData) throws -> Apple.Apns.ProviderData.Builder { 173 | return try Apple.Apns.ProviderData.Builder().mergeFrom(other:prototype) 174 | } 175 | override public func encode() throws -> Dictionary { 176 | guard isInitialized() else { 177 | throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") 178 | } 179 | 180 | var jsonMap:Dictionary = Dictionary() 181 | if hasBundle { 182 | jsonMap["bundle"] = bundle 183 | } 184 | if hasToken { 185 | jsonMap["token"] = token 186 | } 187 | if hasPriority { 188 | jsonMap["priority"] = UInt(priority) 189 | } 190 | if hasPayload { 191 | jsonMap["payload"] = try payload.encode() 192 | } 193 | if hasServiceIdentity { 194 | jsonMap["serviceIdentity"] = serviceIdentity.toString() 195 | } 196 | if hasCertificatePath { 197 | jsonMap["certificatePath"] = certificatePath 198 | } 199 | if hasCertificatePassphrase { 200 | jsonMap["certificatePassphrase"] = certificatePassphrase 201 | } 202 | return jsonMap 203 | } 204 | override class public func decode(jsonMap:Dictionary) throws -> Apple.Apns.ProviderData { 205 | return try Apple.Apns.ProviderData.Builder.decodeToBuilder(jsonMap:jsonMap).build() 206 | } 207 | override class public func fromJSON(data:Data) throws -> Apple.Apns.ProviderData { 208 | return try Apple.Apns.ProviderData.Builder.fromJSONToBuilder(data:data).build() 209 | } 210 | override public func getDescription(indent:String) throws -> String { 211 | var output = "" 212 | if hasBundle { 213 | output += "\(indent) bundle: \(bundle) \n" 214 | } 215 | if hasToken { 216 | output += "\(indent) token: \(token) \n" 217 | } 218 | if hasPriority { 219 | output += "\(indent) priority: \(priority) \n" 220 | } 221 | if hasPayload { 222 | output += "\(indent) payload {\n" 223 | if let outDescPayload = payload { 224 | output += try outDescPayload.getDescription(indent: "\(indent) ") 225 | } 226 | output += "\(indent) }\n" 227 | } 228 | if (hasServiceIdentity) { 229 | output += "\(indent) serviceIdentity: \(serviceIdentity.description)\n" 230 | } 231 | if hasCertificatePath { 232 | output += "\(indent) certificatePath: \(certificatePath) \n" 233 | } 234 | if hasCertificatePassphrase { 235 | output += "\(indent) certificatePassphrase: \(certificatePassphrase) \n" 236 | } 237 | output += unknownFields.getDescription(indent: indent) 238 | return output 239 | } 240 | override public var hashValue:Int { 241 | get { 242 | var hashCode:Int = 7 243 | if hasBundle { 244 | hashCode = (hashCode &* 31) &+ bundle.hashValue 245 | } 246 | if hasToken { 247 | hashCode = (hashCode &* 31) &+ token.hashValue 248 | } 249 | if hasPriority { 250 | hashCode = (hashCode &* 31) &+ priority.hashValue 251 | } 252 | if hasPayload { 253 | if let hashValuepayload = payload?.hashValue { 254 | hashCode = (hashCode &* 31) &+ hashValuepayload 255 | } 256 | } 257 | if hasServiceIdentity { 258 | hashCode = (hashCode &* 31) &+ Int(serviceIdentity.rawValue) 259 | } 260 | if hasCertificatePath { 261 | hashCode = (hashCode &* 31) &+ certificatePath.hashValue 262 | } 263 | if hasCertificatePassphrase { 264 | hashCode = (hashCode &* 31) &+ certificatePassphrase.hashValue 265 | } 266 | hashCode = (hashCode &* 31) &+ unknownFields.hashValue 267 | return hashCode 268 | } 269 | } 270 | 271 | 272 | //Meta information declaration start 273 | 274 | override public class func className() -> String { 275 | return "Apple.Apns.ProviderData" 276 | } 277 | override public func className() -> String { 278 | return "Apple.Apns.ProviderData" 279 | } 280 | //Meta information declaration end 281 | 282 | final public class Builder : GeneratedMessageBuilder { 283 | fileprivate var builderResult:Apple.Apns.ProviderData = Apple.Apns.ProviderData() 284 | public func getMessage() -> Apple.Apns.ProviderData { 285 | return builderResult 286 | } 287 | 288 | required override public init () { 289 | super.init() 290 | } 291 | public var hasBundle:Bool { 292 | get { 293 | return builderResult.hasBundle 294 | } 295 | } 296 | public var bundle:String { 297 | get { 298 | return builderResult.bundle 299 | } 300 | set (value) { 301 | builderResult.hasBundle = true 302 | builderResult.bundle = value 303 | } 304 | } 305 | @discardableResult 306 | public func setBundle(_ value:String) -> Apple.Apns.ProviderData.Builder { 307 | self.bundle = value 308 | return self 309 | } 310 | @discardableResult 311 | public func clearBundle() -> Apple.Apns.ProviderData.Builder{ 312 | builderResult.hasBundle = false 313 | builderResult.bundle = "" 314 | return self 315 | } 316 | public var hasToken:Bool { 317 | get { 318 | return builderResult.hasToken 319 | } 320 | } 321 | public var token:String { 322 | get { 323 | return builderResult.token 324 | } 325 | set (value) { 326 | builderResult.hasToken = true 327 | builderResult.token = value 328 | } 329 | } 330 | @discardableResult 331 | public func setToken(_ value:String) -> Apple.Apns.ProviderData.Builder { 332 | self.token = value 333 | return self 334 | } 335 | @discardableResult 336 | public func clearToken() -> Apple.Apns.ProviderData.Builder{ 337 | builderResult.hasToken = false 338 | builderResult.token = "" 339 | return self 340 | } 341 | public var hasPriority:Bool { 342 | get { 343 | return builderResult.hasPriority 344 | } 345 | } 346 | public var priority:UInt32 { 347 | get { 348 | return builderResult.priority 349 | } 350 | set (value) { 351 | builderResult.hasPriority = true 352 | builderResult.priority = value 353 | } 354 | } 355 | @discardableResult 356 | public func setPriority(_ value:UInt32) -> Apple.Apns.ProviderData.Builder { 357 | self.priority = value 358 | return self 359 | } 360 | @discardableResult 361 | public func clearPriority() -> Apple.Apns.ProviderData.Builder{ 362 | builderResult.hasPriority = false 363 | builderResult.priority = UInt32(0) 364 | return self 365 | } 366 | public var hasPayload:Bool { 367 | get { 368 | return builderResult.hasPayload 369 | } 370 | } 371 | public var payload:Apple.Apns.Push! { 372 | get { 373 | if payloadBuilder_ != nil { 374 | builderResult.payload = payloadBuilder_.getMessage() 375 | } 376 | return builderResult.payload 377 | } 378 | set (value) { 379 | builderResult.hasPayload = true 380 | builderResult.payload = value 381 | } 382 | } 383 | fileprivate var payloadBuilder_:Apple.Apns.Push.Builder! { 384 | didSet { 385 | builderResult.hasPayload = true 386 | } 387 | } 388 | public func getPayloadBuilder() -> Apple.Apns.Push.Builder { 389 | if payloadBuilder_ == nil { 390 | payloadBuilder_ = Apple.Apns.Push.Builder() 391 | builderResult.payload = payloadBuilder_.getMessage() 392 | if payload != nil { 393 | try! payloadBuilder_.mergeFrom(other: payload) 394 | } 395 | } 396 | return payloadBuilder_ 397 | } 398 | @discardableResult 399 | public func setPayload(_ value:Apple.Apns.Push!) -> Apple.Apns.ProviderData.Builder { 400 | self.payload = value 401 | return self 402 | } 403 | @discardableResult 404 | public func mergePayload(value:Apple.Apns.Push) throws -> Apple.Apns.ProviderData.Builder { 405 | if builderResult.hasPayload { 406 | builderResult.payload = try Apple.Apns.Push.builderWithPrototype(prototype:builderResult.payload).mergeFrom(other: value).buildPartial() 407 | } else { 408 | builderResult.payload = value 409 | } 410 | builderResult.hasPayload = true 411 | return self 412 | } 413 | @discardableResult 414 | public func clearPayload() -> Apple.Apns.ProviderData.Builder { 415 | payloadBuilder_ = nil 416 | builderResult.hasPayload = false 417 | builderResult.payload = nil 418 | return self 419 | } 420 | public var hasServiceIdentity:Bool{ 421 | get { 422 | return builderResult.hasServiceIdentity 423 | } 424 | } 425 | public var serviceIdentity:Apple.Apns.ProviderData.Identity { 426 | get { 427 | return builderResult.serviceIdentity 428 | } 429 | set (value) { 430 | builderResult.hasServiceIdentity = true 431 | builderResult.serviceIdentity = value 432 | } 433 | } 434 | @discardableResult 435 | public func setServiceIdentity(_ value:Apple.Apns.ProviderData.Identity) -> Apple.Apns.ProviderData.Builder { 436 | self.serviceIdentity = value 437 | return self 438 | } 439 | @discardableResult 440 | public func clearServiceIdentity() -> Apple.Apns.ProviderData.Builder { 441 | builderResult.hasServiceIdentity = false 442 | builderResult.serviceIdentity = .production 443 | return self 444 | } 445 | public var hasCertificatePath:Bool { 446 | get { 447 | return builderResult.hasCertificatePath 448 | } 449 | } 450 | public var certificatePath:String { 451 | get { 452 | return builderResult.certificatePath 453 | } 454 | set (value) { 455 | builderResult.hasCertificatePath = true 456 | builderResult.certificatePath = value 457 | } 458 | } 459 | @discardableResult 460 | public func setCertificatePath(_ value:String) -> Apple.Apns.ProviderData.Builder { 461 | self.certificatePath = value 462 | return self 463 | } 464 | @discardableResult 465 | public func clearCertificatePath() -> Apple.Apns.ProviderData.Builder{ 466 | builderResult.hasCertificatePath = false 467 | builderResult.certificatePath = "" 468 | return self 469 | } 470 | public var hasCertificatePassphrase:Bool { 471 | get { 472 | return builderResult.hasCertificatePassphrase 473 | } 474 | } 475 | public var certificatePassphrase:String { 476 | get { 477 | return builderResult.certificatePassphrase 478 | } 479 | set (value) { 480 | builderResult.hasCertificatePassphrase = true 481 | builderResult.certificatePassphrase = value 482 | } 483 | } 484 | @discardableResult 485 | public func setCertificatePassphrase(_ value:String) -> Apple.Apns.ProviderData.Builder { 486 | self.certificatePassphrase = value 487 | return self 488 | } 489 | @discardableResult 490 | public func clearCertificatePassphrase() -> Apple.Apns.ProviderData.Builder{ 491 | builderResult.hasCertificatePassphrase = false 492 | builderResult.certificatePassphrase = "" 493 | return self 494 | } 495 | override public var internalGetResult:GeneratedMessage { 496 | get { 497 | return builderResult 498 | } 499 | } 500 | @discardableResult 501 | override public func clear() -> Apple.Apns.ProviderData.Builder { 502 | builderResult = Apple.Apns.ProviderData() 503 | return self 504 | } 505 | override public func clone() throws -> Apple.Apns.ProviderData.Builder { 506 | return try Apple.Apns.ProviderData.builderWithPrototype(prototype:builderResult) 507 | } 508 | override public func build() throws -> Apple.Apns.ProviderData { 509 | try checkInitialized() 510 | return buildPartial() 511 | } 512 | public func buildPartial() -> Apple.Apns.ProviderData { 513 | let returnMe:Apple.Apns.ProviderData = builderResult 514 | return returnMe 515 | } 516 | @discardableResult 517 | public func mergeFrom(other:Apple.Apns.ProviderData) throws -> Apple.Apns.ProviderData.Builder { 518 | if other == Apple.Apns.ProviderData() { 519 | return self 520 | } 521 | if other.hasBundle { 522 | bundle = other.bundle 523 | } 524 | if other.hasToken { 525 | token = other.token 526 | } 527 | if other.hasPriority { 528 | priority = other.priority 529 | } 530 | if (other.hasPayload) { 531 | try mergePayload(value: other.payload) 532 | } 533 | if other.hasServiceIdentity { 534 | serviceIdentity = other.serviceIdentity 535 | } 536 | if other.hasCertificatePath { 537 | certificatePath = other.certificatePath 538 | } 539 | if other.hasCertificatePassphrase { 540 | certificatePassphrase = other.certificatePassphrase 541 | } 542 | try merge(unknownField: other.unknownFields) 543 | return self 544 | } 545 | @discardableResult 546 | override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.ProviderData.Builder { 547 | return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) 548 | } 549 | @discardableResult 550 | override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.ProviderData.Builder { 551 | let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) 552 | while (true) { 553 | let protobufTag = try codedInputStream.readTag() 554 | switch protobufTag { 555 | case 0: 556 | self.unknownFields = try unknownFieldsBuilder.build() 557 | return self 558 | 559 | case 10: 560 | bundle = try codedInputStream.readString() 561 | 562 | case 18: 563 | token = try codedInputStream.readString() 564 | 565 | case 24: 566 | priority = try codedInputStream.readUInt32() 567 | 568 | case 34: 569 | let subBuilder:Apple.Apns.Push.Builder = Apple.Apns.Push.Builder() 570 | if hasPayload { 571 | try subBuilder.mergeFrom(other: payload) 572 | } 573 | try codedInputStream.readMessage(builder: subBuilder, extensionRegistry:extensionRegistry) 574 | payload = subBuilder.buildPartial() 575 | 576 | case 40: 577 | let valueIntserviceIdentity = try codedInputStream.readEnum() 578 | if let enumsserviceIdentity = Apple.Apns.ProviderData.Identity(rawValue:valueIntserviceIdentity){ 579 | serviceIdentity = enumsserviceIdentity 580 | } else { 581 | try unknownFieldsBuilder.mergeVarintField(fieldNumber: 5, value:Int64(valueIntserviceIdentity)) 582 | } 583 | 584 | case 50: 585 | certificatePath = try codedInputStream.readString() 586 | 587 | case 58: 588 | certificatePassphrase = try codedInputStream.readString() 589 | 590 | default: 591 | if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { 592 | unknownFields = try unknownFieldsBuilder.build() 593 | return self 594 | } 595 | } 596 | } 597 | } 598 | class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Apple.Apns.ProviderData.Builder { 599 | let resultDecodedBuilder = Apple.Apns.ProviderData.Builder() 600 | if let jsonValueBundle = jsonMap["bundle"] as? String { 601 | resultDecodedBuilder.bundle = jsonValueBundle 602 | } 603 | if let jsonValueToken = jsonMap["token"] as? String { 604 | resultDecodedBuilder.token = jsonValueToken 605 | } 606 | if let jsonValuePriority = jsonMap["priority"] as? UInt { 607 | resultDecodedBuilder.priority = UInt32(jsonValuePriority) 608 | } 609 | if let jsonValuePayload = jsonMap["payload"] as? Dictionary { 610 | resultDecodedBuilder.payload = try Apple.Apns.Push.Builder.decodeToBuilder(jsonMap:jsonValuePayload).build() 611 | 612 | } 613 | if let jsonValueServiceIdentity = jsonMap["serviceIdentity"] as? String { 614 | resultDecodedBuilder.serviceIdentity = try Apple.Apns.ProviderData.Identity.fromString(str: jsonValueServiceIdentity) 615 | } 616 | if let jsonValueCertificatePath = jsonMap["certificatePath"] as? String { 617 | resultDecodedBuilder.certificatePath = jsonValueCertificatePath 618 | } 619 | if let jsonValueCertificatePassphrase = jsonMap["certificatePassphrase"] as? String { 620 | resultDecodedBuilder.certificatePassphrase = jsonValueCertificatePassphrase 621 | } 622 | return resultDecodedBuilder 623 | } 624 | override class public func fromJSONToBuilder(data:Data) throws -> Apple.Apns.ProviderData.Builder { 625 | let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) 626 | guard let jsDataCast = jsonData as? Dictionary else { 627 | throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") 628 | } 629 | return try Apple.Apns.ProviderData.Builder.decodeToBuilder(jsonMap:jsDataCast) 630 | } 631 | } 632 | 633 | } 634 | 635 | final public class Response : GeneratedMessage { 636 | 637 | public static func == (lhs: Apple.Apns.Response, rhs: Apple.Apns.Response) -> Bool { 638 | if (lhs === rhs) { 639 | return true 640 | } 641 | var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) 642 | fieldCheck = fieldCheck && (lhs.hasStatusCode == rhs.hasStatusCode) && (!lhs.hasStatusCode || lhs.statusCode == rhs.statusCode) 643 | fieldCheck = fieldCheck && (lhs.hasApnsId == rhs.hasApnsId) && (!lhs.hasApnsId || lhs.apnsId == rhs.apnsId) 644 | fieldCheck = fieldCheck && (lhs.hasReason == rhs.hasReason) && (!lhs.hasReason || lhs.reason == rhs.reason) 645 | fieldCheck = fieldCheck && (lhs.hasReasonDescription == rhs.hasReasonDescription) && (!lhs.hasReasonDescription || lhs.reasonDescription == rhs.reasonDescription) 646 | fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) 647 | return fieldCheck 648 | } 649 | 650 | //200 - Success 651 | //400 - Bad request 652 | //403 - There was an error with the certificate. 653 | //405 - The request used a bad :method value. Only POST requests are supported. 654 | //410 - The device token is no longer active for the topic. 655 | //413 - The notification payload was too large. 656 | //429 - The server received too many requests for the same device token. 657 | //500 - Internal server error 658 | //503 - The server is shutting down and unavailable. 659 | public fileprivate(set) var statusCode:Int32 = Int32(0) 660 | public fileprivate(set) var hasStatusCode:Bool = false 661 | 662 | public fileprivate(set) var apnsId:String = "" 663 | public fileprivate(set) var hasApnsId:Bool = false 664 | 665 | public fileprivate(set) var reason:String = "" 666 | public fileprivate(set) var hasReason:Bool = false 667 | 668 | public fileprivate(set) var reasonDescription:String = "" 669 | public fileprivate(set) var hasReasonDescription:Bool = false 670 | 671 | required public init() { 672 | super.init() 673 | } 674 | override public func isInitialized() -> Bool { 675 | return true 676 | } 677 | override public func writeTo(codedOutputStream: CodedOutputStream) throws { 678 | if hasStatusCode { 679 | try codedOutputStream.writeInt32(fieldNumber: 1, value:statusCode) 680 | } 681 | if hasApnsId { 682 | try codedOutputStream.writeString(fieldNumber: 2, value:apnsId) 683 | } 684 | if hasReason { 685 | try codedOutputStream.writeString(fieldNumber: 3, value:reason) 686 | } 687 | if hasReasonDescription { 688 | try codedOutputStream.writeString(fieldNumber: 4, value:reasonDescription) 689 | } 690 | try unknownFields.writeTo(codedOutputStream: codedOutputStream) 691 | } 692 | override public func serializedSize() -> Int32 { 693 | var serialize_size:Int32 = memoizedSerializedSize 694 | if serialize_size != -1 { 695 | return serialize_size 696 | } 697 | 698 | serialize_size = 0 699 | if hasStatusCode { 700 | serialize_size += statusCode.computeInt32Size(fieldNumber: 1) 701 | } 702 | if hasApnsId { 703 | serialize_size += apnsId.computeStringSize(fieldNumber: 2) 704 | } 705 | if hasReason { 706 | serialize_size += reason.computeStringSize(fieldNumber: 3) 707 | } 708 | if hasReasonDescription { 709 | serialize_size += reasonDescription.computeStringSize(fieldNumber: 4) 710 | } 711 | serialize_size += unknownFields.serializedSize() 712 | memoizedSerializedSize = serialize_size 713 | return serialize_size 714 | } 715 | public class func getBuilder() -> Apple.Apns.Response.Builder { 716 | return Apple.Apns.Response.classBuilder() as! Apple.Apns.Response.Builder 717 | } 718 | public func getBuilder() -> Apple.Apns.Response.Builder { 719 | return classBuilder() as! Apple.Apns.Response.Builder 720 | } 721 | override public class func classBuilder() -> ProtocolBuffersMessageBuilder { 722 | return Apple.Apns.Response.Builder() 723 | } 724 | override public func classBuilder() -> ProtocolBuffersMessageBuilder { 725 | return Apple.Apns.Response.Builder() 726 | } 727 | public func toBuilder() throws -> Apple.Apns.Response.Builder { 728 | return try Apple.Apns.Response.builderWithPrototype(prototype:self) 729 | } 730 | public class func builderWithPrototype(prototype:Apple.Apns.Response) throws -> Apple.Apns.Response.Builder { 731 | return try Apple.Apns.Response.Builder().mergeFrom(other:prototype) 732 | } 733 | override public func encode() throws -> Dictionary { 734 | guard isInitialized() else { 735 | throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") 736 | } 737 | 738 | var jsonMap:Dictionary = Dictionary() 739 | if hasStatusCode { 740 | jsonMap["statusCode"] = Int(statusCode) 741 | } 742 | if hasApnsId { 743 | jsonMap["apnsId"] = apnsId 744 | } 745 | if hasReason { 746 | jsonMap["reason"] = reason 747 | } 748 | if hasReasonDescription { 749 | jsonMap["reasonDescription"] = reasonDescription 750 | } 751 | return jsonMap 752 | } 753 | override class public func decode(jsonMap:Dictionary) throws -> Apple.Apns.Response { 754 | return try Apple.Apns.Response.Builder.decodeToBuilder(jsonMap:jsonMap).build() 755 | } 756 | override class public func fromJSON(data:Data) throws -> Apple.Apns.Response { 757 | return try Apple.Apns.Response.Builder.fromJSONToBuilder(data:data).build() 758 | } 759 | override public func getDescription(indent:String) throws -> String { 760 | var output = "" 761 | if hasStatusCode { 762 | output += "\(indent) statusCode: \(statusCode) \n" 763 | } 764 | if hasApnsId { 765 | output += "\(indent) apnsId: \(apnsId) \n" 766 | } 767 | if hasReason { 768 | output += "\(indent) reason: \(reason) \n" 769 | } 770 | if hasReasonDescription { 771 | output += "\(indent) reasonDescription: \(reasonDescription) \n" 772 | } 773 | output += unknownFields.getDescription(indent: indent) 774 | return output 775 | } 776 | override public var hashValue:Int { 777 | get { 778 | var hashCode:Int = 7 779 | if hasStatusCode { 780 | hashCode = (hashCode &* 31) &+ statusCode.hashValue 781 | } 782 | if hasApnsId { 783 | hashCode = (hashCode &* 31) &+ apnsId.hashValue 784 | } 785 | if hasReason { 786 | hashCode = (hashCode &* 31) &+ reason.hashValue 787 | } 788 | if hasReasonDescription { 789 | hashCode = (hashCode &* 31) &+ reasonDescription.hashValue 790 | } 791 | hashCode = (hashCode &* 31) &+ unknownFields.hashValue 792 | return hashCode 793 | } 794 | } 795 | 796 | 797 | //Meta information declaration start 798 | 799 | override public class func className() -> String { 800 | return "Apple.Apns.Response" 801 | } 802 | override public func className() -> String { 803 | return "Apple.Apns.Response" 804 | } 805 | //Meta information declaration end 806 | 807 | final public class Builder : GeneratedMessageBuilder { 808 | fileprivate var builderResult:Apple.Apns.Response = Apple.Apns.Response() 809 | public func getMessage() -> Apple.Apns.Response { 810 | return builderResult 811 | } 812 | 813 | required override public init () { 814 | super.init() 815 | } 816 | public var hasStatusCode:Bool { 817 | get { 818 | return builderResult.hasStatusCode 819 | } 820 | } 821 | public var statusCode:Int32 { 822 | get { 823 | return builderResult.statusCode 824 | } 825 | set (value) { 826 | builderResult.hasStatusCode = true 827 | builderResult.statusCode = value 828 | } 829 | } 830 | @discardableResult 831 | public func setStatusCode(_ value:Int32) -> Apple.Apns.Response.Builder { 832 | self.statusCode = value 833 | return self 834 | } 835 | @discardableResult 836 | public func clearStatusCode() -> Apple.Apns.Response.Builder{ 837 | builderResult.hasStatusCode = false 838 | builderResult.statusCode = Int32(0) 839 | return self 840 | } 841 | public var hasApnsId:Bool { 842 | get { 843 | return builderResult.hasApnsId 844 | } 845 | } 846 | public var apnsId:String { 847 | get { 848 | return builderResult.apnsId 849 | } 850 | set (value) { 851 | builderResult.hasApnsId = true 852 | builderResult.apnsId = value 853 | } 854 | } 855 | @discardableResult 856 | public func setApnsId(_ value:String) -> Apple.Apns.Response.Builder { 857 | self.apnsId = value 858 | return self 859 | } 860 | @discardableResult 861 | public func clearApnsId() -> Apple.Apns.Response.Builder{ 862 | builderResult.hasApnsId = false 863 | builderResult.apnsId = "" 864 | return self 865 | } 866 | public var hasReason:Bool { 867 | get { 868 | return builderResult.hasReason 869 | } 870 | } 871 | public var reason:String { 872 | get { 873 | return builderResult.reason 874 | } 875 | set (value) { 876 | builderResult.hasReason = true 877 | builderResult.reason = value 878 | } 879 | } 880 | @discardableResult 881 | public func setReason(_ value:String) -> Apple.Apns.Response.Builder { 882 | self.reason = value 883 | return self 884 | } 885 | @discardableResult 886 | public func clearReason() -> Apple.Apns.Response.Builder{ 887 | builderResult.hasReason = false 888 | builderResult.reason = "" 889 | return self 890 | } 891 | public var hasReasonDescription:Bool { 892 | get { 893 | return builderResult.hasReasonDescription 894 | } 895 | } 896 | public var reasonDescription:String { 897 | get { 898 | return builderResult.reasonDescription 899 | } 900 | set (value) { 901 | builderResult.hasReasonDescription = true 902 | builderResult.reasonDescription = value 903 | } 904 | } 905 | @discardableResult 906 | public func setReasonDescription(_ value:String) -> Apple.Apns.Response.Builder { 907 | self.reasonDescription = value 908 | return self 909 | } 910 | @discardableResult 911 | public func clearReasonDescription() -> Apple.Apns.Response.Builder{ 912 | builderResult.hasReasonDescription = false 913 | builderResult.reasonDescription = "" 914 | return self 915 | } 916 | override public var internalGetResult:GeneratedMessage { 917 | get { 918 | return builderResult 919 | } 920 | } 921 | @discardableResult 922 | override public func clear() -> Apple.Apns.Response.Builder { 923 | builderResult = Apple.Apns.Response() 924 | return self 925 | } 926 | override public func clone() throws -> Apple.Apns.Response.Builder { 927 | return try Apple.Apns.Response.builderWithPrototype(prototype:builderResult) 928 | } 929 | override public func build() throws -> Apple.Apns.Response { 930 | try checkInitialized() 931 | return buildPartial() 932 | } 933 | public func buildPartial() -> Apple.Apns.Response { 934 | let returnMe:Apple.Apns.Response = builderResult 935 | return returnMe 936 | } 937 | @discardableResult 938 | public func mergeFrom(other:Apple.Apns.Response) throws -> Apple.Apns.Response.Builder { 939 | if other == Apple.Apns.Response() { 940 | return self 941 | } 942 | if other.hasStatusCode { 943 | statusCode = other.statusCode 944 | } 945 | if other.hasApnsId { 946 | apnsId = other.apnsId 947 | } 948 | if other.hasReason { 949 | reason = other.reason 950 | } 951 | if other.hasReasonDescription { 952 | reasonDescription = other.reasonDescription 953 | } 954 | try merge(unknownField: other.unknownFields) 955 | return self 956 | } 957 | @discardableResult 958 | override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.Response.Builder { 959 | return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) 960 | } 961 | @discardableResult 962 | override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Response.Builder { 963 | let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) 964 | while (true) { 965 | let protobufTag = try codedInputStream.readTag() 966 | switch protobufTag { 967 | case 0: 968 | self.unknownFields = try unknownFieldsBuilder.build() 969 | return self 970 | 971 | case 8: 972 | statusCode = try codedInputStream.readInt32() 973 | 974 | case 18: 975 | apnsId = try codedInputStream.readString() 976 | 977 | case 26: 978 | reason = try codedInputStream.readString() 979 | 980 | case 34: 981 | reasonDescription = try codedInputStream.readString() 982 | 983 | default: 984 | if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { 985 | unknownFields = try unknownFieldsBuilder.build() 986 | return self 987 | } 988 | } 989 | } 990 | } 991 | class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Apple.Apns.Response.Builder { 992 | let resultDecodedBuilder = Apple.Apns.Response.Builder() 993 | if let jsonValueStatusCode = jsonMap["statusCode"] as? Int { 994 | resultDecodedBuilder.statusCode = Int32(jsonValueStatusCode) 995 | } 996 | if let jsonValueApnsId = jsonMap["apnsId"] as? String { 997 | resultDecodedBuilder.apnsId = jsonValueApnsId 998 | } 999 | if let jsonValueReason = jsonMap["reason"] as? String { 1000 | resultDecodedBuilder.reason = jsonValueReason 1001 | } 1002 | if let jsonValueReasonDescription = jsonMap["reasonDescription"] as? String { 1003 | resultDecodedBuilder.reasonDescription = jsonValueReasonDescription 1004 | } 1005 | return resultDecodedBuilder 1006 | } 1007 | override class public func fromJSONToBuilder(data:Data) throws -> Apple.Apns.Response.Builder { 1008 | let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) 1009 | guard let jsDataCast = jsonData as? Dictionary else { 1010 | throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") 1011 | } 1012 | return try Apple.Apns.Response.Builder.decodeToBuilder(jsonMap:jsDataCast) 1013 | } 1014 | } 1015 | 1016 | } 1017 | 1018 | final public class Push : GeneratedMessage { 1019 | 1020 | public static func == (lhs: Apple.Apns.Push, rhs: Apple.Apns.Push) -> Bool { 1021 | if (lhs === rhs) { 1022 | return true 1023 | } 1024 | var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) 1025 | fieldCheck = fieldCheck && (lhs.hasAps == rhs.hasAps) && (!lhs.hasAps || lhs.aps == rhs.aps) 1026 | fieldCheck = fieldCheck && (lhs.hasImage == rhs.hasImage) && (!lhs.hasImage || lhs.image == rhs.image) 1027 | fieldCheck = fieldCheck && (lhs.hasVideo == rhs.hasVideo) && (!lhs.hasVideo || lhs.video == rhs.video) 1028 | fieldCheck = fieldCheck && (lhs.hasAudio == rhs.hasAudio) && (!lhs.hasAudio || lhs.audio == rhs.audio) 1029 | fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) 1030 | return fieldCheck 1031 | } 1032 | 1033 | 1034 | 1035 | //Nested type declaration start 1036 | 1037 | final public class Aps : GeneratedMessage { 1038 | 1039 | public static func == (lhs: Apple.Apns.Push.Aps, rhs: Apple.Apns.Push.Aps) -> Bool { 1040 | if (lhs === rhs) { 1041 | return true 1042 | } 1043 | var fieldCheck:Bool = (lhs.hashValue == rhs.hashValue) 1044 | fieldCheck = fieldCheck && (lhs.hasAlert == rhs.hasAlert) && (!lhs.hasAlert || lhs.alert == rhs.alert) 1045 | fieldCheck = fieldCheck && (lhs.hasSound == rhs.hasSound) && (!lhs.hasSound || lhs.sound == rhs.sound) 1046 | fieldCheck = fieldCheck && (lhs.hasBadge == rhs.hasBadge) && (!lhs.hasBadge || lhs.badge == rhs.badge) 1047 | fieldCheck = fieldCheck && (lhs.hasContentAvailable == rhs.hasContentAvailable) && (!lhs.hasContentAvailable || lhs.contentAvailable == rhs.contentAvailable) 1048 | fieldCheck = fieldCheck && (lhs.hasMutableContent == rhs.hasMutableContent) && (!lhs.hasMutableContent || lhs.mutableContent == rhs.mutableContent) 1049 | fieldCheck = fieldCheck && (lhs.hasCategory == rhs.hasCategory) && (!lhs.hasCategory || lhs.category == rhs.category) 1050 | fieldCheck = (fieldCheck && (lhs.unknownFields == rhs.unknownFields)) 1051 | return fieldCheck 1052 | } 1053 | 1054 | public fileprivate(set) var alert:String = "" 1055 | public fileprivate(set) var hasAlert:Bool = false 1056 | 1057 | public fileprivate(set) var sound:String = "" 1058 | public fileprivate(set) var hasSound:Bool = false 1059 | 1060 | public fileprivate(set) var badge:Int32 = Int32(0) 1061 | public fileprivate(set) var hasBadge:Bool = false 1062 | 1063 | public fileprivate(set) var contentAvailable:Int32 = Int32(0) 1064 | public fileprivate(set) var hasContentAvailable:Bool = false 1065 | 1066 | public fileprivate(set) var mutableContent:Int32 = Int32(0) 1067 | public fileprivate(set) var hasMutableContent:Bool = false 1068 | 1069 | public fileprivate(set) var category:String = "" 1070 | public fileprivate(set) var hasCategory:Bool = false 1071 | 1072 | required public init() { 1073 | super.init() 1074 | } 1075 | override public func isInitialized() -> Bool { 1076 | return true 1077 | } 1078 | override public func writeTo(codedOutputStream: CodedOutputStream) throws { 1079 | if hasAlert { 1080 | try codedOutputStream.writeString(fieldNumber: 1, value:alert) 1081 | } 1082 | if hasSound { 1083 | try codedOutputStream.writeString(fieldNumber: 2, value:sound) 1084 | } 1085 | if hasBadge { 1086 | try codedOutputStream.writeInt32(fieldNumber: 3, value:badge) 1087 | } 1088 | if hasContentAvailable { 1089 | try codedOutputStream.writeInt32(fieldNumber: 4, value:contentAvailable) 1090 | } 1091 | if hasMutableContent { 1092 | try codedOutputStream.writeInt32(fieldNumber: 5, value:mutableContent) 1093 | } 1094 | if hasCategory { 1095 | try codedOutputStream.writeString(fieldNumber: 6, value:category) 1096 | } 1097 | try unknownFields.writeTo(codedOutputStream: codedOutputStream) 1098 | } 1099 | override public func serializedSize() -> Int32 { 1100 | var serialize_size:Int32 = memoizedSerializedSize 1101 | if serialize_size != -1 { 1102 | return serialize_size 1103 | } 1104 | 1105 | serialize_size = 0 1106 | if hasAlert { 1107 | serialize_size += alert.computeStringSize(fieldNumber: 1) 1108 | } 1109 | if hasSound { 1110 | serialize_size += sound.computeStringSize(fieldNumber: 2) 1111 | } 1112 | if hasBadge { 1113 | serialize_size += badge.computeInt32Size(fieldNumber: 3) 1114 | } 1115 | if hasContentAvailable { 1116 | serialize_size += contentAvailable.computeInt32Size(fieldNumber: 4) 1117 | } 1118 | if hasMutableContent { 1119 | serialize_size += mutableContent.computeInt32Size(fieldNumber: 5) 1120 | } 1121 | if hasCategory { 1122 | serialize_size += category.computeStringSize(fieldNumber: 6) 1123 | } 1124 | serialize_size += unknownFields.serializedSize() 1125 | memoizedSerializedSize = serialize_size 1126 | return serialize_size 1127 | } 1128 | public class func getBuilder() -> Apple.Apns.Push.Aps.Builder { 1129 | return Apple.Apns.Push.Aps.classBuilder() as! Apple.Apns.Push.Aps.Builder 1130 | } 1131 | public func getBuilder() -> Apple.Apns.Push.Aps.Builder { 1132 | return classBuilder() as! Apple.Apns.Push.Aps.Builder 1133 | } 1134 | override public class func classBuilder() -> ProtocolBuffersMessageBuilder { 1135 | return Apple.Apns.Push.Aps.Builder() 1136 | } 1137 | override public func classBuilder() -> ProtocolBuffersMessageBuilder { 1138 | return Apple.Apns.Push.Aps.Builder() 1139 | } 1140 | public func toBuilder() throws -> Apple.Apns.Push.Aps.Builder { 1141 | return try Apple.Apns.Push.Aps.builderWithPrototype(prototype:self) 1142 | } 1143 | public class func builderWithPrototype(prototype:Apple.Apns.Push.Aps) throws -> Apple.Apns.Push.Aps.Builder { 1144 | return try Apple.Apns.Push.Aps.Builder().mergeFrom(other:prototype) 1145 | } 1146 | override public func encode() throws -> Dictionary { 1147 | guard isInitialized() else { 1148 | throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") 1149 | } 1150 | 1151 | var jsonMap:Dictionary = Dictionary() 1152 | if hasAlert { 1153 | jsonMap["alert"] = alert 1154 | } 1155 | if hasSound { 1156 | jsonMap["sound"] = sound 1157 | } 1158 | if hasBadge { 1159 | jsonMap["badge"] = Int(badge) 1160 | } 1161 | if hasContentAvailable { 1162 | jsonMap["contentAvailable"] = Int(contentAvailable) 1163 | } 1164 | if hasMutableContent { 1165 | jsonMap["mutableContent"] = Int(mutableContent) 1166 | } 1167 | if hasCategory { 1168 | jsonMap["category"] = category 1169 | } 1170 | return jsonMap 1171 | } 1172 | override class public func decode(jsonMap:Dictionary) throws -> Apple.Apns.Push.Aps { 1173 | return try Apple.Apns.Push.Aps.Builder.decodeToBuilder(jsonMap:jsonMap).build() 1174 | } 1175 | override class public func fromJSON(data:Data) throws -> Apple.Apns.Push.Aps { 1176 | return try Apple.Apns.Push.Aps.Builder.fromJSONToBuilder(data:data).build() 1177 | } 1178 | override public func getDescription(indent:String) throws -> String { 1179 | var output = "" 1180 | if hasAlert { 1181 | output += "\(indent) alert: \(alert) \n" 1182 | } 1183 | if hasSound { 1184 | output += "\(indent) sound: \(sound) \n" 1185 | } 1186 | if hasBadge { 1187 | output += "\(indent) badge: \(badge) \n" 1188 | } 1189 | if hasContentAvailable { 1190 | output += "\(indent) contentAvailable: \(contentAvailable) \n" 1191 | } 1192 | if hasMutableContent { 1193 | output += "\(indent) mutableContent: \(mutableContent) \n" 1194 | } 1195 | if hasCategory { 1196 | output += "\(indent) category: \(category) \n" 1197 | } 1198 | output += unknownFields.getDescription(indent: indent) 1199 | return output 1200 | } 1201 | override public var hashValue:Int { 1202 | get { 1203 | var hashCode:Int = 7 1204 | if hasAlert { 1205 | hashCode = (hashCode &* 31) &+ alert.hashValue 1206 | } 1207 | if hasSound { 1208 | hashCode = (hashCode &* 31) &+ sound.hashValue 1209 | } 1210 | if hasBadge { 1211 | hashCode = (hashCode &* 31) &+ badge.hashValue 1212 | } 1213 | if hasContentAvailable { 1214 | hashCode = (hashCode &* 31) &+ contentAvailable.hashValue 1215 | } 1216 | if hasMutableContent { 1217 | hashCode = (hashCode &* 31) &+ mutableContent.hashValue 1218 | } 1219 | if hasCategory { 1220 | hashCode = (hashCode &* 31) &+ category.hashValue 1221 | } 1222 | hashCode = (hashCode &* 31) &+ unknownFields.hashValue 1223 | return hashCode 1224 | } 1225 | } 1226 | 1227 | 1228 | //Meta information declaration start 1229 | 1230 | override public class func className() -> String { 1231 | return "Apple.Apns.Push.Aps" 1232 | } 1233 | override public func className() -> String { 1234 | return "Apple.Apns.Push.Aps" 1235 | } 1236 | //Meta information declaration end 1237 | 1238 | final public class Builder : GeneratedMessageBuilder { 1239 | fileprivate var builderResult:Apple.Apns.Push.Aps = Apple.Apns.Push.Aps() 1240 | public func getMessage() -> Apple.Apns.Push.Aps { 1241 | return builderResult 1242 | } 1243 | 1244 | required override public init () { 1245 | super.init() 1246 | } 1247 | public var hasAlert:Bool { 1248 | get { 1249 | return builderResult.hasAlert 1250 | } 1251 | } 1252 | public var alert:String { 1253 | get { 1254 | return builderResult.alert 1255 | } 1256 | set (value) { 1257 | builderResult.hasAlert = true 1258 | builderResult.alert = value 1259 | } 1260 | } 1261 | @discardableResult 1262 | public func setAlert(_ value:String) -> Apple.Apns.Push.Aps.Builder { 1263 | self.alert = value 1264 | return self 1265 | } 1266 | @discardableResult 1267 | public func clearAlert() -> Apple.Apns.Push.Aps.Builder{ 1268 | builderResult.hasAlert = false 1269 | builderResult.alert = "" 1270 | return self 1271 | } 1272 | public var hasSound:Bool { 1273 | get { 1274 | return builderResult.hasSound 1275 | } 1276 | } 1277 | public var sound:String { 1278 | get { 1279 | return builderResult.sound 1280 | } 1281 | set (value) { 1282 | builderResult.hasSound = true 1283 | builderResult.sound = value 1284 | } 1285 | } 1286 | @discardableResult 1287 | public func setSound(_ value:String) -> Apple.Apns.Push.Aps.Builder { 1288 | self.sound = value 1289 | return self 1290 | } 1291 | @discardableResult 1292 | public func clearSound() -> Apple.Apns.Push.Aps.Builder{ 1293 | builderResult.hasSound = false 1294 | builderResult.sound = "" 1295 | return self 1296 | } 1297 | public var hasBadge:Bool { 1298 | get { 1299 | return builderResult.hasBadge 1300 | } 1301 | } 1302 | public var badge:Int32 { 1303 | get { 1304 | return builderResult.badge 1305 | } 1306 | set (value) { 1307 | builderResult.hasBadge = true 1308 | builderResult.badge = value 1309 | } 1310 | } 1311 | @discardableResult 1312 | public func setBadge(_ value:Int32) -> Apple.Apns.Push.Aps.Builder { 1313 | self.badge = value 1314 | return self 1315 | } 1316 | @discardableResult 1317 | public func clearBadge() -> Apple.Apns.Push.Aps.Builder{ 1318 | builderResult.hasBadge = false 1319 | builderResult.badge = Int32(0) 1320 | return self 1321 | } 1322 | public var hasContentAvailable:Bool { 1323 | get { 1324 | return builderResult.hasContentAvailable 1325 | } 1326 | } 1327 | public var contentAvailable:Int32 { 1328 | get { 1329 | return builderResult.contentAvailable 1330 | } 1331 | set (value) { 1332 | builderResult.hasContentAvailable = true 1333 | builderResult.contentAvailable = value 1334 | } 1335 | } 1336 | @discardableResult 1337 | public func setContentAvailable(_ value:Int32) -> Apple.Apns.Push.Aps.Builder { 1338 | self.contentAvailable = value 1339 | return self 1340 | } 1341 | @discardableResult 1342 | public func clearContentAvailable() -> Apple.Apns.Push.Aps.Builder{ 1343 | builderResult.hasContentAvailable = false 1344 | builderResult.contentAvailable = Int32(0) 1345 | return self 1346 | } 1347 | public var hasMutableContent:Bool { 1348 | get { 1349 | return builderResult.hasMutableContent 1350 | } 1351 | } 1352 | public var mutableContent:Int32 { 1353 | get { 1354 | return builderResult.mutableContent 1355 | } 1356 | set (value) { 1357 | builderResult.hasMutableContent = true 1358 | builderResult.mutableContent = value 1359 | } 1360 | } 1361 | @discardableResult 1362 | public func setMutableContent(_ value:Int32) -> Apple.Apns.Push.Aps.Builder { 1363 | self.mutableContent = value 1364 | return self 1365 | } 1366 | @discardableResult 1367 | public func clearMutableContent() -> Apple.Apns.Push.Aps.Builder{ 1368 | builderResult.hasMutableContent = false 1369 | builderResult.mutableContent = Int32(0) 1370 | return self 1371 | } 1372 | public var hasCategory:Bool { 1373 | get { 1374 | return builderResult.hasCategory 1375 | } 1376 | } 1377 | public var category:String { 1378 | get { 1379 | return builderResult.category 1380 | } 1381 | set (value) { 1382 | builderResult.hasCategory = true 1383 | builderResult.category = value 1384 | } 1385 | } 1386 | @discardableResult 1387 | public func setCategory(_ value:String) -> Apple.Apns.Push.Aps.Builder { 1388 | self.category = value 1389 | return self 1390 | } 1391 | @discardableResult 1392 | public func clearCategory() -> Apple.Apns.Push.Aps.Builder{ 1393 | builderResult.hasCategory = false 1394 | builderResult.category = "" 1395 | return self 1396 | } 1397 | override public var internalGetResult:GeneratedMessage { 1398 | get { 1399 | return builderResult 1400 | } 1401 | } 1402 | @discardableResult 1403 | override public func clear() -> Apple.Apns.Push.Aps.Builder { 1404 | builderResult = Apple.Apns.Push.Aps() 1405 | return self 1406 | } 1407 | override public func clone() throws -> Apple.Apns.Push.Aps.Builder { 1408 | return try Apple.Apns.Push.Aps.builderWithPrototype(prototype:builderResult) 1409 | } 1410 | override public func build() throws -> Apple.Apns.Push.Aps { 1411 | try checkInitialized() 1412 | return buildPartial() 1413 | } 1414 | public func buildPartial() -> Apple.Apns.Push.Aps { 1415 | let returnMe:Apple.Apns.Push.Aps = builderResult 1416 | return returnMe 1417 | } 1418 | @discardableResult 1419 | public func mergeFrom(other:Apple.Apns.Push.Aps) throws -> Apple.Apns.Push.Aps.Builder { 1420 | if other == Apple.Apns.Push.Aps() { 1421 | return self 1422 | } 1423 | if other.hasAlert { 1424 | alert = other.alert 1425 | } 1426 | if other.hasSound { 1427 | sound = other.sound 1428 | } 1429 | if other.hasBadge { 1430 | badge = other.badge 1431 | } 1432 | if other.hasContentAvailable { 1433 | contentAvailable = other.contentAvailable 1434 | } 1435 | if other.hasMutableContent { 1436 | mutableContent = other.mutableContent 1437 | } 1438 | if other.hasCategory { 1439 | category = other.category 1440 | } 1441 | try merge(unknownField: other.unknownFields) 1442 | return self 1443 | } 1444 | @discardableResult 1445 | override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.Push.Aps.Builder { 1446 | return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) 1447 | } 1448 | @discardableResult 1449 | override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push.Aps.Builder { 1450 | let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) 1451 | while (true) { 1452 | let protobufTag = try codedInputStream.readTag() 1453 | switch protobufTag { 1454 | case 0: 1455 | self.unknownFields = try unknownFieldsBuilder.build() 1456 | return self 1457 | 1458 | case 10: 1459 | alert = try codedInputStream.readString() 1460 | 1461 | case 18: 1462 | sound = try codedInputStream.readString() 1463 | 1464 | case 24: 1465 | badge = try codedInputStream.readInt32() 1466 | 1467 | case 32: 1468 | contentAvailable = try codedInputStream.readInt32() 1469 | 1470 | case 40: 1471 | mutableContent = try codedInputStream.readInt32() 1472 | 1473 | case 50: 1474 | category = try codedInputStream.readString() 1475 | 1476 | default: 1477 | if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { 1478 | unknownFields = try unknownFieldsBuilder.build() 1479 | return self 1480 | } 1481 | } 1482 | } 1483 | } 1484 | class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Apple.Apns.Push.Aps.Builder { 1485 | let resultDecodedBuilder = Apple.Apns.Push.Aps.Builder() 1486 | if let jsonValueAlert = jsonMap["alert"] as? String { 1487 | resultDecodedBuilder.alert = jsonValueAlert 1488 | } 1489 | if let jsonValueSound = jsonMap["sound"] as? String { 1490 | resultDecodedBuilder.sound = jsonValueSound 1491 | } 1492 | if let jsonValueBadge = jsonMap["badge"] as? Int { 1493 | resultDecodedBuilder.badge = Int32(jsonValueBadge) 1494 | } 1495 | if let jsonValueContentAvailable = jsonMap["contentAvailable"] as? Int { 1496 | resultDecodedBuilder.contentAvailable = Int32(jsonValueContentAvailable) 1497 | } 1498 | if let jsonValueMutableContent = jsonMap["mutableContent"] as? Int { 1499 | resultDecodedBuilder.mutableContent = Int32(jsonValueMutableContent) 1500 | } 1501 | if let jsonValueCategory = jsonMap["category"] as? String { 1502 | resultDecodedBuilder.category = jsonValueCategory 1503 | } 1504 | return resultDecodedBuilder 1505 | } 1506 | override class public func fromJSONToBuilder(data:Data) throws -> Apple.Apns.Push.Aps.Builder { 1507 | let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) 1508 | guard let jsDataCast = jsonData as? Dictionary else { 1509 | throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") 1510 | } 1511 | return try Apple.Apns.Push.Aps.Builder.decodeToBuilder(jsonMap:jsDataCast) 1512 | } 1513 | } 1514 | 1515 | } 1516 | 1517 | //Nested type declaration end 1518 | 1519 | public fileprivate(set) var aps:Apple.Apns.Push.Aps! 1520 | public fileprivate(set) var hasAps:Bool = false 1521 | public fileprivate(set) var image:String = "" 1522 | public fileprivate(set) var hasImage:Bool = false 1523 | 1524 | public fileprivate(set) var video:String = "" 1525 | public fileprivate(set) var hasVideo:Bool = false 1526 | 1527 | public fileprivate(set) var audio:String = "" 1528 | public fileprivate(set) var hasAudio:Bool = false 1529 | 1530 | required public init() { 1531 | super.init() 1532 | } 1533 | override public func isInitialized() -> Bool { 1534 | return true 1535 | } 1536 | override public func writeTo(codedOutputStream: CodedOutputStream) throws { 1537 | if hasAps { 1538 | try codedOutputStream.writeMessage(fieldNumber: 1, value:aps) 1539 | } 1540 | if hasImage { 1541 | try codedOutputStream.writeString(fieldNumber: 2, value:image) 1542 | } 1543 | if hasVideo { 1544 | try codedOutputStream.writeString(fieldNumber: 3, value:video) 1545 | } 1546 | if hasAudio { 1547 | try codedOutputStream.writeString(fieldNumber: 4, value:audio) 1548 | } 1549 | try unknownFields.writeTo(codedOutputStream: codedOutputStream) 1550 | } 1551 | override public func serializedSize() -> Int32 { 1552 | var serialize_size:Int32 = memoizedSerializedSize 1553 | if serialize_size != -1 { 1554 | return serialize_size 1555 | } 1556 | 1557 | serialize_size = 0 1558 | if hasAps { 1559 | if let varSizeaps = aps?.computeMessageSize(fieldNumber: 1) { 1560 | serialize_size += varSizeaps 1561 | } 1562 | } 1563 | if hasImage { 1564 | serialize_size += image.computeStringSize(fieldNumber: 2) 1565 | } 1566 | if hasVideo { 1567 | serialize_size += video.computeStringSize(fieldNumber: 3) 1568 | } 1569 | if hasAudio { 1570 | serialize_size += audio.computeStringSize(fieldNumber: 4) 1571 | } 1572 | serialize_size += unknownFields.serializedSize() 1573 | memoizedSerializedSize = serialize_size 1574 | return serialize_size 1575 | } 1576 | public class func getBuilder() -> Apple.Apns.Push.Builder { 1577 | return Apple.Apns.Push.classBuilder() as! Apple.Apns.Push.Builder 1578 | } 1579 | public func getBuilder() -> Apple.Apns.Push.Builder { 1580 | return classBuilder() as! Apple.Apns.Push.Builder 1581 | } 1582 | override public class func classBuilder() -> ProtocolBuffersMessageBuilder { 1583 | return Apple.Apns.Push.Builder() 1584 | } 1585 | override public func classBuilder() -> ProtocolBuffersMessageBuilder { 1586 | return Apple.Apns.Push.Builder() 1587 | } 1588 | public func toBuilder() throws -> Apple.Apns.Push.Builder { 1589 | return try Apple.Apns.Push.builderWithPrototype(prototype:self) 1590 | } 1591 | public class func builderWithPrototype(prototype:Apple.Apns.Push) throws -> Apple.Apns.Push.Builder { 1592 | return try Apple.Apns.Push.Builder().mergeFrom(other:prototype) 1593 | } 1594 | override public func encode() throws -> Dictionary { 1595 | guard isInitialized() else { 1596 | throw ProtocolBuffersError.invalidProtocolBuffer("Uninitialized Message") 1597 | } 1598 | 1599 | var jsonMap:Dictionary = Dictionary() 1600 | if hasAps { 1601 | jsonMap["aps"] = try aps.encode() 1602 | } 1603 | if hasImage { 1604 | jsonMap["image"] = image 1605 | } 1606 | if hasVideo { 1607 | jsonMap["video"] = video 1608 | } 1609 | if hasAudio { 1610 | jsonMap["audio"] = audio 1611 | } 1612 | return jsonMap 1613 | } 1614 | override class public func decode(jsonMap:Dictionary) throws -> Apple.Apns.Push { 1615 | return try Apple.Apns.Push.Builder.decodeToBuilder(jsonMap:jsonMap).build() 1616 | } 1617 | override class public func fromJSON(data:Data) throws -> Apple.Apns.Push { 1618 | return try Apple.Apns.Push.Builder.fromJSONToBuilder(data:data).build() 1619 | } 1620 | override public func getDescription(indent:String) throws -> String { 1621 | var output = "" 1622 | if hasAps { 1623 | output += "\(indent) aps {\n" 1624 | if let outDescAps = aps { 1625 | output += try outDescAps.getDescription(indent: "\(indent) ") 1626 | } 1627 | output += "\(indent) }\n" 1628 | } 1629 | if hasImage { 1630 | output += "\(indent) image: \(image) \n" 1631 | } 1632 | if hasVideo { 1633 | output += "\(indent) video: \(video) \n" 1634 | } 1635 | if hasAudio { 1636 | output += "\(indent) audio: \(audio) \n" 1637 | } 1638 | output += unknownFields.getDescription(indent: indent) 1639 | return output 1640 | } 1641 | override public var hashValue:Int { 1642 | get { 1643 | var hashCode:Int = 7 1644 | if hasAps { 1645 | if let hashValueaps = aps?.hashValue { 1646 | hashCode = (hashCode &* 31) &+ hashValueaps 1647 | } 1648 | } 1649 | if hasImage { 1650 | hashCode = (hashCode &* 31) &+ image.hashValue 1651 | } 1652 | if hasVideo { 1653 | hashCode = (hashCode &* 31) &+ video.hashValue 1654 | } 1655 | if hasAudio { 1656 | hashCode = (hashCode &* 31) &+ audio.hashValue 1657 | } 1658 | hashCode = (hashCode &* 31) &+ unknownFields.hashValue 1659 | return hashCode 1660 | } 1661 | } 1662 | 1663 | 1664 | //Meta information declaration start 1665 | 1666 | override public class func className() -> String { 1667 | return "Apple.Apns.Push" 1668 | } 1669 | override public func className() -> String { 1670 | return "Apple.Apns.Push" 1671 | } 1672 | //Meta information declaration end 1673 | 1674 | final public class Builder : GeneratedMessageBuilder { 1675 | fileprivate var builderResult:Apple.Apns.Push = Apple.Apns.Push() 1676 | public func getMessage() -> Apple.Apns.Push { 1677 | return builderResult 1678 | } 1679 | 1680 | required override public init () { 1681 | super.init() 1682 | } 1683 | public var hasAps:Bool { 1684 | get { 1685 | return builderResult.hasAps 1686 | } 1687 | } 1688 | public var aps:Apple.Apns.Push.Aps! { 1689 | get { 1690 | if apsBuilder_ != nil { 1691 | builderResult.aps = apsBuilder_.getMessage() 1692 | } 1693 | return builderResult.aps 1694 | } 1695 | set (value) { 1696 | builderResult.hasAps = true 1697 | builderResult.aps = value 1698 | } 1699 | } 1700 | fileprivate var apsBuilder_:Apple.Apns.Push.Aps.Builder! { 1701 | didSet { 1702 | builderResult.hasAps = true 1703 | } 1704 | } 1705 | public func getApsBuilder() -> Apple.Apns.Push.Aps.Builder { 1706 | if apsBuilder_ == nil { 1707 | apsBuilder_ = Apple.Apns.Push.Aps.Builder() 1708 | builderResult.aps = apsBuilder_.getMessage() 1709 | if aps != nil { 1710 | try! apsBuilder_.mergeFrom(other: aps) 1711 | } 1712 | } 1713 | return apsBuilder_ 1714 | } 1715 | @discardableResult 1716 | public func setAps(_ value:Apple.Apns.Push.Aps!) -> Apple.Apns.Push.Builder { 1717 | self.aps = value 1718 | return self 1719 | } 1720 | @discardableResult 1721 | public func mergeAps(value:Apple.Apns.Push.Aps) throws -> Apple.Apns.Push.Builder { 1722 | if builderResult.hasAps { 1723 | builderResult.aps = try Apple.Apns.Push.Aps.builderWithPrototype(prototype:builderResult.aps).mergeFrom(other: value).buildPartial() 1724 | } else { 1725 | builderResult.aps = value 1726 | } 1727 | builderResult.hasAps = true 1728 | return self 1729 | } 1730 | @discardableResult 1731 | public func clearAps() -> Apple.Apns.Push.Builder { 1732 | apsBuilder_ = nil 1733 | builderResult.hasAps = false 1734 | builderResult.aps = nil 1735 | return self 1736 | } 1737 | public var hasImage:Bool { 1738 | get { 1739 | return builderResult.hasImage 1740 | } 1741 | } 1742 | public var image:String { 1743 | get { 1744 | return builderResult.image 1745 | } 1746 | set (value) { 1747 | builderResult.hasImage = true 1748 | builderResult.image = value 1749 | } 1750 | } 1751 | @discardableResult 1752 | public func setImage(_ value:String) -> Apple.Apns.Push.Builder { 1753 | self.image = value 1754 | return self 1755 | } 1756 | @discardableResult 1757 | public func clearImage() -> Apple.Apns.Push.Builder{ 1758 | builderResult.hasImage = false 1759 | builderResult.image = "" 1760 | return self 1761 | } 1762 | public var hasVideo:Bool { 1763 | get { 1764 | return builderResult.hasVideo 1765 | } 1766 | } 1767 | public var video:String { 1768 | get { 1769 | return builderResult.video 1770 | } 1771 | set (value) { 1772 | builderResult.hasVideo = true 1773 | builderResult.video = value 1774 | } 1775 | } 1776 | @discardableResult 1777 | public func setVideo(_ value:String) -> Apple.Apns.Push.Builder { 1778 | self.video = value 1779 | return self 1780 | } 1781 | @discardableResult 1782 | public func clearVideo() -> Apple.Apns.Push.Builder{ 1783 | builderResult.hasVideo = false 1784 | builderResult.video = "" 1785 | return self 1786 | } 1787 | public var hasAudio:Bool { 1788 | get { 1789 | return builderResult.hasAudio 1790 | } 1791 | } 1792 | public var audio:String { 1793 | get { 1794 | return builderResult.audio 1795 | } 1796 | set (value) { 1797 | builderResult.hasAudio = true 1798 | builderResult.audio = value 1799 | } 1800 | } 1801 | @discardableResult 1802 | public func setAudio(_ value:String) -> Apple.Apns.Push.Builder { 1803 | self.audio = value 1804 | return self 1805 | } 1806 | @discardableResult 1807 | public func clearAudio() -> Apple.Apns.Push.Builder{ 1808 | builderResult.hasAudio = false 1809 | builderResult.audio = "" 1810 | return self 1811 | } 1812 | override public var internalGetResult:GeneratedMessage { 1813 | get { 1814 | return builderResult 1815 | } 1816 | } 1817 | @discardableResult 1818 | override public func clear() -> Apple.Apns.Push.Builder { 1819 | builderResult = Apple.Apns.Push() 1820 | return self 1821 | } 1822 | override public func clone() throws -> Apple.Apns.Push.Builder { 1823 | return try Apple.Apns.Push.builderWithPrototype(prototype:builderResult) 1824 | } 1825 | override public func build() throws -> Apple.Apns.Push { 1826 | try checkInitialized() 1827 | return buildPartial() 1828 | } 1829 | public func buildPartial() -> Apple.Apns.Push { 1830 | let returnMe:Apple.Apns.Push = builderResult 1831 | return returnMe 1832 | } 1833 | @discardableResult 1834 | public func mergeFrom(other:Apple.Apns.Push) throws -> Apple.Apns.Push.Builder { 1835 | if other == Apple.Apns.Push() { 1836 | return self 1837 | } 1838 | if (other.hasAps) { 1839 | try mergeAps(value: other.aps) 1840 | } 1841 | if other.hasImage { 1842 | image = other.image 1843 | } 1844 | if other.hasVideo { 1845 | video = other.video 1846 | } 1847 | if other.hasAudio { 1848 | audio = other.audio 1849 | } 1850 | try merge(unknownField: other.unknownFields) 1851 | return self 1852 | } 1853 | @discardableResult 1854 | override public func mergeFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.Push.Builder { 1855 | return try mergeFrom(codedInputStream: codedInputStream, extensionRegistry:ExtensionRegistry()) 1856 | } 1857 | @discardableResult 1858 | override public func mergeFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push.Builder { 1859 | let unknownFieldsBuilder:UnknownFieldSet.Builder = try UnknownFieldSet.builderWithUnknownFields(copyFrom:self.unknownFields) 1860 | while (true) { 1861 | let protobufTag = try codedInputStream.readTag() 1862 | switch protobufTag { 1863 | case 0: 1864 | self.unknownFields = try unknownFieldsBuilder.build() 1865 | return self 1866 | 1867 | case 10: 1868 | let subBuilder:Apple.Apns.Push.Aps.Builder = Apple.Apns.Push.Aps.Builder() 1869 | if hasAps { 1870 | try subBuilder.mergeFrom(other: aps) 1871 | } 1872 | try codedInputStream.readMessage(builder: subBuilder, extensionRegistry:extensionRegistry) 1873 | aps = subBuilder.buildPartial() 1874 | 1875 | case 18: 1876 | image = try codedInputStream.readString() 1877 | 1878 | case 26: 1879 | video = try codedInputStream.readString() 1880 | 1881 | case 34: 1882 | audio = try codedInputStream.readString() 1883 | 1884 | default: 1885 | if (!(try parse(codedInputStream:codedInputStream, unknownFields:unknownFieldsBuilder, extensionRegistry:extensionRegistry, tag:protobufTag))) { 1886 | unknownFields = try unknownFieldsBuilder.build() 1887 | return self 1888 | } 1889 | } 1890 | } 1891 | } 1892 | class override public func decodeToBuilder(jsonMap:Dictionary) throws -> Apple.Apns.Push.Builder { 1893 | let resultDecodedBuilder = Apple.Apns.Push.Builder() 1894 | if let jsonValueAps = jsonMap["aps"] as? Dictionary { 1895 | resultDecodedBuilder.aps = try Apple.Apns.Push.Aps.Builder.decodeToBuilder(jsonMap:jsonValueAps).build() 1896 | 1897 | } 1898 | if let jsonValueImage = jsonMap["image"] as? String { 1899 | resultDecodedBuilder.image = jsonValueImage 1900 | } 1901 | if let jsonValueVideo = jsonMap["video"] as? String { 1902 | resultDecodedBuilder.video = jsonValueVideo 1903 | } 1904 | if let jsonValueAudio = jsonMap["audio"] as? String { 1905 | resultDecodedBuilder.audio = jsonValueAudio 1906 | } 1907 | return resultDecodedBuilder 1908 | } 1909 | override class public func fromJSONToBuilder(data:Data) throws -> Apple.Apns.Push.Builder { 1910 | let jsonData = try JSONSerialization.jsonObject(with:data, options: JSONSerialization.ReadingOptions(rawValue: 0)) 1911 | guard let jsDataCast = jsonData as? Dictionary else { 1912 | throw ProtocolBuffersError.invalidProtocolBuffer("Invalid JSON data") 1913 | } 1914 | return try Apple.Apns.Push.Builder.decodeToBuilder(jsonMap:jsDataCast) 1915 | } 1916 | } 1917 | 1918 | } 1919 | 1920 | } 1921 | extension Apple.Apns.ProviderData: GeneratedMessageProtocol { 1922 | public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { 1923 | var mergedArray = Array() 1924 | while let value = try parseDelimitedFrom(inputStream: inputStream) { 1925 | mergedArray.append(value) 1926 | } 1927 | return mergedArray 1928 | } 1929 | public class func parseDelimitedFrom(inputStream: InputStream) throws -> Apple.Apns.ProviderData? { 1930 | return try Apple.Apns.ProviderData.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() 1931 | } 1932 | public class func parseFrom(data: Data) throws -> Apple.Apns.ProviderData { 1933 | return try Apple.Apns.ProviderData.Builder().mergeFrom(data: data, extensionRegistry:Apple.Apns.PushServiceRoot.default.extensionRegistry).build() 1934 | } 1935 | public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.ProviderData { 1936 | return try Apple.Apns.ProviderData.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() 1937 | } 1938 | public class func parseFrom(inputStream: InputStream) throws -> Apple.Apns.ProviderData { 1939 | return try Apple.Apns.ProviderData.Builder().mergeFrom(inputStream: inputStream).build() 1940 | } 1941 | public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.ProviderData { 1942 | return try Apple.Apns.ProviderData.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() 1943 | } 1944 | public class func parseFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.ProviderData { 1945 | return try Apple.Apns.ProviderData.Builder().mergeFrom(codedInputStream: codedInputStream).build() 1946 | } 1947 | public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.ProviderData { 1948 | return try Apple.Apns.ProviderData.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() 1949 | } 1950 | } 1951 | extension Apple.Apns.Response: GeneratedMessageProtocol { 1952 | public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { 1953 | var mergedArray = Array() 1954 | while let value = try parseDelimitedFrom(inputStream: inputStream) { 1955 | mergedArray.append(value) 1956 | } 1957 | return mergedArray 1958 | } 1959 | public class func parseDelimitedFrom(inputStream: InputStream) throws -> Apple.Apns.Response? { 1960 | return try Apple.Apns.Response.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() 1961 | } 1962 | public class func parseFrom(data: Data) throws -> Apple.Apns.Response { 1963 | return try Apple.Apns.Response.Builder().mergeFrom(data: data, extensionRegistry:Apple.Apns.PushServiceRoot.default.extensionRegistry).build() 1964 | } 1965 | public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Response { 1966 | return try Apple.Apns.Response.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() 1967 | } 1968 | public class func parseFrom(inputStream: InputStream) throws -> Apple.Apns.Response { 1969 | return try Apple.Apns.Response.Builder().mergeFrom(inputStream: inputStream).build() 1970 | } 1971 | public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Response { 1972 | return try Apple.Apns.Response.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() 1973 | } 1974 | public class func parseFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.Response { 1975 | return try Apple.Apns.Response.Builder().mergeFrom(codedInputStream: codedInputStream).build() 1976 | } 1977 | public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Response { 1978 | return try Apple.Apns.Response.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() 1979 | } 1980 | } 1981 | extension Apple.Apns.Push: GeneratedMessageProtocol { 1982 | public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { 1983 | var mergedArray = Array() 1984 | while let value = try parseDelimitedFrom(inputStream: inputStream) { 1985 | mergedArray.append(value) 1986 | } 1987 | return mergedArray 1988 | } 1989 | public class func parseDelimitedFrom(inputStream: InputStream) throws -> Apple.Apns.Push? { 1990 | return try Apple.Apns.Push.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() 1991 | } 1992 | public class func parseFrom(data: Data) throws -> Apple.Apns.Push { 1993 | return try Apple.Apns.Push.Builder().mergeFrom(data: data, extensionRegistry:Apple.Apns.PushServiceRoot.default.extensionRegistry).build() 1994 | } 1995 | public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push { 1996 | return try Apple.Apns.Push.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() 1997 | } 1998 | public class func parseFrom(inputStream: InputStream) throws -> Apple.Apns.Push { 1999 | return try Apple.Apns.Push.Builder().mergeFrom(inputStream: inputStream).build() 2000 | } 2001 | public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push { 2002 | return try Apple.Apns.Push.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() 2003 | } 2004 | public class func parseFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.Push { 2005 | return try Apple.Apns.Push.Builder().mergeFrom(codedInputStream: codedInputStream).build() 2006 | } 2007 | public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push { 2008 | return try Apple.Apns.Push.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() 2009 | } 2010 | } 2011 | extension Apple.Apns.Push.Aps: GeneratedMessageProtocol { 2012 | public class func parseArrayDelimitedFrom(inputStream: InputStream) throws -> Array { 2013 | var mergedArray = Array() 2014 | while let value = try parseDelimitedFrom(inputStream: inputStream) { 2015 | mergedArray.append(value) 2016 | } 2017 | return mergedArray 2018 | } 2019 | public class func parseDelimitedFrom(inputStream: InputStream) throws -> Apple.Apns.Push.Aps? { 2020 | return try Apple.Apns.Push.Aps.Builder().mergeDelimitedFrom(inputStream: inputStream)?.build() 2021 | } 2022 | public class func parseFrom(data: Data) throws -> Apple.Apns.Push.Aps { 2023 | return try Apple.Apns.Push.Aps.Builder().mergeFrom(data: data, extensionRegistry:Apple.Apns.PushServiceRoot.default.extensionRegistry).build() 2024 | } 2025 | public class func parseFrom(data: Data, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push.Aps { 2026 | return try Apple.Apns.Push.Aps.Builder().mergeFrom(data: data, extensionRegistry:extensionRegistry).build() 2027 | } 2028 | public class func parseFrom(inputStream: InputStream) throws -> Apple.Apns.Push.Aps { 2029 | return try Apple.Apns.Push.Aps.Builder().mergeFrom(inputStream: inputStream).build() 2030 | } 2031 | public class func parseFrom(inputStream: InputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push.Aps { 2032 | return try Apple.Apns.Push.Aps.Builder().mergeFrom(inputStream: inputStream, extensionRegistry:extensionRegistry).build() 2033 | } 2034 | public class func parseFrom(codedInputStream: CodedInputStream) throws -> Apple.Apns.Push.Aps { 2035 | return try Apple.Apns.Push.Aps.Builder().mergeFrom(codedInputStream: codedInputStream).build() 2036 | } 2037 | public class func parseFrom(codedInputStream: CodedInputStream, extensionRegistry:ExtensionRegistry) throws -> Apple.Apns.Push.Aps { 2038 | return try Apple.Apns.Push.Aps.Builder().mergeFrom(codedInputStream: codedInputStream, extensionRegistry:extensionRegistry).build() 2039 | } 2040 | } 2041 | 2042 | // @@protoc_insertion_point(global_scope) 2043 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexeyxo/swift-apns/a6bb08dd07ef2d5b82c71cef354dd5bd2a5da108/logo.png -------------------------------------------------------------------------------- /protobuf/PushService.proto: -------------------------------------------------------------------------------- 1 | syntax="proto3"; 2 | package Apple.APNS; 3 | message ProviderData { 4 | enum Identity { 5 | Production = 0; 6 | Development = 1; 7 | } 8 | string bundle = 1; 9 | string token = 2; 10 | uint32 priority = 3; 11 | Push payload = 4; 12 | Identity serviceIdentity = 5; 13 | string certificatePath = 6; 14 | string certificatePassphrase = 7; 15 | } 16 | 17 | message Response { 18 | /* 19 | 200 - Success 20 | 400 - Bad request 21 | 403 - There was an error with the certificate. 22 | 405 - The request used a bad :method value. Only POST requests are supported. 23 | 410 - The device token is no longer active for the topic. 24 | 413 - The notification payload was too large. 25 | 429 - The server received too many requests for the same device token. 26 | 500 - Internal server error 27 | 503 - The server is shutting down and unavailable. 28 | */ 29 | int32 statusCode = 1; 30 | string apns_id = 2; 31 | string reason = 3; 32 | string reasonDescription = 4; 33 | } 34 | 35 | message Push { 36 | message Aps { 37 | string alert = 1; 38 | string sound = 2; 39 | int32 badge = 3; 40 | int32 content_available = 4; 41 | int32 mutable_content = 5; 42 | string category = 6; 43 | } 44 | 45 | Aps aps = 1; 46 | string image = 2; 47 | string video = 3; 48 | string audio = 4; 49 | } 50 | 51 | 52 | --------------------------------------------------------------------------------