• Stars
    star
    261
  • Rank 156,630 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android Library for easy GCM integration in few lines of code.

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:

  • The project uses Google Play Services, so make sure you have:

  • classpath 'com.google.gms:google-services:1.5.0' in your project root gradle file

  • apply plugin: 'com.google.gms.google-services' in your module gradle file

  • compile 'com.google.android.gms:play-services-gcm:8.3.0' in your module gradle file dependencies

  • Add this to your build.gradle: compile 'eu.inloop:easygcm:1.6.2@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 EasyGcm.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

  • Alternatively, instead of being implemented by the Application class, you can have your own instance of GcmListener and set it in the application with EasyGcm.setGcmListener(GcmListener listener)

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"/>

If you want to access the registrationId after the registration has finished, you can use EasyGcm.isRegistered(Context context), EasyGcm.getRegistrationId(Context context) or for convenience EasyGcm.resendRegistrationIdToBackend(Context context) (returns null if registrationId does not exist).

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'
  • add following code to your build.gradle and edit push notification data, apiKey and registration ID
task push(type: eu.inloop.easygcm.PushTask) {
    data = '{"myMessage":"Hello World"}'
    apiKey = 'AIzaSyDt0uzm74Un5qsoEyQcvE-5lhDB3n3m9XX' // Server API Key
    registrationIds = [
            'mt4gNCjtlRs:APA91bHiu_7X_CzA_IbSk9FiR_wk9b6sIvAuR6t-zoE5ujSx0D5Obql5dZiQ9DrEK8YsJm4lBr2nNLKWGRKSr2GZJSgdm_jxOWO4nBCE2QYNzJTS2bCTPRgrIH7cra0t1BEU7g2dwnYY'
    ]
}
  • 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

More Repositories

1

svg2android

SVG to Android VectorDrawable XML resource file
JavaScript
1,706
star
2

shadow4android

Android 9-patch shadow generator
JavaScript
943
star
3

sqlite-viewer

View SQLite file online
JavaScript
861
star
4

AndroidViewModel

Separating data and state handling from Fragments or Activities without lots of boilerplate-code.
Java
815
star
5

interpolator

Realtime interpolation equation editor
JavaScript
391
star
6

apk-method-count

Output per-package method counts in Android APK
TypeScript
295
star
7

UpdatableFragmentStatePagerAdapter

FragmentStatePagerAdapter but with working notifyDataSetChanged() support
Java
136
star
8

image-picker

An easy to use, highly configurable image picker for your chat application.
Swift
101
star
9

easyrelease

Gradle plugin for Android projects that helps with signing release APKs
Groovy
58
star
10

SimpleRecyclerAdapter

A simple and reusable RecyclerView adapter
Java
41
star
11

LocalMessageManager

Simpler to use and faster alternative to LocalBroadcastManager
Java
40
star
12

ScreenInfo

Android screen info tool for developers
Java
20
star
13

qlplayground

QuickLook generator for the Xcode Playgrounds
CSS
20
star
14

Styles

Styling iOS apps made easy
Swift
18
star
15

cra-docker

Docker image for running Create React App distributions
Dockerfile
11
star
16

INLBreadcrumbs

iOS library for UINavigationController breadcrumb navigation
Objective-C
7
star
17

CodableStore

Persistance providers for swift Codables
Swift
6
star
18

PinIndicatorView

A simple UI component that mimics the lock screen pin indicator
Swift
6
star
19

styles-zeplin-extension

Zeplin extension for Styles
TypeScript
5
star
20

UIViewController-DisplayChild

UIViewController containment made easy
Swift
4
star
21

UIViewController-DisplayInDrawer

Present any view controller easily in a drawer (iOS Maps style)
Swift
4
star
22

goclitools

Collection of tools for creating cli apps.
Go
3
star
23

slack-ooo

JavaScript
3
star
24

Knight

MVP library with Dependency Injection for Android
Java
3
star
25

ParallaxAnimation

iOS UICollectionView layout parallax effect example
Swift
3
star
26

devopscli

CLI tools for devops to automate everyday tasks
Go
3
star
27

INLThemes

An iOS library for supporting multiple UI themes
Objective-C
3
star
28

qc

Cisco AnyConnect Secure Mobility Server helper for the lazy ones
Swift
3
star
29

INLConfig

An iOS library for loading your configuration from a plist that supports automatic code generation for supporting code and remote updates
Swift
3
star
30

eureka-article

Source code for the Medium post about Eureka
Swift
2
star
31

SVGMap

SVGMap
Swift
2
star
32

bitbucket-pr-badges

Pull Request status badges for Bitbucket (browser extension).
JavaScript
2
star
33

PluggableApplicationDelegate

Service oriented application delegate. Carthage ready.
Swift
2
star
34

enhanced-volley

Java
2
star
35

inkwire

Wireframe kit and UX pattern library for Sketch. iOS in progress, Android to come.
2
star
36

cleaner-swift-templates

Inloop Clean Swift Xcode templates
Makefile
2
star
37

easylog

A simple wrapper for android.util.Log which adds useful features such as: calling method name added to each log, log message parameters, tag automatically added, option to disable all logs...
Java
2
star
38

go-transport-queue

Queue for transporting large batch of messages with specific interval and batch size.
Go
1
star
39

INLAsyncOperation

The wrapper for the AsynchronousOperation
Shell
1
star
40

YoutubeLeakSample

Java
1
star
41

nsq-transport

NSQ consumer for transporting messages to various targets
Go
1
star
42

tslint-config

1
star
43

HideableItemsTabbarController

Hide UITabBar items with ease.
Swift
1
star
44

csv2languagefiles

Translates CSV containing language translations to both iOS and Android file formats.
Python
1
star
45

sql-exporter

Command line utility to export data from SQL database
Go
1
star