A gem to send the push notification to mobile app via Amazon Simple Notification Service (SNS). Currently supports only iOS platform at production quality. The support for Android is experimentally implemented.
Add this line to your application's Gemfile:
gem 'j7w1'
And then execute:
$ bundle
Or install it yourself as:
$ gem install j7w1
First, configure your app.
J7W1.configure 'config.yml'
Or, you may configure programatically as below:
configuration = {
app_endpoint: {
ios: {arn: ...},
},
account: {
...
}
}
J7W1.configure
Configuration is expected to have the structure as below:
app_endpoint:
ios:
arn: "<The ARN of your app.>"
android:
arn: "<The ARN of your android app.>"
account:
access_key_id: "<Your Access Key>"
secret_access_key: "<Your Secret Key>"
region: '<Your Region>'
If you use this with RoR, top-level environmental definition can be available.
J7W1::PushClient.create_device_endpoint.
J7W1::PushClient.create_device_identifier device_identifier, platform
This method returns the arn registered.
J7W1::PushClient.push.
J7W1::PushClient.push endpoint_arn, platform, message: some_message, badge: badge_count, sound: xxx
endpoint_arn should be the return value of the :create_device_endpoint above.
The generator j7w1:model must be useful for you. It provides the items below:
- The model J7W1ApplicationDevice. This model enables you to store the device information and to push easily.
- The migration for the model above.
- Asyncronous SNS Syncing support. Currently delayed_job and sidekiq are supported. If you use this feature, invoke j7w1:model generation with --async-engine=(delayed_job|sidekiq).
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
TOYODA Naoto https://github.com/condor