@@ -189,6 +189,7 @@ export class PushNotificationService extends TypedEmitter<PushNotificationServic
189
189
190
190
private async createPushCredentials ( ) : Promise < Credentials > {
191
191
const generatedFid = generateFid ( ) ;
192
+
192
193
return await this . registerFid ( generatedFid )
193
194
. then ( async ( registerFidResponse ) => {
194
195
const checkinResponse = await this . executeCheckin ( ) ;
@@ -229,6 +230,7 @@ export class PushNotificationService extends TypedEmitter<PushNotificationServic
229
230
}
230
231
231
232
private async loginPushCredentials ( credentials : Credentials ) : Promise < Credentials > {
233
+ rootPushLogger . info ( 'fidresponse' , credentials . fidResponse )
232
234
return await this . executeCheckin ( )
233
235
. then ( async ( response ) => {
234
236
const registerGcmResponse = await this . registerGcm ( credentials . fidResponse , response ) ;
@@ -704,8 +706,8 @@ export class PushNotificationService extends TypedEmitter<PushNotificationServic
704
706
return this . persistentIds ;
705
707
}
706
708
707
- private async _open ( renew = false ) : Promise < void > {
708
- if ( ! this . credentials || Object . keys ( this . credentials ) . length === 0 || ( this . credentials && this . credentials . fidResponse && new Date ( ) . getTime ( ) >= this . credentials . fidResponse . authToken . expiresAt ) ) {
709
+ private async _open ( renew = false , forceNew = false ) : Promise < void > {
710
+ if ( forceNew || ! this . credentials || Object . keys ( this . credentials ) . length === 0 || ( this . credentials && this . credentials . fidResponse && new Date ( ) . getTime ( ) >= this . credentials . fidResponse . authToken . expiresAt ) ) {
709
711
rootPushLogger . debug ( `Create new push credentials...` , { credentials : this . credentials , renew : renew } ) ;
710
712
this . credentials = await this . createPushCredentials ( ) . catch ( err => {
711
713
const error = ensureError ( err ) ;
@@ -775,7 +777,7 @@ export class PushNotificationService extends TypedEmitter<PushNotificationServic
775
777
public async open ( ) : Promise < Credentials | undefined > {
776
778
if ( ! this . connecting && ! this . connected ) {
777
779
this . connecting = true ;
778
- await this . _open ( ) . catch ( ( err ) => {
780
+ await this . _open ( false , true ) . catch ( ( err ) => {
779
781
const error = ensureError ( err ) ;
780
782
rootPushLogger . error ( `Got exception trying to initialize push notifications` , { error : getError ( error ) , credentials : this . credentials } ) ;
781
783
} ) ;
0 commit comments