Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Vandriel committed Nov 9, 2014
1 parent 03ed94c commit db26eef
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Classes/NWHub.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/** Helper on top of `NWPusher` that hides the details of pushing and reading.
This class provides a more convenient way of pushing notifications to the APNS server. It deals with the trouble of assigning a unique identifier to every notification and the handling of error responses from the server. It hides the latency that comes with transmitting the pushes, allowing you to simply push your notifications and getting notified of errors through the delegate. If this feels over-abstracted, then definitely check out the `NWPusher` class, which will give you full control.
This class provides a more convenient way of pushing notifications to the APNs. It deals with the trouble of assigning a unique identifier to every notification and the handling of error responses from the server. It hides the latency that comes with transmitting the pushes, allowing you to simply push your notifications and getting notified of errors through the delegate. If this feels over-abstracted, then definitely check out the `NWPusher` class, which will give you full control.
There are two set of methods for pushing notifications: the easy and the pros. The former will just do the pushing and reconnect if the connection breaks. This is your low-worry solution, provided that you call `readFailed` every so often (seconds) to handle error data from the server. The latter will give you a little more control and a little more responsibility.
*/
Expand Down Expand Up @@ -121,7 +121,7 @@

/** Read the response from the server and reconnect if anything failed.
If the APNS server finds something wrong with a notification, it will write back the identifier and error code. As this involves transmission to and from the server, it takes just a little while to get this failure info. This method should therefore be invoked a little (say a second) after pushing to see if anything was wrong. On a slow connection this might take longer than the interval between push messages, in which case the reported notification was *not* the last one sent.
If the APNs finds something wrong with a notification, it will write back the identifier and error code. As this involves transmission to and from the server, it takes just a little while to get this failure info. This method should therefore be invoked a little (say a second) after pushing to see if anything was wrong. On a slow connection this might take longer than the interval between push messages, in which case the reported notification was *not* the last one sent.
From the server we only get the notification identifier and the error message. This method translates this back into the original notification by keeping track of all notifications sent in the past 30 seconds. If somehow the original notification cannot be found, it will assign `NSNull`.
Expand Down
4 changes: 2 additions & 2 deletions Classes/NWPushFeedback.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

@class NWSSLConnection;

/** Reads tokens and dates from the APNS Feedback Service.
/** Reads tokens and dates from the APNs feedback service.
The Feedback Service is a separate server that provides a list of all device tokens that it tried to deliver a notification to, but was unable to. This usually indicates that this device no longer has the app installed. This way, the Feedback Service provides reliable way of finding out who uninstalled the app, which can be fed back into your database.
The feedback service is a separate server that provides a list of all device tokens that it tried to deliver a notification to, but was unable to. This usually indicates that this device no longer has the app installed. This way, the feedback service provides reliable way of finding out who uninstalled the app, which can be fed back into your database.
Apple recommends reading from the service once a day. After a device token has been read, it will not be returned again until the next failed delivery. In practice: connect once a day, read all device tokens, and update your own database accordingly.
Expand Down
8 changes: 4 additions & 4 deletions Classes/NWPusher.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

@class NWNotification, NWSSLConnection;

/** Serializes notification objects and pushes them to the APNS.
/** Serializes notification objects and pushes them to the APNs.
This is the heart of the framework. As the (inconvenient) name suggest, it's also one of the first classes that was added to the framework. This class provides a straightforward interface to the APNS server, including connecting, pushing to and reading from the server.
This is the heart of the framework. As the (inconvenient) name suggest, it's also one of the first classes that was added to the framework. This class provides a straightforward interface to the APNs, including connecting, pushing to and reading from the server.
Connecting is done based on an identity or PKCS #12 data. The identity is an instance of `SecIdentityRef` and contains a certificate and private key. The PKCS #12 data can be deserialized into such an identity. One can reconnect or disconnect at any time, and should if the connection has been dropped by the server. The latter can happen quite easily, for example when there is something wrong with the device token or payload of the notification.
Expand All @@ -39,10 +39,10 @@

/** @name Connecting */

/** Connect with the APNS server using the identity. */
/** Connect with the APNs using the identity. */
- (BOOL)connectWithIdentity:(NWIdentityRef)identity error:(NSError **)error;

/** Connect with the APNS server using the identity from PKCS #12 data. */
/** Connect with the APNs using the identity from PKCS #12 data. */
- (BOOL)connectWithPKCS12Data:(NSData *)data password:(NSString *)password error:(NSError **)error;

/** Reconnect using the same identity, disconnects if necessary. */
Expand Down
2 changes: 1 addition & 1 deletion Classes/NWSSLConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>


/** An SSL (TLS) connection to the APNS server.
/** An SSL (TLS) connection to the APNs.
This class is basically an Objective-C wrapper around `SSLContextRef` and `SSLConnectionRef`, which are part of the native Secure Transport framework. This class provides a generic interface for SSL (TLS) connections, independent of NWPusher.
Expand Down
2 changes: 1 addition & 1 deletion Classes/NWSecTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/** Tells if the certificate is for pushing to the Development (sandbox) server. */
+ (BOOL)isSandboxCertificate:(NWCertificateRef)certificate;

/** Tells if the certificate can be used for connecting with APNS. */
/** Tells if the certificate can be used for connecting with APNs. */
+ (BOOL)isPushCertificate:(NWCertificateRef)certificate;

/** Composes a dictionary describing the characteristics of the identity. */
Expand Down
8 changes: 4 additions & 4 deletions Classes/NWType.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

#import <Foundation/Foundation.h>

/** The current and past data formats supported by APNS. */
/** The current and past data formats supported by APNs. For more information see Apple documentation under 'Legacy Information'. */
typedef NS_ENUM(NSInteger, NWNotificationType) {
/** The oldest format, simply concatenates the device token and payload. */
/** The 'Simple Notification Format'. The oldest format, simply concatenates the device token and payload. */
kNWNotificationType0 = 0,
/** Similar to the previous format, but includes and identifier and expiration date. */
/** The 'Enhanced Notification Format'. Similar to the previous format, but includes and identifier and expiration date. */
kNWNotificationType1 = 1,
/** A new, more extensible format that allows for attributes like priority. */
/** The 'Binary Interface and Notification Format'. The latest, more extensible format that allows for attributes like priority. */
kNWNotificationType2 = 2,
};

Expand Down
2 changes: 1 addition & 1 deletion NWPusher.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'NWPusher'
s.version = '0.6.0'
s.summary = 'OS X and iOS application and framework to play with the Apple Push Notification Service (APNS).'
s.summary = 'OS X and iOS application and framework to play with the Apple Push Notification service (APNs).'
s.homepage = 'https://github.com/noodlewerk/NWPusher'
s.license = { :type => 'BSD', :file => 'LICENSE.txt' }
s.author = { 'Leonard van Driel' => '[email protected]' }
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Pusher
======

*OS X and iOS application and framework to play with the Apple Push Notification Service (APNS)*
*OS X and iOS application and framework to play with the Apple Push Notification service (APNs)*

<img src="Docs/osx1.png" alt="Pusher OS X" width="612"/>

Expand Down Expand Up @@ -48,7 +48,7 @@ Mac OS X application for sending push notifications through the APN service:
- *Stores device tokens* so you don't have to copy-paste them every time
- Handles *PKCS #12* files (.p12)
- Automatic configuration for *sandbox*
- Reports *detailed error messages* returned by APNS
- Reports *detailed error messages* returned by APNs
- Reads from *feedback service*

OS X and iOS framework for sending pushes from your own application:
Expand Down Expand Up @@ -84,7 +84,7 @@ The push certificate should be exported to a PKCS12 file, which allows you to sh
<img src="Docs/keychain2.png" alt="PKCS12 file" width="690"/>

### Device token
Now you need to obtain a device token, which is a 64 character hex string (256 bits indeed). This should be done from within the iOS app you're going to push to. Add the following lines to the application delegate (Xcode 6 required):
Now you need to obtain a device token, which is a 64 character hex string (256 bits). This should be done from within the iOS app you're going to push to. Add the following lines to the application delegate (Xcode 6 required):

```objective-c
- (BOOL)application:(UIApplication *)application
Expand Down Expand Up @@ -172,7 +172,7 @@ If everything is set up correctly, you only need to *Connect* and *Push*. Then y

Again, if things are not working as expected, take a look at the *Troubleshooting* section below or post an issue on GitHub.

Consult Apple's documentation for more info on the APNS architecture: [Apple Push Notification Service](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html)
Consult Apple's documentation for more info on the APNs architecture: [Apple Push Notification Service](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html)

Pushing from code
-----------------
Expand All @@ -196,7 +196,7 @@ To create a connection directly from a PKCS12 (.p12) file:
NSError *error = nil;
NWPusher *pusher = [NWPusher connectWithPKCS12Data:pkcs12 password:@"pa$$word" error:&error];
if (pusher) {
NSLog(@"Connected to APNS");
NSLog(@"Connected to APNs");
} else {
NSLog(@"Unable to connect: %@", error);
}
Expand All @@ -210,7 +210,7 @@ When pusher is successfully connected, send a payload to your device:
NSError *error = nil;
BOOL pushed = [pusher pushPayload:payload token:token identifier:rand() error:&error];
if (pushed) {
NSLog(@"Pushed to APNS");
NSLog(@"Pushed to APNs");
} else {
NSLog(@"Unable to push: %@", error);
}
Expand Down Expand Up @@ -262,7 +262,7 @@ Consult Apple's documentation for more info on the client-server communication:
Feedback Service
----------------
The feedback service is part of the Apple Push Notification Service. The feedback service is basically a list containing device tokens that became invalid. Apple recommends that you read from the feedback service once every 24 hours, and no longer send notifications to listed devices. Note that this can be used to find out who removed your app from their device.
The feedback service is part of the Apple Push Notification service. The feedback service is basically a list containing device tokens that became invalid. Apple recommends that you read from the feedback service once every 24 hours, and no longer send notifications to listed devices. Note that this can be used to find out who removed your app from their device.
Communication with the feedback service can be done with the `NWPushFeedback` class. First connect using one of the `connect` methods:
Expand Down

0 comments on commit db26eef

Please sign in to comment.