GithubHelp home page GithubHelp logo

classicvalues / easygcm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from avast/easygcm

0.0 0.0 0.0 148 KB

Android Library for easy GCM integration

License: Apache License 2.0

Java 89.31% Groovy 10.69%

easygcm's Introduction

easygcm

Android Library for easy GCM integration. Including push notifications sender task for Gradle.

This library is based on sample client code provided by Android documentation at http://developer.android.com/google/gcm/client.html and https://code.google.com/p/gcm/

It includes all the common code from the sample including AndroidManifest.xml that is automatically merged into your application. Also content of sample's DemoActivity is included in this library extracted in GcmHelper class. This library further improves original sample client in several ways, see changelog.

How to use:

  • Add this to your build.gradle: compile 'eu.inloop:easygcm:1.5.3@aar'
  • In your Application implement GcmListener interface with two methods:
    • onMessage()
    • sendRegistrationIdToBackend()

Note: Both methods are executed asynchronously in background thread and the wake lock is held until the method is executed. Don't start other asynchronous tasks here unless needed - the wake lock would be released and the tasks would not be guaranteed to run. Put the blocking code right into these methods.

  • In your MainActivity onCreate(), call GcmHelper.init(this);
  • Define GCM Sender ID adding google-service.json configuration and setting up Google Services Gradle plugin as described in Implementing GCM Client on Android

If you need GET_ACCOUNTS permission, add this to you application's manifest:

<uses-permission
    android:name="android.permission.GET_ACCOUNTS"
    tools:remove="android:maxSdkVersion"/>

That's it. You might also want to use Gradle task for sending push notifications to your device:

  • add Gradle dependency to buildscript section: classpath 'eu.inloop:easygcm-tasks:1.3.0'
  • edit push notification data, apiKey and registration ID in build.gradle
  • call ./gradlew push

How to build locally:

So far, it is not possible to use project dependencies in Gradle's buildscript section (needed for our plugin). That means you have to build the library first (and install in local Maven repo) and just then build the sample application.

./gradlew clean uploadArchives
./gradlew -p easygcm-sample clean assembleDebug

easygcm's People

Contributors

davidvavra avatar martinadamek avatar peterbartos avatar soyangel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.