Android push notifications client (GCM, ADM, Nokia Push)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.idea Merge branch 'dev' Jul 10, 2015
gradle/wrapper Fix code analyzers problems. Nov 27, 2014
opfpush-providers Update versions. Aug 31, 2015
opfpush Update versions. Aug 31, 2015
LICENSE Initial commit Jul 3, 2014
gradlew Add proguard rules. Mar 17, 2015
gradlew.bat Add analyzers properties. Nov 27, 2014


Android Arsenal

OPFPush is an open source library which provides an easy way for developers to integrate android push notifications into their apps.

Currently OPFPush supports the following push providers: Google Cloud Messaging, Nokia Notification Push, Amazon Device Messaging and provides possibility to use the system push provider for a specific device.

How To Use

Add dependencies

The main dependencies are the opfmaps module and the OPFUtils library:

compile 'org.onepf:opfpush:0.3.1@aar'
compile 'org.onepf:opfutils:0.1.25'

Then you have to add at least one map provider dependency.

GCM Provider:

compile 'org.onepf:opfpush-gcm:0.3.1@aar'
compile ''

ADM Push Provider:

compile 'org.onepf:opfpush-adm:0.3.1@aar'
provided ''

Nokia Push Provider:

compile 'org.onepf:opfpush-nokia:0.3.1@aar'
compile ''

NOTE: If you use ADMProvider or/and NokiaPushProvider you have to add the following repo which hosts amazon-device-messaging.jar and nokia-push.jar:

allprojects {
  repositories {
    // third-party dependencies
    maven { url '' }

Update AndroidManfest.xml

Add permissions and receivers required for each used Push Provider:

<!--gcm permissions-->
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
   android:protectionLevel="signature" />
<!--adm permissions-->
<permission android:name="${applicationId}.permission.RECEIVE_ADM_MESSAGE" />
   android:protectionLevel="signature" />
<!--The same as for gcm-->

   <!--gcm receiver-->
         <action android:name="" />
         <action android:name=""/>
         <category android:name="${applicationId}"/>
   <!--adm receiver-->

         <action android:name="" />
         <action android:name="" />

         <category android:name="${applicationId}" />
   <!--nokia receiver-->
         <action android:name="" />
         <action android:name="" />

         <category android:name="${applicationId}" />



To setup OPFPush add the following piece of code to your Application.onCreate() method:

public class MyApplication extends Application {

   public void onCreate() {
      OPFLog.setEnabled(BuildConfig.DEBUG, true); //Optional. It enables debug logs of the OPFMaps library in the debug build of your apk.

      final Configuration configuration = new Configuration.Builder()
            .addProviders(new GCMProvider(this, GCM_SENDER_ID), new ADMProvider(this), new NokiaNotificationsProvider(this, NOKIA_SENDER_ID)) //Add all providers. The priority of the providers corresponds to the order in which they were added.
            .setSelectSystemPreferred(true) //If you set true, the system push provider will get the highest priority. Default value is false.
            .setEventListener(new PushEventListener(this)) //An implementation of EventListener interface.
      OPFPush.init(this, configuration); //Init OPFPush using the created Configuration object:
      OPFPush.getHelper().register(); //Start registration.

You'll get the registration id into EventListener.onRegistered() callback. After registration you'll start receiving push messages into EventListener.onMessage() callback.


Take a look at the usage of the OPFPush library in our sample application.

##More Information

Simple interation of Google Cloud Messaging

If you want to start using GCM in your application but don't know how. See the easiest way to implement GCM using OPFPush library.

Using of OPFPushReceiver

You can use BroadcastReceiver instead of EventListener for receiving push events. See the following section

Using of JAR dependencies instead of AARs

You also can use JAR dependencies. See the following section.

Notification payload support

GCM Notification payload support was added to the library. Also we have implemented a similar mechanism for all supported push providers. See the following section

Create Custom Push Provider

To create a custom push provider see the following section.

Comparison of most popular push services

Criteria GCM ADM Nokia Notifications OPFPush
Receive messages + + + +
Multiple senders + - + +
Notification payload support + - - +
Asynchronous registration and unregistration - + + +
Retry register on fail - + + +
Retry register on fail after reboot - - - +
Retry unregister on fail - - - +
Check is registration valid on boot - - - +
Retry register after updating app version - - - +
Retry register after changing ANDROID_ID - - - +


Copyright 2012-2015 One Platform Foundation

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

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.