diff --git a/Example/index.html b/Example/index.html index a65001c5..e8b7ca9e 100644 --- a/Example/index.html +++ b/Example/index.html @@ -34,6 +34,10 @@ console.log("onPushReceived: " + JSON.stringify(event)) }) + Airship.push.onBackgroundPushReceived(function(event) { + console.log("onBackgroundPushReceived: " + JSON.stringify(event)) + }) + Airship.push.onNotificationResponse(function(event) { console.log("onNotificationResponse: " + JSON.stringify(event)) }) diff --git a/cordova-airship/types/index.d.ts b/cordova-airship/types/index.d.ts index 74a39ae1..be31b5e8 100644 --- a/cordova-airship/types/index.d.ts +++ b/cordova-airship/types/index.d.ts @@ -1082,6 +1082,16 @@ export interface AirshipPush { callback: (event: PushReceivedEvent) => void ): Cancellable + /** + * Background push received listener. + * + * @param callback The callback. + * @return A cancellable that can be used to cancel the listener. + */ + onBackgroundPushReceived( + callback: (event: PushReceivedEvent) => void + ): Cancellable + /** * Notification response listener. * diff --git a/cordova-airship/www/Airship.js b/cordova-airship/www/Airship.js index 7ff42640..76895a82 100644 --- a/cordova-airship/www/Airship.js +++ b/cordova-airship/www/Airship.js @@ -377,6 +377,11 @@ airship.push.onPushReceived = function (callback) { return registerListener("airship.event.push_received", callback) } +airship.push.onBackgroundPushReceived = function (callback) { + argscheck.checkArgs('F', 'Airship.push.onBackgroundPushReceived', arguments) + return registerListener("airship.event.background_push_received", callback) +} + airship.push.onNotificationResponse = function (callback) { argscheck.checkArgs('F', 'Airship.push.onNotificationResponse', arguments) return registerListener("airship.event.notification_response", callback)