Skip to content

Commit

Permalink
Done #6 Close #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Khokhlov committed Jan 7, 2017
1 parent 761313b commit a6bb08d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion APNS.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "APNS"
s.version = "1.2.1"
s.version = "1.2.2"
s.summary = "Swift Framework for sending Apple Push Notification over HTTP/2 API"
s.homepage = "https://github.com/alexeyxo/swift-apns"
s.license = "Apache 2.0"
Expand Down
18 changes: 9 additions & 9 deletions Framework/APNS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
3F270F5E1D943CAE0013D585 /* APNS-Protobuf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F1823371D403C0300022759 /* APNS-Protobuf.swift */; };
3F270F5F1D943CB10013D585 /* Apple.Apns.PushService.proto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F1823381D403C0300022759 /* Apple.Apns.PushService.proto.swift */; };
3F1968811E2107D80005FEA8 /* cert.p12 in Resources */ = {isa = PBXBuildFile; fileRef = 3F1968801E2107D80005FEA8 /* cert.p12 */; };
3F3823431D42292500646806 /* APNSNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FBBC7F31C5CC25100EF69CC /* APNSNetwork.swift */; };
3F388E141C5E1DC20000EDCE /* APNS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3FBBC7E71C5CC20F00EF69CC /* APNS.framework */; };
3F388E221C5E35F20000EDCE /* UnitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F388E111C5E1DC20000EDCE /* UnitTest.swift */; };
3F6A672B1D423F3200432AA1 /* cert.p12 in Resources */ = {isa = PBXBuildFile; fileRef = 3F6A672A1D423F3100432AA1 /* cert.p12 */; };
3FBBC7EB1C5CC20F00EF69CC /* APNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FBBC7EA1C5CC20F00EF69CC /* APNS.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */

Expand All @@ -29,10 +27,10 @@
/* Begin PBXFileReference section */
3F1823371D403C0300022759 /* APNS-Protobuf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "APNS-Protobuf.swift"; path = "../../Source/APNS-Protobuf.swift"; sourceTree = "<group>"; };
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 = "<group>"; };
3F1968801E2107D80005FEA8 /* cert.p12 */ = {isa = PBXFileReference; lastKnownFileType = file; path = cert.p12; sourceTree = SOURCE_ROOT; };
3F388E0F1C5E1DC20000EDCE /* UnitTest.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTest.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3F388E111C5E1DC20000EDCE /* UnitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnitTest.swift; sourceTree = "<group>"; };
3F388E131C5E1DC20000EDCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3F6A672A1D423F3100432AA1 /* cert.p12 */ = {isa = PBXFileReference; lastKnownFileType = file; path = cert.p12; sourceTree = "<group>"; };
3FBBC7E71C5CC20F00EF69CC /* APNS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = APNS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3FBBC7EA1C5CC20F00EF69CC /* APNS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APNS.h; sourceTree = "<group>"; };
3FBBC7EC1C5CC20F00EF69CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -61,8 +59,8 @@
3F388E101C5E1DC20000EDCE /* UnitTest */ = {
isa = PBXGroup;
children = (
3F1968801E2107D80005FEA8 /* cert.p12 */,
3F388E111C5E1DC20000EDCE /* UnitTest.swift */,
3F6A672A1D423F3100432AA1 /* cert.p12 */,
3F388E131C5E1DC20000EDCE /* Info.plist */,
);
path = UnitTest;
Expand Down Expand Up @@ -155,7 +153,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Alexey Khokhlov";
TargetAttributes = {
3F388E0E1C5E1DC20000EDCE = {
Expand Down Expand Up @@ -191,7 +189,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3F6A672B1D423F3200432AA1 /* cert.p12 in Resources */,
3F1968811E2107D80005FEA8 /* cert.p12 in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -217,8 +215,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3F270F5F1D943CB10013D585 /* Apple.Apns.PushService.proto.swift in Sources */,
3F270F5E1D943CAE0013D585 /* APNS-Protobuf.swift in Sources */,
3F3823431D42292500646806 /* APNSNetwork.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -272,8 +268,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand Down Expand Up @@ -319,8 +317,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
9 changes: 4 additions & 5 deletions Framework/UnitTest/UnitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ class UnitTest: XCTestCase {
let aps = ["sound":"default", "alert":"testPush()"]
let payload = ["aps":aps]
let str = Bundle(for:UnitTest.self).path(forResource: "cert", ofType: "p12")!
// ApplePushMessage(topic: <#T##String#>, priority: <#T##Int#>, payload: <#T##Dictionary<String, AnyObject>#>, deviceToken: <#T##String#>, certificatePath: <#T##String#>, passphrase: <#T##String#>)
var mess = ApplePushMessage(topic: "com.advisa.voipservice",
var mess = ApplePushMessage(topic: "com.123.123",
priority: 10,
payload: payload,
deviceToken: "3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe",
deviceToken: "e86ba7b98a8bbc2725481caed7c2b2d906dae1f11339bb11a6918095d6d14933",
certificatePath:str,
passphrase: "123456")

Expand Down Expand Up @@ -93,10 +92,10 @@ class UnitTest: XCTestCase {
let aps = ["sound":"default", "alert":"testPush()"]
let payload = ["aps":aps]
let str = Bundle(for:UnitTest.self).path(forResource: "cert", ofType: "p12")!
var mess = ApplePushMessage(topic: "com.advisa.voipservice",
var mess = ApplePushMessage(topic: "com.123.123",
priority: 10,
payload: payload,
deviceToken: "3dd55a590564asdasd41ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe",
deviceToken: "e86ba7b98a8bbc27254ddd81caed7c2b2d906dae1f11339bb11a6918095d6d14933",
certificatePath:str,
passphrase: "123456")

Expand Down
11 changes: 8 additions & 3 deletions Source/APNSNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ open class APNSNetwork:NSObject {
public init(session:URLSession?) {
super.init()
guard let session = session else {
APNSNetwork.session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: OperationQueue.main)
let session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: OperationQueue.main)
APNSNetwork.session = session
return
}
APNSNetwork.session = session
Expand Down Expand Up @@ -247,10 +248,14 @@ open class APNSNetwork:NSObject {
return task

}

}

extension APNSNetwork: URLSessionDelegate {
public func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: (Foundation.URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
extension APNSNetwork: URLSessionDelegate, URLSessionTaskDelegate {
public func urlSession(_ session: URLSession,
task: URLSessionTask,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {

var cert : SecCertificate?
SecIdentityCopyCertificate(self.secIdentity!, &cert)
Expand Down
8 changes: 4 additions & 4 deletions Source/Apple.Apns.PushService.proto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public extension Apple.Apns {
}
}
}
class public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.ProviderData.Builder {
class override public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.ProviderData.Builder {
let resultDecodedBuilder = Apple.Apns.ProviderData.Builder()
if let jsonValueBundle = jsonMap["bundle"] as? String {
resultDecodedBuilder.bundle = jsonValueBundle
Expand Down Expand Up @@ -988,7 +988,7 @@ public extension Apple.Apns {
}
}
}
class public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.Response.Builder {
class override public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.Response.Builder {
let resultDecodedBuilder = Apple.Apns.Response.Builder()
if let jsonValueStatusCode = jsonMap["statusCode"] as? Int {
resultDecodedBuilder.statusCode = Int32(jsonValueStatusCode)
Expand Down Expand Up @@ -1481,7 +1481,7 @@ public extension Apple.Apns {
}
}
}
class public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.Push.Aps.Builder {
class override public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.Push.Aps.Builder {
let resultDecodedBuilder = Apple.Apns.Push.Aps.Builder()
if let jsonValueAlert = jsonMap["alert"] as? String {
resultDecodedBuilder.alert = jsonValueAlert
Expand Down Expand Up @@ -1889,7 +1889,7 @@ public extension Apple.Apns {
}
}
}
class public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.Push.Builder {
class override public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Apple.Apns.Push.Builder {
let resultDecodedBuilder = Apple.Apns.Push.Builder()
if let jsonValueAps = jsonMap["aps"] as? Dictionary<String,Any> {
resultDecodedBuilder.aps = try Apple.Apns.Push.Aps.Builder.decodeToBuilder(jsonMap:jsonValueAps).build()
Expand Down

0 comments on commit a6bb08d

Please sign in to comment.