Skip to content

Example: Basic Push

// do not forget to call Backendless.initApp in the app initialization logic

var channel = "TestChannel",
    message = "Hello, world!",
    publishOptions = new Backendless.PublishOptions({
       headers: {
           "android-ticker-text": "Your just got a push notification",
           "android-content-title": "This is a notification title",
           "android-content-text": "Push notifications are cool"
       }
   });

Backendless.Messaging.publish( channel, message, publishOptions )
 .then( function( messageStatus ) {
    console.log( "message has been published, message status - " + messageStatus.status );
  })
 .catch( function ( error ) {
    console.log( "error - " + error.message );
 });

Codeless Reference

The example below publishes the message to the "default" channel. This message is delivered only to Android devices, since no values were set for iOS properties.

push_example_basic_push_1

For a detailed description of the Codeless block, refer to the Push With API topic of this guide.