Skip to content

Commit b88f710

Browse files
author
oleg
committed
BKNDLSS-17829 App crashes with NPE when unregistering device with methods without a callback argument
1 parent 7a0d4eb commit b88f710

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/com/backendless/push/FCMRegistration.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ public void handleResponse( Integer response )
105105
Log.d( TAG, "Unregistered on Backendless." );
106106
if( response < 1 )
107107
FCMRegistration.unregisterDeviceOnFCM( appContext, callback );
108-
else
108+
else if( callback != null )
109109
callback.handleResponse( response );
110110
}
111111

112112
@Override
113113
public void handleFault( BackendlessFault fault )
114114
{
115115
Log.d( TAG, "Could not unregister device on Backendless server: " + fault.toString() );
116-
callback.handleFault( new BackendlessFault( "Could not unregister device on Backendless server: " + fault.toString() ) );
116+
if (callback != null)
117+
callback.handleFault( new BackendlessFault( "Could not unregister device on Backendless server: " + fault.toString() ) );
117118
}
118119
} );
119120
}
@@ -128,13 +129,15 @@ public void onComplete( @NonNull Task<Void> task )
128129
if( task.isSuccessful() )
129130
{
130131
Log.d( TAG, "Unsubscribed on FCM." );
131-
callback.handleResponse( 0 );
132+
if( callback != null )
133+
callback.handleResponse( 0 );
132134
}
133135
else
134136
{
135137
Log.e( TAG, "Failed to unsubscribe in FCM.", task.getException() );
136138
String reason = (task.getException() != null) ? Objects.toString( task.getException().getMessage() ) : "";
137-
callback.handleFault( new BackendlessFault( "Failed to unsubscribe on FCM. " + reason ) );
139+
if( callback != null )
140+
callback.handleFault( new BackendlessFault( "Failed to unsubscribe on FCM. " + reason ) );
138141
}
139142
}
140143
} );

0 commit comments

Comments
 (0)