Support Topics Documentation Slack YouTube Blog

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


(Rehan) #1

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);

}
});
}


(Fahad Khalid Bhatti) #2

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


(Sergey Chupov) #3

Hi Rehan,

Can you please also provide the publishing code?


(Rehan) #4

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();
}


(Sergey Chupov) #5

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


(Rehan) #6

no, but when i set channel name “Default” than its receive…


(Rehan) #7

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);
}


(Sergey Chupov) #8

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


(Rehan) #9

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


(Sergey Chupov) #10

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