Backendless Support
 
Waiting for user's response

Notification not working when use other channel instead of "Default" channel

When i register device with "Default" channel than notification working but when i change channel name then device register and channel creates as well but notification not receiving... (SDK 4)

Backendless.Messaging.registerDevice("xxxxxxxxxxxx", GlobalValues.m_stUserName, new AsyncCallback<Void>() {

@Override

public void handleResponse(Void response) {

System.out.println("==>> Register device : " + response);

Backendless.Messaging.subscribe(GlobalValues.m_stUserName, new AsyncCallback<List<Message>>() {

@Override

public void handleResponse(List<Message> response) {

Log.e("device subscribe",""+response);

System.out.println("==>> Register device subscribe : " + response);

}

@Override

public void handleFault(BackendlessFault fault) {

System.out.println("==>> Register device subscribe fault : " + fault);

}

}, new AsyncCallback<Subscription>() {

@Override

public void handleResponse(Subscription response) {

System.out.println("==>> Register device Subscription : " + response.getChannelName());

@Override

public void handleFault(BackendlessFault fault) {

System.out.println("==>> Register device Subscription fault : " + fault);

}

});

}

Leave a Comment

Comments (9)

photo
1

Facing same issue. I am unable to use custom channel name. to send notifications to multiple devices using same account simultaneously.

photo
1

Hi Rehan,

Can you please also provide the publishing code?

photo
1

hi Sergey

this one is publish code.

PublishOptions publishOptions = new PublishOptions();

publishOptions.putHeader("ios-alert", getMessage(signal));

publishOptions.putHeader("android-ticker-text", context.getResources().getString(R.string.app_name));

publishOptions.putHeader("android-content-title", context.getResources().getString(R.string.app_name));

publishOptions.putHeader("android-content-text", getMessage(signal));

Backendless.Messaging.publish(GlobalValues.m_stUserName, getMessage(signal) + "," + getDeviceID(context), publishOptions, new AsyncCallback<MessageStatus>() {

@Override

public void handleResponse(MessageStatus messageStatus) {

System.out.println("status : " + messageStatus);

}

@Override

public void handleFault(BackendlessFault backendlessFault) {

Log.e("messageStatus", "" + backendlessFault);

}

});

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

photo
1

Does your code receive a message when you publish it from the developer's console?

photo
1

no, but when i set channel name "Default" than its receive....

photo
1

i receive a message here when send from console with both Channel name . but PushReceiverBackendless class only executes when channel name "Default"

Backendless.Messaging.subscribe(GlobalValues.m_stUserName, new AsyncCallback<List<Message>>() {

@Override

public void handleResponse(List<Message> response) {

System.out.println("==>> Register device subscribe : " + response);

}

photo
1

So you're working with push notifications or publish-subscribe messaging? You don't need a .subscribe() call when you only work with pushes.

photo
1

i just want to send a push notifications to those users who are on same channel.

photo
1

In this case you only need to call .registerDevice() with proper channel, not .subscribe().

photo