@@ -29,15 +29,22 @@ function ensureCallback() {
2929 }
3030
3131 public onError ( error : any ) : void { }
32+
3233 public onSuccess ( message : string ) : void {
3334 const callback = this . _owner ?. get ?.( ) ?. [ this . _propName ] ;
3435 if ( typeof callback === 'function' ) {
3536 if ( this . _propName === '_onToken' ) {
3637 callback ( message ) ;
38+ } else if ( this . _propName === '_onNotificationTap' || this . _propName === '_onMessage' ) {
39+ try {
40+ setTimeout ( ( ) => {
41+ callback ( JSON . parse ( message ) ) ;
42+ } ) ;
43+ } catch ( e ) { }
3744 } else {
3845 try {
3946 callback ( JSON . parse ( message ) ) ;
40- } catch ( e ) { }
47+ } catch ( e ) { }
4148 }
4249 }
4350 }
@@ -58,6 +65,7 @@ export class Messaging implements IMessaging {
5865 #onTokenCallback?;
5966 #onToken?: ( token : string ) => void ;
6067
68+ showNotificationsWhenInForeground : boolean ;
6169
6270 constructor ( ) {
6371 if ( defaultMessaging ) {
@@ -67,10 +75,8 @@ export class Messaging implements IMessaging {
6775 org . nativescript . firebase . messaging . FirebaseMessaging . init ( Utils . android . getApplicationContext ( ) ) ;
6876 this . #native = com . google . firebase . messaging . FirebaseMessaging . getInstance ( ) ;
6977 ensureCallback ( ) ;
70- Application . android . on ( AndroidApplication . activityNewIntentEvent , this . _newIntentCallback ) ;
78+ Application . android . on ( AndroidApplication . activityNewIntentEvent , this . _newIntentCallback . bind ( this ) ) ;
7179 }
72- showNotificationsWhenInForeground : boolean ;
73-
7480
7581 _newIntentCallback ( args : AndroidActivityNewIntentEventData ) {
7682 org . nativescript . firebase . messaging . FirebaseMessaging . handleActivityIntent ( args . intent ) ;
@@ -92,7 +98,6 @@ export class Messaging implements IMessaging {
9298 return this . #onNotificationTapCallback;
9399 }
94100
95-
96101 get _onToken ( ) {
97102 return this . #onToken;
98103 }
@@ -117,7 +122,7 @@ export class Messaging implements IMessaging {
117122 } ) ;
118123 }
119124
120- getAPNSToken ( ) {
125+ getAPNSToken ( ) {
121126 return null ;
122127 }
123128
@@ -249,4 +254,4 @@ export class Messaging implements IMessaging {
249254 get android ( ) {
250255 return this . native ;
251256 }
252- }
257+ }
0 commit comments