Support Topics Documentation Slack YouTube Blog

difference between push notification and pub/sub

Hello

I’ve a question … what is the difference between push notification and pub/sub … if I’ve register the device then send a push to a channel … and subscribe to the channel to get the published message …isn’t is the same as pub/sub message … ? or they are different ?
And I’ve a problem in data service … when I get the rows from the table … only 10 rows are retrieved … it’s problem from my code ?
And thanks

Push notifications:

    can be delivered to your app even if the app is not currently running. have limit in size of messages (check documentation from Apple, Google and Microsoft on these limits) require registration of the physical device (meaning they cannot be used from a program not running on a device)
Pub/Sub messages:
    App which receives messages must be running. Much higher limit on the message size (2048 bytes) Can send/receive ANY message - primitive values, strings, dates, objects, collections works across all devices, browsers, standalone programs
As for the 10 rows received, this is result of paging - use the PageSize argument to set how many records should be returned (cannot exceed more than 100). See [url=https://backendless.com/feature-17-data-paging-or-how-to-efficiently-load-large-data-sets-in-a-mobile-app/]this[/url] for details.

Regards,
Mark

Thank you … if I’m making chat app with private and group chat … what’s better to use in your opinion … push notification or pub/sub messages?

It could be a combination of the two. Try generating chat app using Backendless, see the screenshot below. The generated code shows both approaches.

http://support.backendless.com/public/attachments/d293133caafb456d8e1a2ecc12509e24.jpg</img>

I’ve already generated it … it’s very useful …
but when I select user to chat with it shows a dialog and i’t isn’t dismissing and the selected user don’t get a notification

I am not aware of the UI problem. Try debugging it.

To get notifications you need to configure the server-side and change the client-side to use proper Google Project number.

I’ve create a project in google developer console and got the projeect number …I’ll try to solve that problem

OK if I send a message using pub/sub and set a header with key “to:” , and value "receiver name "
can the message been sent to only the user who his name is the “receiver name” ?

Yes, but only if the subscriber uses a selector for the specified header and its value. See the “Selectors” section here:

http://backendless.com/documentation/messaging/android/messaging_message_subscription.htm

Thank you … I will read about that

what about subtopics ? can they help ?

Yes, they can. Every chat may have its own subtopic.

Sorry … but I haven’t understand the code in the "Data paging " what is the

CountDownLatch latch = new CountDownLatch( 1 );
and why we use it ?

and if have 1 page then I used nextPage method … what it will return ?
that’s my code :
BackendlessDataQuery dataQuery = new BackendlessDataQuery();
dataQuery.setPageSize(100);
Backendless.Persistence.of(Messages.class).find(dataQuery,new AsyncCallback<BackendlessCollection<Messages>>() {
@Override
public void handleResponse(BackendlessCollection<Messages> messagesCollection) {
if (messagesCollection != null) {
UsersMessages = messagesCollection.getCurrentPage();
if(messagesCollection.getTotalObjects() > 100){
UsersMessages = messagesCollection.nextPage().getCurrentPage();
}
messagesAdapter adapter = new messagesAdapter(MainActivity.this, UsersMessages);
listView.setAdapter(adapter);
swipeRefreshLayout.setRefreshing(false);
}
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
}
});

where I have to use nextPage method ?
and sorry for taking your time

CountDownLatch is a class from JDK:

https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CountDownLatch.html

It is used only in the async example to force sequential loading of individual pages (page 2 is loaded after page 1, and page 3 is loaded only after page 2 is available and so on).

nextPage should be used when you need to fetch the next page of data. If you are at the end of the collection, the sync version of the method will be returning empty collection.

Mark

even after using setPageSize(100); I’m just geting 10 of the rows

check your code, you must be doing it wrong

You’re right …I’m very sorry … I haven’t put the query in the find method

this query will work or not ? I want to get all users expect current user :

dataQuery.setWhereClause(“name != '” + Backendless.UserService.CurrentUser().getProperty(“name”).toString() +"’");

What are the reasons of getting that error ?

BackendlessException{ code: ‘Internal client exception’, message: ‘null’ }

Possibly you’re calling an sync API method from the main thread on Android.