lib/push/cordova.js
function listenPushNotification(callback) {
    if (callback === void 0) { callback = defaultPushCallback; }
    if (resolveRegistrationEventResponse) {
        diag.debug.assert(!!rejectRegistrationEventResponse);
        resolveRegistrationEventResponse(undefined);
        resolveRegistrationEventResponse = undefined;
        rejectRegistrationEventResponse = undefined;
    }
    if (callback) {
        // perform registration
        promiseRegistrationEventResponse = device.ready.then(function (info) {
            var pushInitOptions = init.initOptions.push;
            var pushPlatform = info.platform.id;
            if (pushPlatform === 'windowsphone') {
                pushPlatform = 'windows';
            }
            if (!pushInitOptions || !pushPlatform || !(pushPlatform in pushInitOptions)) {
                // no push configuration for current platform
                promiseRegistrationEventResponse = Q.resolve(undefined);
                return promiseRegistrationEventResponse;
            }
            // init or reinit push
            var pushStatic = global['PushNotification'];
            var pushImpl = pushStatic.init(pushInitOptions);
            if (pushPlugin !== pushImpl) {
                if (pushPlugin) {
                    // turn off existing event handlers (in reverse order of registration)
                    pushPlugin.off('notification', onPushNotificationNotification);
                    pushPlugin.off('registration', onPushNotificationRegistration);
                    pushPlugin.off('error', onPushNotificationError);
                }
                // set up new registration results
                promiseRegistrationEventResponse = Q.Promise(function (resolve, reject) {
                    resolveRegistrationEventResponse = resolve;
                    rejectRegistrationEventResponse = reject;
                });
                // activation of new implementation
                pushCallback = callback;
                pushPlugin = pushImpl;
                // turn on event handlers (in order of relevance)
                pushPlugin.on('error', onPushNotificationError);
                pushPlugin.on('registration', onPushNotificationRegistration);
                pushPlugin.on('notification', onPushNotificationNotification);
            }
            return promiseRegistrationEventResponse;
        });
    }
    else if (pushPlugin) {
        // perform unregistration
        promiseRegistrationEventResponse = Q.Promise(function (resolve, reject) {
            try {
                pushPlugin.unregister(resolve, reject);
            }
            catch (error) {
                reject(error);
            }
        });
    }
    else {
        // nothing to unregister
        promiseRegistrationEventResponse = Q.resolve(undefined);
    }
    return promiseRegistrationEventResponse;
}
function listenPushNotification(callback) {
    if (callback === void 0) { callback = defaultPushCallback; }
    if (resolveRegistrationEventResponse) {
        diag.debug.assert(!!rejectRegistrationEventResponse);
        resolveRegistrationEventResponse(undefined);
        resolveRegistrationEventResponse = undefined;
        rejectRegistrationEventResponse = undefined;
    }
    if (callback) {
        // perform registration
        promiseRegistrationEventResponse = device.ready.then(function (info) {
            var pushInitOptions = init.initOptions.push;
            var pushPlatform = info.platform.id;
            if (pushPlatform === 'windowsphone') {
                pushPlatform = 'windows';
            }
            if (!pushInitOptions || !pushPlatform || !(pushPlatform in pushInitOptions)) {
                // no push configuration for current platform
                promiseRegistrationEventResponse = Q.resolve(undefined);
                return promiseRegistrationEventResponse;
            }
            // init or reinit push
            var pushStatic = global['PushNotification'];
            var pushImpl = pushStatic.init(pushInitOptions);
            if (pushPlugin !== pushImpl) {
                if (pushPlugin) {
                    // turn off existing event handlers (in reverse order of registration)
                    pushPlugin.off('notification', onPushNotificationNotification);
                    pushPlugin.off('registration', onPushNotificationRegistration);
                    pushPlugin.off('error', onPushNotificationError);
                }
                // set up new registration results
                promiseRegistrationEventResponse = Q.Promise(function (resolve, reject) {
                    resolveRegistrationEventResponse = resolve;
                    rejectRegistrationEventResponse = reject;
                });
                // activation of new implementation
                pushCallback = callback;
                pushPlugin = pushImpl;
                // turn on event handlers (in order of relevance)
                pushPlugin.on('error', onPushNotificationError);
                pushPlugin.on('registration', onPushNotificationRegistration);
                pushPlugin.on('notification', onPushNotificationNotification);
            }
            return promiseRegistrationEventResponse;
        });
    }
    else if (pushPlugin) {
        // perform unregistration
        promiseRegistrationEventResponse = Q.Promise(function (resolve, reject) {
            try {
                pushPlugin.unregister(resolve, reject);
            }
            catch (error) {
                reject(error);
            }
        });
    }
    else {
        // nothing to unregister
        promiseRegistrationEventResponse = Q.resolve(undefined);
    }
    return promiseRegistrationEventResponse;
}
function listenPushNotification ( callback ) { if ( callback === void 0 ) { callback = defaultPushCallback ; } if ( resolveRegistrationEventResponse ) { diag . debug . assert ( ! ! rejectRegistrationEventResponse ) ; resolveRegistrationEventResponse ( undefined ) ; resolveRegistrationEventResponse = undefined ; rejectRegistrationEventResponse = undefined ; } if ( callback ) { // perform registration promiseRegistrationEventResponse = device . ready . then ( function ( info ) { var pushInitOptions = init . initOptions . push ; var pushPlatform = info . platform . id ; if ( pushPlatform === 'windowsphone' ) { pushPlatform = 'windows' ; } if ( ! pushInitOptions || ! pushPlatform || ! ( pushPlatform in pushInitOptions ) ) { // no push configuration for current platform promiseRegistrationEventResponse = Q . resolve ( undefined ) ; return promiseRegistrationEventResponse ; } // init or reinit push var pushStatic = global [ 'PushNotification' ] ; var pushImpl = pushStatic . init ( pushInitOptions ) ; if ( pushPlugin !== pushImpl ) { if ( pushPlugin ) { // turn off existing event handlers (in reverse order of registration) pushPlugin . off ( 'notification' , onPushNotificationNotification ) ; pushPlugin . off ( 'registration' , onPushNotificationRegistration ) ; pushPlugin . off ( 'error' , onPushNotificationError ) ; } // set up new registration results promiseRegistrationEventResponse = Q . Promise ( function ( resolve , reject ) { resolveRegistrationEventResponse = resolve ; rejectRegistrationEventResponse = reject ; } ) ; // activation of new implementation pushCallback = callback ; pushPlugin = pushImpl ; // turn on event handlers (in order of relevance) pushPlugin . on ( 'error' , onPushNotificationError ) ; pushPlugin . on ( 'registration' , onPushNotificationRegistration ) ; pushPlugin . on ( 'notification' , onPushNotificationNotification ) ; } return promiseRegistrationEventResponse ; } ) ; } else if ( pushPlugin ) { // perform unregistration promiseRegistrationEventResponse = Q . Promise ( function ( resolve , reject ) { try { pushPlugin . unregister ( resolve , reject ) ; } catch ( error ) { reject ( error ) ; } } ) ; } else { // nothing to unregister promiseRegistrationEventResponse = Q . resolve ( undefined ) ; } return promiseRegistrationEventResponse ; }
installs a callback for receiving push notification messages, and registers the device with the
3rd party push service provider.

Usually push configuration is provided to `init()` and a call to this method is chained passing
the sink callback. Application using an explicit login then call `configurePushDevice()` as part
of the `LogonCallback` while anonymous applications call the latter directly.

In general it is not wise to unregister from push messages. However, this functionality is
available by passing `null` as callback.

@param callback to install, or explicitly null to unregister.
@return promise of registration, for informal purposes.
installs a callback for receiving push notification messages and registers the device with the 3rd party push service provider .