@@ -4,7 +4,7 @@ import { AuthorizationStatus, IMessaging, Permissions, Notification, RemoteMessa
44
55export { AuthorizationStatus } from './common' ;
66
7- declare const FIRApp , TNSFirebaseMessaging , FIRAuth , TNSUIApplicationDelegate ;
7+ declare const FIRApp , TNSFirebaseMessaging , TNSFirebaseCore ;
88
99let _registerDeviceForRemoteMessages = {
1010 resolve : null ,
@@ -60,8 +60,9 @@ export class Messaging implements IMessaging {
6060
6161 getToken ( ) : Promise < string > {
6262 return new Promise ( ( resolve , reject ) => {
63- if ( UIDevice . currentDevice . name . toLocaleLowerCase ( ) . indexOf ( 'simulator' ) !== - 1 && ! UIApplication . sharedApplication . registeredForRemoteNotifications ) {
63+ if ( ! TNSFirebaseCore . isSimulator ( ) && ! UIApplication . sharedApplication . registeredForRemoteNotifications ) {
6464 reject ( new Error ( 'You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages()' ) ) ;
65+ return ;
6566 }
6667 this . native ?. tokenWithCompletion ( ( token , error ) => {
6768 if ( error ) {
@@ -115,9 +116,8 @@ export class Messaging implements IMessaging {
115116 this . #onMessage = listener ;
116117 if ( listener ) {
117118 TNSFirebaseMessaging . onMessageCallback = ( dict ) => {
118- listener ( deserialize ( dict ) )
119- }
120-
119+ listener ( deserialize ( dict ) ) ;
120+ } ;
121121 } else {
122122 TNSFirebaseMessaging . onMessageCallback = null ;
123123 }
@@ -127,8 +127,8 @@ export class Messaging implements IMessaging {
127127 this . #onToken = listener ;
128128 if ( listener ) {
129129 TNSFirebaseMessaging . onTokenCallback = ( value ) => {
130- listener ( value )
131- }
130+ listener ( value ) ;
131+ } ;
132132 } else {
133133 TNSFirebaseMessaging . onTokenCallback = null ;
134134 }
@@ -138,26 +138,26 @@ export class Messaging implements IMessaging {
138138 this . #onNotificationTap = listener ;
139139 if ( listener ) {
140140 TNSFirebaseMessaging . onNotificationTapCallback = ( dict ) => {
141- listener ( deserialize ( dict ) )
142- }
141+ listener ( deserialize ( dict ) ) ;
142+ } ;
143143 } else {
144144 TNSFirebaseMessaging . onNotificationTapCallback = null ;
145145 }
146146 }
147147
148148 registerDeviceForRemoteMessages ( ) : Promise < void > {
149149 return new Promise ( ( resolve , reject ) => {
150- if ( UIDevice . currentDevice . name . toLocaleLowerCase ( ) . indexOf ( 'simulator' ) > - 1 ) {
150+ if ( TNSFirebaseCore . isSimulator ( ) ) {
151151 ApplicationSettings . setBoolean ( REMOTE_NOTIFICATIONS_REGISTRATION_STATUS , true ) ;
152152 resolve ( ) ;
153153 }
154- TNSFirebaseMessaging . registerDeviceForRemoteMessagesCallback = ( result , error ) => {
155- if ( error ) {
154+ TNSFirebaseMessaging . registerDeviceForRemoteMessagesCallback = ( result , error ) => {
155+ if ( error ) {
156156 reject ( FirebaseError . fromNative ( error ) ) ;
157- } else {
157+ } else {
158158 resolve ( result ) ;
159159 }
160- }
160+ } ;
161161 if ( UIApplication ?. sharedApplication ) {
162162 UIApplication ?. sharedApplication ?. registerForRemoteNotifications ?.( ) ;
163163 } else {
@@ -288,4 +288,4 @@ export class Messaging implements IMessaging {
288288 get ios ( ) {
289289 return this . native ;
290290 }
291- }
291+ }
0 commit comments