Home

Awesome

Android Arsenal

android-remote-notifications

A Google GCM/Amazon SNS alternative using pull instead of push.

Main features

Download

Gradle:

implementation ('com.github.kaiwinter:android-remote-notifications:1.1.5@aar') {
    transitive = true
}

Demo:

How to integrate

You can find the source code of the example app here: MainActivity

The easy way

this will

For more control

RemoteNotifications rn = new RemoteNotifications(context, url);
rn.updateNotifications(UpdatePolicy.NOW);
rn.showNotifications(); // if update still runs, event will be queued and carried out later

// -or, register a listener on update completion-
rn.updateNotifications(UpdatePolicy.NOW, finishListener);

How to build a JSON notification file

First: You don´t have to write the JSON file by hand. Just use the API to initialize a Notification object and then create JSON from it: NotificationCreatorUtil

Example of a Toast Notification

[
  {
    "type": "ToastNotification",
    "notificationConfiguration": {
      "startShowingDate": null,
      "executionPolicy": "ALWAYS",
      "numberOfTotalViews": null,
      "versionCodePolicy": null
    },
    "message": "This is a Toast Notification",
    "duration": 1
  }
]

Example of an AlertDialog Notification

[
  {
    "type": "AlertDialogNotification",
    "notificationConfiguration": {
      "startShowingDate": null,
      "executionPolicy": "ALWAYS",
      "numberOfTotalViews": null,
      "versionCodePolicy": null
    },
    "title": "Title",
    "message": "This is an AlertDialog notification",
    "negativeButtonText": "Exit App",
    "neutralButtonText": "Open web page",
    "positiveButtonText": "Open Play Store",
    "positiveButtonAction": {
      "type": "OpenStoreButtonAction",
      "packageName": "de.vorlesungsfrei.taekwondo.ads"
    },
    "negativeButtonAction": {
      "type": "ExitAppButtonAction"
    },
    "neutralButtonAction": {
      "type": "OpenUrlButtonAction",
      "link": "https://github.com/kaiwinter/android-remote-notifications"
    },
    "modal": false
  }
]

Screenshots

Preview

License

 Copyright 2018 Kai Winter
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
     http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.