Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support an option delegateBean in configuration #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ApnsGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ push notifications to an iPhone client of your Grails application.
certificateResourcePath = application.config.apns.certificateResourcePath ?: null
password = application.config.apns.password
environment = configuredEnvironment
if ( application.config.apns.delegateBean ) {
log.debug "Using delegate ${application.config.apns.delegateBean}"
delegateBean = ref( application.config.apns.delegateBean )
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ If you don't have access to your server's file system, you can also replace path

This new configuration system is way better for Heroku deployment.

You can configure a bean to be notified by sent event via the option "delegateBean". This bean must implement the interface com.notnoop.apns.ApnsDelegate.

apns {
pathToCertificate = "/usr/local/myapp/APNs_production_certificates.p12"
password = "password"
environment = "production"
delegateBean = "apnsDelegateService"
}

Usage
=====

Expand Down
5 changes: 5 additions & 0 deletions src/groovy/org/epseelon/grails/apns/ApnsFactoryBean.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ApnsFactoryBean implements FactoryBean {
boolean queued = false
Environment environment = Environment.SANDBOX
boolean nonBlocking = false
def delegateBean

Object getObject() {
def apnsService = APNS.newService()
Expand Down Expand Up @@ -49,6 +50,10 @@ class ApnsFactoryBean implements FactoryBean {

apnsService = apnsService.asQueued()

if( delegateBean ) {
apnsService = apnsService.withDelegate( delegateBean )
}

return apnsService.build()
}

Expand Down