public Observable < Pair < SessionData , ComapiResult < Void > > > updatePushToken ( ) { final SessionData session = dataMgr . getSessionDAO ( ) . session ( ) ; if ( isSessionValid ( session ) ) { return wrapObservable ( Observable . create ( ( Observable . OnSubscribe < String > ) sub -> { String token = dataMgr . getDeviceDAO ( ) . device ( ) . getPushToken ( ) ; if ( TextUtils . isEmpty ( token ) ) { token = pushMgr . getPushToken ( ) ; if ( ! TextUtils . isEmpty ( token ) ) { dataMgr . getDeviceDAO ( ) . setPushToken ( token ) ; } } sub . onNext ( token ) ; sub . onCompleted ( ) ; } ) . concatMap ( token -> sessionController . doUpdatePush ( session , token ) . map ( mapToComapiResult ( ) ) ) . map ( result -> new Pair <> ( session , result ) ) ) ; } else { return Observable . error ( getSessionStateErrorDescription ( ) ) ; } }
Gets an observable task for push token registration . Will emit FCM push token for provided senderId .