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