onMessage Method is never called in Push Notifications

Hi Everyone, I’ve read all documentation about Custom Push Notifications and I tried to customise onClick action when the push notification get to the other device ,but onMessage method is never called,
I created the 2 classes which extends of BackendlessPushService and BackendlessBroadcastReceiver with their manifest configuration,but when I get the push not.in the ther device this method does not work…
This is my first class created
public class PushService extends BackendlessPushService
{
@Override
public void onRegistered(Context context, String registrationId)
{
Toast.makeText( context, “device registered” + registrationId, Toast.LENGTH_SHORT).show();
}
@Override
public void onUnregistered( Context context, Boolean unregistered )
{
Toast.makeText( context, “device unregistered”, Toast.LENGTH_SHORT).show();
}
@Override
public boolean onMessage( Context context, Intent intent)
{
String message = intent.getStringExtra( “message” );
Toast.makeText( context, "Push message received. Message: " + message, Toast.LENGTH_LONG ).show();
return false;
}
@Override
public void onError( Context context, String message )
{
Toast.makeText( context, message, Toast.LENGTH_SHORT).show();
}
}
and this is the last one
public class MyPushReceiver extends BackendlessBroadcastReceiver
{
@Override
public boolean onMessage(Context ctx,Intent intent)
{
String message = intent.getStringExtra( “message” );
Toast.makeText( context, "Push message received. Message: " + message, Toast.LENGTH_LONG ).show(); return false;
}
@Override
public Class<? extends BackendlessPushService> getServiceClass()
{
return PushService.class;
}
}
if this method was called… the toast message would appear (I tried with other parameters such as PublishOptions.ANDROID_TICKER_TEXT_TAG, PublishOptions.ANDROID_CONTENT_TITLE_TAG for instance).and this is how I send push notification :
DeliveryOptions deliveryOptions = new DeliveryOptions();
deliveryOptions.addPushSinglecast(deviceId);
deliveryOptions.setPushPolicy(PushPolicyEnum.ONLY);
PublishOptions publishOptions = new PublishOptions();
publishOptions.putHeader(PublishOptions.ANDROID_TICKER_TEXT_TAG,"the user “+ current_user.getProperty(“name”) + " "
+current_user.getProperty(“last_name”)+” “+ “has respond to you”);
publishOptions.putHeader(PublishOptions.ANDROID_CONTENT_TITLE_TAG,“Diabetes APP”);
publishOptions.putHeader(PublishOptions.ANDROID_CONTENT_TEXT_TAG,“Message from forum”);
Backendless.Messaging.publish(“Message from forum”,publishOptions, deliveryOptions, new AsyncCallback<MessageStatus>()
{
@Override
public void handleResponse(MessageStatus response)
{
Toast.makeText(getActivity(),“PUSH NOTIFICATION SENT”,Toast.LENGTH_LONG).show();
}
@Override
public void handleFault(BackendlessFault fault)
{
Toast.makeText(getActivity(),” ERROR-PUSH NOTIFICATION NOT SENT- " +fault.getMessage(),Toast.LENGTH_LONG).show();
}
});

I’m not sure what could be the problem…
Please any help would be appreciated.

Regards

Have you tried debugging and actually checking whether the code goes into onMessage method? Or logging something there? Also you might try to return true to see the notification in the device’s notification bar

Hi Sergey, thanks for your response, I tried changing the boolean value to true and false… but nothing happens, but I was told by backendless support that the onMessage Method is invoked automatically in the device when it gets the notification…

Have you followed this doc?

yes, I followed that doc, but I still can’t see onMessage or the other 3 methods working.

Hi Jon,
Please, provide us minimal sample app to reproduce this problem.
Regards Ilya

Hi Dear Ilya , I could find the solution, but onMessage method only works in PushReceiverClass and not in BackendlessBroadcastReceiver and everything goes well so far.
Thanks a lot