android-remote-notifications


Source link: https://github.com/kaiwinter/android-remote-notifications

android-remote-notifications

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

Main features

  • Independent user notifications (no Google GCM or Amazon SNS), just put a JSON file in the cloud
  • Framework will update available notifications automatically in defined time intervals ( now, daily, bi-weekly, weekly, monthly)
  • Flexible parameters:
    • start date for notification (distribute early, show later)
    • amount of times the notification should be shown
    • interval between showing notifications ( always, every day, every week, every month)
    • specify on which app version ( versionCode) the notification should be shown
  • Show notifications as AlertDialog or Toast message (defined by the remote JSON file)
    • AlertDialog: Specify button captions and actions: Open Store-Action, Open URL-Action, Exit App-Action, all defined by a JSON file on your server
  • perfect to inform your users about discounts on one of your other apps or premium version
  • pro tip: as some users don't always update to the latest app versions you should integrate this framework in an early phase if you plan to use it at a later time.

Download

Maven

<dependency>
<groupId>com.github.kaiwinter</groupId>
<artifactId>android-remote-notifications</artifactId>
<version>1.1.0</version>
<type>aar</type> </dependency>

Gradle:

compile 'com.github.kaiwinter:android-remote-notifications:1.1.0'

Direct:

Live Demo:

Appetize.io

How to integrate

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

The easy way

  • Call RemoteNotifications.start(context, url, UpdatePolicy.NOW); in your onCreate() or onResume() method

this will

  • start an update of the notifications (use UpdatePolicy.WEEKLY in production environment to update once a week)
  • show due notifications to the user

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

ProGuard

To keep the jackson annotations add this to your ProGuard configuration.

# android-remote-notifications -keepattributes *Annotation*,EnclosingMethod,Signature -keepnames class com.fasterxml.jackson.** {
 *; 
}
 -dontwarn com.fasterxml.jackson.databind.** -keep public class com.github.kaiwinter.** {
*;
}
 

License

 Copyright 2015 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. 

Resources

Monad on Android like Scala.

Very easy to use wrapper library for Android SharePreferences.

Provides a simple way for handling connectivity change events.

A small library to send an email in background without user interaction.

Android Library to help you with your runtime Permissions.

This is a lightweight Image Cropper for Android which also supports no-crop feature.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes