GithubHelp home page GithubHelp logo

apns-persistent's Introduction

Apns::Persistent

apns-persisitent is referencing houston

Installation

Add this line to your application's Gemfile:

gem 'apns-persistent'

And then execute:

$ bundle

Or install it yourself as:

$ gem install apns-persistent

Push Usage

Examples

Recommend

c = Apns::Persistent::PushClient.new(certificate: '/path/to/apple_push_notification.pem', sandbox: true)
c.open

thread = c.register_error_handle do |command, status, id|
  #error handle
  puts "Send Error! command:#{command} status:#{status} id:#{id}"
end

c.push(token: '88189fcf 62a1b2eb b7cb1435 597e734e a90da4ce 6196a9b3 309a5421 4c6259e',
       alert: 'foobar',
       sound: 'default',
       id: 1)

begin
  thread.join
rescue Interrupt
  c.close
end

Without Thread

c = Apns::Persistent::PushClient.new(certificate: '/path/to/apple_push_notification.pem', sandbox: true)
c.open
c.push(token: '88189fcf 62a1b2eb b7cb1435 597e734e a90da4ce 6196a9b3 309a5421 4c6259e',
       alert: 'foobar',
       sound: 'default',
       id: 1) do |command, status, id|
  #error handle
  puts "Send Error! command:#{command} status:#{status} id:#{id}"
end
c.close

Without Persistent Connections

Apns::Persistent::PushClient.push_once(certificate: '/path/to/apple_push_notification.pem',
                                       token: '88189fcf 62a1b2eb b7cb1435 597e734e a90da4ce 6196a9b3 309a5421 4c6259e9',
                                       alert: 'foobar',
                                       sound: 'default',
                                       id: 1) do |command, status, id|
  #error handle
  puts "Send Error! command:#{command} status:#{status} id:#{id}"
end

Feedback API Usage

Get unregistered devices

c = Apns::Persistent::FeedbackClient.new(certificate: '/path/to/apple_push_notification.pem', sandbox: true)
c.open
devices = c.unregistered_devices
c.close

Get unregistered device tokens

c = Apns::Persistent::FeedbackClient.new(certificate: '/path/to/apple_push_notification.pem', sandbox: true)
c.open
device_tokens = c.unregistered_device_tokens
c.close

Get unregistered devices once

devices = Apns::Persistent::FeedbackClient.unregistered_devices_once(certificate: '/path/to/apple_push_notification.pem', sandbox: true)

Get unregistered device tokens once

device_tokens = Apns::Persistent::FeedbackClient.unregistered_device_tokens_once(certificate: '/path/to/apple_push_notification.pem', sandbox: true)

Command Line Tools

Launch Daemon

$ push_daemon --pemfile <path> [--sandbox]

Push after launch daemon

$ push --token <token> --alert "Hello" --badge 2 --sound "default"

Push once

$ push_once --pemfile <path> [--sandbox] --token <token> --alert "Hello" --sound "default" --badge 2

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/malt03/apns-persistent. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

apns-persistent's People

Contributors

malt03 avatar taka0125 avatar

Watchers

 avatar  avatar  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.