RSS

Push Notification

21 Nov

Push notifications let your application notify a user of new messages or events even when the user is not actively using your application. On Android devices, when a device receives a push notification, your application’s icon and a message appear in the status bar.

image

image

Design Editor

AppyBuilder SILVER plan now contains an experimental non-visible PushNotification component that can easily be added into your app. It contains simple configuration properties and blocks to enable the push notifications without any coding!

image

To enable this feature, drag-and-drop a PushNotification component onto design layout. It, currently, contains below properties:

image

  • FirebaseURL – On back-end, this component uses Firebase and will be listening to any updates that your app has subscribed to. This property will need to be configured to use your own Firebase database.
  • TopicPath – Each app can subscribe (listen) to specific TopicPath. Once configured in your app, using Firebase-dashboard, you will be able to push messages to any app that is subscribed to this specific topic. TopicPath will have default value of:
    • _topic_/EMAIL_DOMAIN/APP_NAME   where
      • EMAIL_DOMAIN is the domain of your email. For example if your email is jdoe@gmail.com, domain will will be jdoe
      • APP_NAME is the name of your app; e.g. LegoApp
      • Given above examples the full TopicPath will be: _topic_/jdoe/LegoApp
  • VersionCode – Push messages can be sent to ALL apps, regardless of version OR specific versions of the app. This optional property can be used to push messages to specific version of the published apps. For example, updating VersionCode to 2, will update the TopicPath like below; meaning that app will be subscribed to (listen to) any messages that are sent to path below:
    • _topic_/jdoe/LegoApp/2

Blocks Editor

PushNotification includes a block that should be used to start the subscription.

image

Once subscription is started, the app will listen to messages, even if the app is not active. This block returns a boolean indicating if starting the subscription was success or not. For this tutorial, we just ignore the value. Therefore, from built-in blocks, use “Evaluate but ignore result” block and snap into PushNotification.StartSubscription:

image

Above blocks can be added into Screen1.Initialize event-handler block. Once this is triggered, app will listen to messages, even if app is not active OR if app is closed / killed.

image

Configuring Firebase

Once Firebase account is setup, we use Firebase dahsboard (console), to add the TopicPath. For this, from your app, copy the TopicPath into clipboard. Next, in Firebase dashboard, at root level, click the + sign and paste the copied TopicPath  as shown below:

image

Above will result in child-tags being created like below. Now, the message will be pushed to your app and will display in the taskbar, even if the app is not-active or is forced-closed.

image

A notification message on device taskbar will include a title. Above will result in a default title to be displayed on taskbar. If you like to use your own title, you could use below syntax for the message.

someTitle=Hello Android!

Once the message is received by device, it will take display “someTitle” (or whatever your title is) as the title of the notification.

Conclusion

PushNotification allows you to re-engage users by delivering messages to all client apps and can be used to notify client app that for example new data is available to sync or new version of the app is available.

 

 

 
Leave a comment

Posted by on November 21, 2016 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: