Commit 671bd58b authored by Simon MacDonald's avatar Simon MacDonald
Browse files

Add unregister event

parent 8dc487ff
Loading
Loading
Loading
Loading
+10 −0
Changes for README.md: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -122,6 +122,16 @@ push.on('error', function(e) {
});
```

### push.unregister(successHandler, errorHandler)

The unregister method is used when the application no longer wants to receive push notifications.

#### Example

```javascript
push.unregister(successHandler, errorHandler);
```

## Native Requirements

- There should be no dependency on any other plugins.
+1 −0
Changes for src/ios/PushPlugin.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
@property BOOL                          isInline;

- (void)init:(CDVInvokedUrlCommand*)command;
- (void)unregister:(CDVInvokedUrlCommand*)command;

- (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
- (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error;
+20 −0
Changes for www/push.js: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -50,6 +50,26 @@ var PushNotification = function(options) {
    }, 10);
};

/**
 * Unregister from push notifications
 */

PushNotification.prototype.unregister = function(successCallback, errorCallback, options) {
    if (errorCallback == null) { errorCallback = function() {}}

    if (typeof errorCallback != "function")  {
        console.log("PushNotification.unregister failure: failure parameter not a function");
        return
    }

    if (typeof successCallback != "function") {
        console.log("PushNotification.unregister failure: success callback parameter must be a function");
        return
    }

    exec(successCallback, errorCallback, "PushNotification", "unregister", [options]);
};

/**
 * Listen for an event.
 *