Skip to content

Commit de8d95f

Browse files
committed
Corrected & cleaned up NotificationPusher comments.
Former-commit-id: 4b93a7f
1 parent 325a30d commit de8d95f

File tree

1 file changed

+7
-54
lines changed

1 file changed

+7
-54
lines changed

PerfectLib/NotificationPusher.swift

+7-54
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ let deviceId = "hex string device id"
5353
let ary = [IOSNotificationItem.AlertBody("This is the message"), IOSNotificationItem.Sound("default")]
5454
let n = NotificationPusher()
5555

56+
n.apnsTopic = "com.company.my-app"
57+
5658
n.pushIOS(configurationName, deviceToken: deviceId, expiration: 0, priority: 10, notificationItems: ary) {
5759
response in
5860

@@ -148,7 +150,7 @@ public class NotificationPusher {
148150
/// Toggle development or production on a global basis.
149151
public static var development = false
150152

151-
/// apns-topic
153+
/// Sets the apns-topic which will be used for iOS notifications.
152154
public var apnsTopic: String?
153155

154156
var responses = [NotificationResponse]()
@@ -247,6 +249,8 @@ public class NotificationPusher {
247249

248250
}
249251

252+
/// Initialize given iOS apns-topic string.
253+
/// This can be set after initialization on the X.apnsTopic property.
250254
public init(apnsTopic: String) {
251255
self.apnsTopic = apnsTopic
252256
}
@@ -282,7 +286,8 @@ public class NotificationPusher {
282286
}
283287
}
284288
}
285-
/// Push multiple messages to one device.
289+
290+
/// Push one message to multiple devices.
286291
/// Provide the previously set configuration name, and zero or more device tokens. The same message will be sent to each device.
287292
/// Provide the expiration and priority as described here:
288293
/// https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html
@@ -357,58 +362,6 @@ public class NotificationPusher {
357362
self.pushIOS(client, deviceTokens: g, expiration: expiration, priority: priority, notificationJson: jsond, callback: callback)
358363
}
359364

360-
/// Push multiple messages to one device.
361-
/// Provide the previously set configuration name, and zero or more device tokens. The same message will be sent to each device.
362-
/// Provide the expiration and priority as described here:
363-
/// https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html
364-
/// Provide a list of IOSNotificationItems.
365-
/// Provide a callback with which to receive any errors which may have occurred.
366-
/// nil is passed to the callback if the push was successful.
367-
/* public func pushIOS(configurationName: String, deviceTokens: [String], expiration: UInt32, priority: UInt8, notificationItems: [IOSNotificationItem], callback: (errorMessage: String?) -> ()) {
368-
369-
do {
370-
let jsond = try self.itemsToPayloadString(notificationItems)
371-
372-
NotificationPusher.getStreamIOS(configurationName) {
373-
n in
374-
375-
if let net = n {
376-
377-
let request = net.createRequest()
378-
request.setRequestMethod("POST")
379-
request.postBodyBytes = UTF8Encoding.decode(jsond)
380-
request.headers["content-type"] = "application/json; charset=utf-8"
381-
request.headers["apns-expiration"] = "\(expiration)"
382-
request.headers["apns-priority"] = "\(priority)"
383-
request.headers["apns-topic"] = "ca.treefrog.Smirkee"
384-
request.setRequestURI("/3/device/\(deviceToken)")
385-
net.sendRequest(request) {
386-
response, msg in
387-
388-
NotificationPusher.releaseStreamIOS(configurationName, net: net)
389-
390-
if let r = response {
391-
let code = r.getStatus().0
392-
if code != 200 {
393-
callback(errorMessage: "Response code \(code)")
394-
} else {
395-
callback(errorMessage: nil)
396-
}
397-
} else {
398-
callback(errorMessage: msg)
399-
}
400-
}
401-
402-
} else {
403-
callback(errorMessage: "No stream")
404-
}
405-
}
406-
407-
} catch let e {
408-
callback(errorMessage: "\(e)")
409-
}
410-
}
411-
*/
412365
func itemsToPayloadString(notificationItems: [IOSNotificationItem]) -> String {
413366
var dict = [String:Any]()
414367
var aps = [String:Any]()

0 commit comments

Comments
 (0)