Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
/push-senderPublic archive

Java library that allows you to easily send push messages, via GCM (or FCM) and APNS.

License

Notifications You must be signed in to change notification settings

devsu/push-sender

Repository files navigation

Push Sender [DEPRECATED]#

Push Sender is a Java library that allows sending push messages easily, based on the awesome libraries gcm-server by theganyo and java-apns by notnoop. Be sure to check them out! Send push messages with one line of code, forget about the rest, and focus on making your application's business logic!

Overview

Using Push Sender is very simple. You can import Push Sender on your POM file using:

 <dependency> <groupId>com.devsu</groupId> <artifactId>push-sender</artifactId> <version>1.0.3</version> </dependency> 

Synchronous and asynchronous push services

You can send your push messages synchronously and asynchronously by choosing any of the implementations of PushService.

publicclassMySender{SyncAndroidPushServicesyncAndroidService = newSyncAndroidPushService(GCM_API_KEY); AsyncAndroidPushServiceasyncAndroidService = newSyncAndroidPushService(GCM_API_KEY, null); SyncApplePushServicesyncAppleService = newSyncApplePushService(P12_FILEPATH, P12_PASSWORD, IS_PRODUCTION_ENVIRONMENT); AsyncApplePushServiceasyncAppleService = newAsyncApplePushService(P12_FILEPATH, P12_PASSWORD, IS_PRODUCTION_ENVIRONMENT, null); ... publicvoidsendSomePushMessages(){Stringtitle = "My Push Message Title"; Stringcontent = "Hello! This is a push message!"; syncAndroidService.sendPush(title, content, ANDROID_PUSH_TOKEN); asyncAndroidService.sendPush(title, content, ANDROID_PUSH_TOKEN); syncAppleService.sendPush(title, content, IOS_PUSH_TOKEN); asyncAppleService.sendPush(title, content, IOS_PUSH_TOKEN)} ... }

PushCallback

You can implement a PushCallback for any of the asynchronous services.

publicclassMySender{... publicvoidsendSomePushMessages(){AsyncAndroidPushServiceasyncAndroidService = newSyncAndroidPushService(GCM_API_KEY, newPushCallback(){@OverridepublicvoidonSingleSuccess(booleanresult, Stringtitle, Stringmessage, Map<String, String> additionalFields, Stringtoken){System.out.println("The single message was successfully sent!")} @OverridepublicvoidonError(Throwablet){System.err.println("Oops... Something happened!")} @OverridepublicvoidonBulkSuccess(booleanresult, Stringtitle, Stringmessage, Map<String, String> additionalFields, String[] tokens){System.out.println("The bulk message was successfully sent!")} })} ... }

Customizing

  • You can customize any data sent on your push message with a Map<String, String> that contains any key-value pair you want to send.
  • You can build your Message.Builder or PayloadBuilder objects externally and send them as push messages!
  • You can customize settings like max retries, collapse keys, production/sandbox environments, bulk size when sending simultaneous push messages on Android and more...

Authors

Feel free to contact Alvaro López at rion18@hotmail.com!

License

Copyright 2015 Devsu Software

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.

About

Java library that allows you to easily send push messages, via GCM (or FCM) and APNS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages