Showing push notification message in App

Hi,

I would like to send a push notification from the web client and then show that message as a popup when the user opens the app? Therefore is it possible to collect or read messages in the app as strings?

best,

Feras A.

The messages are not persisted, so they are not stored to the server. Your app can collect messages and then shows it. Also you can persist all messages using before or after event handlers http://take.ms/RgdW1. Each time when some one push notification, your bussines logic may save this message to Backendless Data

1 Like

Awesome, How do I collect messages and then show them?

first of all read doc http://backendless.com/docs/android/doc.html#push_push_notification_setup_androi

in the section Manifest Configuration you will find information about BackendlessPushService. so you have to create class:

public class MyPushService extends BackendlessPushService
{
 
  ...
  @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();
    // When returning 'true', default Backendless onMessage implementation 
    // will be executed. The default implementation displays the notification 
    // in the Android Notification Center. Returning false, cancels the 
    // execution of the default implementation.
    return false;
  }
  ...

So you have to return false here and save string message some where

thank you and for iOS in swift?

thank you and for iOS in swift?

Hello,

Backendless push notifications aren’t different from the standard iOS push notifications. You can save the received payloads into UserDefaults for example. Maybe this could be helpful: https://stackoverflow.com/questions/41035878/how-can-i-store-push-notification-alert-message-in-userdefault/41037919

Regards,
Olga