Giter Site home page Giter Site logo

nicoskaralis / pushmeup Goto Github PK

View Code? Open in Web Editor NEW
328.0 328.0 125.0 864 KB

This gem is a wrapper to send push notifications to devices. Currently it only sends to Android or iOS devices, but more platforms will be added soon. With APNS (Apple Push Notifications Service) you can send push notifications to Apple devices. With GCM (Google Cloud Messaging) you can send push notifications to Android devices.

Home Page: http://nicoskaralis.github.com/pushmeup

License: MIT License

Ruby 100.00%

pushmeup's People

Contributors

antoinelyset avatar bitdeli-chef avatar dimagoltsman avatar lloydmeta avatar nicoskaralis avatar printercu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pushmeup's Issues

APNS does not return a response

I am trying to write code that tracks the delivery of push notifications. The response I always get from calling APNS.send_notification is always nil. GCM.send_notification gives me a response hash. With just a nil response, I have no way of knowing if the notification was delivered for APNS. In development the push notifications are delivered, still with a nil response. In production (with TestFlight, the production gateway URL, and my production pem), notifications are not delivered and the response is still nil. I don't know what to do if I can't verify the response from APNS.send_notification.

Here is the code where I am calling APNS.send_notification:

    def push_to_ios_clients
      was_successful = true
      APNS.start_persistence
      pending_ios_clients.each do |client|
        result = APNS.send_notification(client.push_id, apns_data)
        logger.info "APNS response: #{result.inspect}" # result is always nil
        # todo - need to be able to verify response to determine if notification was sent
      end
      was_successful
    ensure
      APNS.stop_persistence
    end

Cucumber testing

Is there a way to not send out a network call and still see the deliveries of the notification? This will be very helpful for cucumber testing.

Deadlock in APNS send_notification

I am using Sidekiq to process my APNS push background jobs. I am using APNS as the code below

APNS.host = 'gateway.push.apple.com'
APNS.port = 2195
APNS.pem  = '<pem credential file path here>'
APNS.pass = ''

message = "new message"
APNS.send_notification('<device token here>', alert: message, :other => {:type => 'requested_order', :key => 'order_id', :value => 1})

However, I often get my push workers stuck in Sidekiq. With a sidekiq dump, I get the following info:

2016-03-15T13:07:52.728Z 7483 TID-gryn4hvgw WARN: Thread TID-gryne1v0o 
2016-03-15T13:07:52.728Z 7483 TID-gryn4hvgw WARN: /opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `synchronize'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `send_notifications'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:37:in `send_notification'
/var/app/current/app/workers/stepped_order_request_notification_worker.rb:54:in `block in perform'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.1.6/lib/active_record/relation/delegation.rb:46:in `each'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.1.6/lib/active_record/relation/delegation.rb:46:in `each'
/var/app/current/app/workers/stepped_order_request_notification_worker.rb:49:in `perform'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:75:in `execute_job'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:127:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidetiq-0.6.3/lib/sidetiq/middleware/history.rb:8:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/logging.rb:24:in `with_context'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:132:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:132:in `invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:51:in `block in process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:98:in `stats'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:50:in `process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:122:in `dispatch'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in `block in task'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'
2016-03-15T13:07:52.728Z 7483 TID-gryn4hvgw WARN: Thread TID-gryne1cu8 
2016-03-15T13:07:52.728Z 7483 TID-gryn4hvgw WARN: /opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `synchronize'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `send_notifications'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:37:in `send_notification'
/var/app/current/app/workers/order_start_notification_worker.rb:41:in `block in perform'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.1.6/lib/active_record/relation/delegation.rb:46:in `each'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.1.6/lib/active_record/relation/delegation.rb:46:in `each'
/var/app/current/app/workers/order_start_notification_worker.rb:40:in `perform'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:75:in `execute_job'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:127:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidetiq-0.6.3/lib/sidetiq/middleware/history.rb:8:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/logging.rb:24:in `with_context'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:132:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:132:in `invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:51:in `block in process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:98:in `stats'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:50:in `process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:122:in `dispatch'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in `block in task'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'
2016-03-15T13:07:52.729Z 7483 TID-gryn4hvgw WARN: Thread TID-gryne02ek 
2016-03-15T13:07:52.729Z 7483 TID-gryn4hvgw WARN: /opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `synchronize'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `send_notifications'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:37:in `send_notification'
/var/app/current/app/workers/order_start_notification_worker.rb:41:in `block in perform'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.1.6/lib/active_record/relation/delegation.rb:46:in `each'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.1.6/lib/active_record/relation/delegation.rb:46:in `each'
/var/app/current/app/workers/order_start_notification_worker.rb:40:in `perform'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:75:in `execute_job'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:127:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:127:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidetiq-0.6.3/lib/sidetiq/middleware/history.rb:8:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/logging.rb:24:in `with_context'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:129:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:132:in `call'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/middleware/chain.rb:132:in `invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:51:in `block in process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:98:in `stats'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/sidekiq-3.3.2/lib/sidekiq/processor.rb:50:in `process'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:122:in `dispatch'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in `block in invoke'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in `block in task'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize'
/opt/rubies/ruby-2.2.4/lib/ruby/gems/2.2.0/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'

Is it because APNS#send_notification is not thread_safe? What is the thread_safe alternative here?

Ensure 2048 Cert.

How am I supposed to add the CAfile in order to actually send a push? .pem is only half the handshake.

GCM mismatchSenderId

I've been reading through doc after doc after doc (and by that I mean site after site) where people run into this error and it has to do with the project # for the app.

target = "reallylongdeviceid" 
GCM.format = :json
GCM.key = "apikey" 
# found at https://console.developers.google.com/project/766********7/apiui/credential?authuser=0
# the number found in the url there, the project number, is a linked sender id on play.google.com/apps/publish/etc....../
data = {:message => "test push" }
GCM.send_notification(target, data) 
GCM.send_notification(target)

Output:

[{:response=>"success", :body=>{"multicast_id"=>obfuscated, "success"=>0, "failure"=>1, "canonical_ids"=>0, "results"=>[{"error"=>"MismatchSenderId"}]}, :headers=>{"content-type"=>["application/json; charset=UTF-8"], "date"=>["Wed, 03 Sep 2014 19:08:56 GMT"], "expires"=>["Wed, 03 Sep 2014 19:08:56 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alternate-protocol"=>["443:quic"], "connection"=>["close"]}, :status_code=>200}] 
[{:response=>"success", :body=>{"multicast_id"=>obfuscated, "success"=>0, "failure"=>1, "canonical_ids"=>0, "results"=>[{"error"=>"MismatchSenderId"}]}, :headers=>{"content-type"=>["application/json; charset=UTF-8"], "date"=>["Wed, 03 Sep 2014 19:10:19 GMT"], "expires"=>["Wed, 03 Sep 2014 19:10:19 GMT"], "cache-control"=>["private, max-age=0"], "x-content-type-options"=>["nosniff"], "x-frame-options"=>["SAMEORIGIN"], "x-xss-protection"=>["1; mode=block"], "server"=>["GSE"], "alternate-protocol"=>["443:quic"], "connection"=>["close"]}, :status_code=>200}] 

I inherited this project and apparently push notifications never worked. It looks like it's an error with the ID that the app registers with, but what's in the phonegap codebase when the app starts, and what's setup as a linked sender ID match. I'm new to looking at push notifications and just want to try to get this working but I'm not sure where to look. This probably isn't related to pushmeup, but any help someone could offer I would appreciate.

Thanks!

Message never makes it do device

I'm attempting to send a message to an Android device. This is the relevant content from the method I am calling

    GCM.key = "<my Google API key for server applications>"
    @project_number = "<the google project number for my app>"
    @reg_id = "<the registration Id for the android device>"

    def notify message
        options = {:collapse_key => "key2", :time_to_live => 3600, :delay_while_idle => true}
        data = { :key => @project_number, :key2 => ["Message Title", message ] }
        resp = GCM.send_notification([@reg_id], data, options)

The response I get from GCM.send_notification returns with a 200 status code and { success: 1 } in the body. But the message never makes it to the device. I'm clearly missing some piece. Can anybody shed some light?

edit: I have been monitoring the API logs on the Google Developer Dashboard, and see no activity.

Broken pipe error

When using APNS.send_notifications I encounter "Broken pipe" errors which after googling around I understand have to do with invalid device registration ids (user blocked notifications, uninstalled the app, etc.). Is there a way to have the APNS.send_notifications method resume pushing to the rest of the devices while just accumulating errors instead of raising an exception and returning?

Great gem BTW!

Mantainer wanted?

Hey there, looking at the state of the issues and pull requests it looks like you could use a mantainer for this gem.

I like its style because it does what's needed and it doesn't have any bloat. I'm using it at work currently so if it's fine with you I'd like to step up.

IOS notification not sent,

i've made everything correctly got the pem, and changed the pushAPNS.rb file, when i run $ruby pushAPNS.rb am not getting any error but nothing is being sent, everything is working on android but not IOS

the certificates i have are for production HELPPPP

iOS 8 not receiving push notifications

I'm testing this out with a push to both an iOS 7 install and an iOS 8 install. The iOS 7 notifications are there but not iOS 8. Has anyone else run into this?

APNS.key and APNS.cert

Hello,

I'm stuck with the "NoMethodError: undefined method `close' for nil:NilClass" error, which I know is a .pem problem. However I have redone my .pem's 3 times without success.

As a sanity check I tried to connect from the console and it works like this with the key and cert separate.

$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert CorideCert.pem -key CorideDevKey.pem

I tried to concatinate these two pem files into one, but that gave the same "closed" error.

$ cat PushChatCert.pem PushChatKey.pem > ck.pem

I also tried "exporting both" from Keychain Access. This creates one .pem file but I still get the undefined method 'close' errror.

What should I do to get these two pem files into one?

On the other hand, wouldn't it just be easier and more explicit to set cert and key attributes separately as two files?

The tutorial http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 asks for key and cert separate, but you say to "export them together."

Thanks!

Development Mode

Hi,

I'm using your gem now and experienced some trouble in sending push notification. The problem that it always return 'nil' every time I tried.
Apparently, I'm using development certificate and the APNS.host should be 'gateway.sandbox.push.apple.com'. (See this https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ProvisioningDevelopment.html)

So, I just want to add suggestion maybe you can add information in the readme or description about APNS host for development mode (gateway.sandbox.push.apple.com) is not the same with production mode (gateway.push.apple.com). There is no big issue at all, it's just that I don't know where I can comment for other user having similar experience with me. Thanks :-)

uninitialized constant MPNS

While i'm trying to send push notification to windows phone 8 using

 pushUri = 'http://am3.notify.live.net/throttledthirdparty/01.00/XXXXXXXXXxxxXXXXXXX'
  title = 'My title'
  MPNS.send_notification(pushUri,title)

It throws error like uninitialized constant MPNS..Can anybody help me out of this?

send_notification (single notification!) is returning an array of responses

This is really minor, but I cracked my head here for half an hour figuring this out:

In gcm/core.rb, you use send_notifications (plural) inside send_notification (singular).

Problem is, the plural form expects multiple responses, and, rightly so, it delivers an array of responses.

But in send_notification (singular), the user would be expecting a single response object, in this method there's no reason to return an array, because there will be a single response for a single notification.

Change send_notification like so below and problem SHOULD be solved (didn't test):

def self.send_notification(device_tokens, data = {}, options = {})
  n = GCM::Notification.new(device_tokens, data, options)
  self.send_notifications([n])[0]
end

This might also apply to APNS and Microsoft, but I've only delved in GCM so far!

Thanks for the great gem!

Switch to FCM (Firebase Cloud Messaging)

Google is deprecating GCM so, it would be a good idea switching to FCM.

Google Cloud Messaging page:

As of April 10, 2018, Google has deprecated GCM. The GCM server and client APIs are deprecated and will be removed as soon as May 29, 2019. Migrate GCM apps to Firebase Cloud Messaging (FCM), which inherits the reliable and scalable GCM infrastructure, plus many new features. See the migration guide to learn more.

APNS.key and APNS.cert

Hello,

I'm stuck with the "NoMethodError: undefined method `close' for nil:NilClass" error, which I know is a .pem problem. However I have redone my .pem's 3 times without success.

Wouldn't it just be easier and more explicit to set cert and key attributes separately as two files?
The tutorial http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 asks for key and cert separate, but you say to "export them together."

Also you should say that the initialization code should go inside an initializer called pushmeup.rb. Good gem branding and more explicit.

Thanks!

Notification to multiple devices

Thanks for the easy to use gem. Can I use pushmeup to send a notification to multiple devices simultaneously? Is there a limit on the number of devices I can notify with one call? Are there any throttling requirements that I should be aware of?

Sending multiple Push APNS

Hi, sorry to bother, but i can't seem to be able to send multiple push notifications via APNS.

here is the code.

def sendIos()
  toPush = getAllPush('ios')
  if toPush.count >= 1
    APNS.start_persistence
    send = []

    toPush.each_with_index do |p, i|
      if p["token"].length == '64'.to_i
        puts 'sending IOS'
        send << APNS::Notification.new(p["token"], :alert => p["text"], :sound => p["sound"])
        deletePush(p["id"])
      else
        deletePush(p["id"])
      end
    end

    APNS.send_notifications(send)
    APNS.stop_persistence
  end
end

i have no error, the code it acts like if it sent the push without a problem. but i have both devices on my hand, and none of them gt the push notification, now if ther is only one push on the send array, then it works, but if there is more than one push on the array, then it dont work at all. can you plis help me?? thanks

GCM collapse_key (send-to-sync) not worked as expected

My understanding is that specifying a collapse_key (e.g. a chat room ID) will prevent duplicate notifications concerning that chat room from stacking up. If this is the intended behavior, this feature is not working.

Here's my implementation:

GCM.send_notification token, {alert: 'collapse_key test'}, {collapse_key: 'something_unique', time_to_live: 3600}

And the result:

screenshot_2015-03-09-11-21-13

Sending to multiple apps

I need the ability to send to different apps/devices from a single Rails application.

The certificate will be different for each push and the current Module doesn't make much sense for the way I do it.

Anyway any future plans for something like this?

class PusherIOS
  include APNS

  def initialize(gateway, port, certificate, passphrase)
    @host = gateway
    @port = port
    @pem  = certificate
    @pass = passphrase
  end
end

certificate = "#{Rails.root}/lib/development.pem"
passphrase = "dapassphrase"
gateway = "gateway.sandbox.push.apple.com"
port = 2195

pusher = PusherIOS.new(gateway, port, certificate, passphrase)

pusher.send_notification(d1.device_token, :alert => 'Hello iPhone!', :badge => 1, :sound => 'default',  :other => {:sent => 'with apns gem', :custom_param => "value"})

This is so we could use an object that is specific to a certificate/passphrase rather than a global module.

multiple push notification iOS

/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/commands/runner.rb:53:in eval': Broken pipe (Errno::EPIPE) from /usr/local/lib/ruby/2.1.0/openssl/buffering.rb:326:indo_write'
from /usr/local/lib/ruby/2.1.0/openssl/buffering.rb:344:in write' from /usr/local/lib/ruby/gems/2.1.0/gems/pushmeup-0.1.2/lib/pushmeup/apns/core.rb:26:inblock in send_notifications'
from /usr/local/lib/ruby/gems/2.1.0/gems/pushmeup-0.1.2/lib/pushmeup/apns/core.rb:25:in each' from /usr/local/lib/ruby/gems/2.1.0/gems/pushmeup-0.1.2/lib/pushmeup/apns/core.rb:25:insend_notifications'

this is happen when I try to send multiple notifications in average 3.000 notifications or more

GCM should return the headers on build_response method

GCM requires to use the 'Retry-After' header in case of error,
and the gem return the headers only when the response code is 200

In addition: the gem support only 500 and 503 response code
and in case the response code is 5xx (like 502..) - the gem return nil instead of the response.

see GCM documentation:
http://developer.android.com/google/gcm/server-ref.html
"5xx Errors in the 500-599 range (such as 500 or 503) indicate that there was an internal error in the GCM server while trying to process the request, or that the server is temporarily unavailable (for example, because of timeouts). Sender must retry later, honoring any Retry-After header included in the response..."

Not getting server response from server for ios

Hi
I Have used your gems,its working fine with android when i send notification i get response (success and error response if something wrong ) but in IOS push notification i am not getting any response from server because of that i dont know notification send successfully or not.Can u please tell how to get response from server
Thanks

Not able to send notification

Hi ,

I want to send notification form my client web app to mobile app. currently I'm working for IOS app.
My client provide me "cert.p12" file.
and I've generate a .pem file using your given command.

In my rails application, I've created a configuration file where I set the host, pem file path

APNS.host = 'gateway.sandbox.push.apple.com'

APNS.pem  = '/home/sumit/rails_work/billy/provision/cert.pem'

and now from my model I try to send notification with dummy devise token. for that I've write the following line

device_token = '123abc456def'
APNS.send_notification(device_token, 'Hello iPhone!' )

when the 'send_notification' method call, I've got the following error.

NoMethodError: undefined method `close' for nil:NilClass
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:83:in `rescue in with_connection'
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:72:in `with_connection'
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:42:in `block in send_notifications'
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `synchronize'
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:41:in `send_notifications'
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:37:in `send_notification'
from (irb):11
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/railties-4.0.8/lib/rails/commands/console.rb:90:in `start'
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/railties-4.0.8/lib/rails/commands/console.rb:9:in `start'
from /home/sumit/.rvm/gems/ruby-2.1.2@store/gems/railties-4.0.8/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

I'm a web developer, I've no Idea about mobile development.
Please let me know where I'm doing wrong.

pem file without certificates blows up hard

So I've been stumbling around the web trying to make APN keys. This involved running a lot of openssl commands by just cut-and-pasting things I saw on the web, without really understanding what I was doing. The fault is entirely mine, but I generated a .pem file that only had my encrypted RSA keys, and not my X509 certificates.

The retry logic in APNS.with_connection really flipped out here, and it got to the point where it even killed my db connection.

If would be nice if there was better handling of the error when it happened here:

context = OpenSSL::SSL::SSLContext.new
context.cert = OpenSSL::X509::Certificate.new(File.read(self.pem))
context.key = OpenSSL::PKey::RSA.new(File.read(self.pem), self.pass)

And instead of retrying when getting an error like:

2.1.4 :003 > OpenSSL::X509::Certificate.new(File.read("./radius-apn-production.pem.old"))
OpenSSL::X509::CertificateError: nested asn1 error
    from (irb):3:in `initialize'
    from (irb):3:in `new'
    from (irb):3
    from /Users/grant/.rvm/rubies/ruby-2.1.4/bin/irb:11:in `<main>'

pushmeup said that I had a bad/incomplete .pem file.

Getting undefined method `close` in apns/core.rb:83

Getting an error when trying to run "ruby pushAPNS.rb

/Users/me/.rvm/gems/ruby-1.9.3-p545@global/gems/pushmeup-0.2.0/lib/pushmeup/apns/core.rb:83:in `rescue in with_connection': undefined method `close' for nil:NilClass (NoMethodError)
    from /Users/me/.rvm/gems/ruby-1.9.3-p545@global/gems/pushmeup-0.2.0/lib/pushmeup/apns/core.rb:72:in `with_connection'
    from /Users/me/.rvm/gems/ruby-1.9.3-p545@global/gems/pushmeup-0.2.0/lib/pushmeup/apns/core.rb:42:in `block in send_notifications'
    from <internal:prelude>:10:in `synchronize'
    from /Users/me/.rvm/gems/ruby-1.9.3-p545@global/gems/pushmeup-0.2.0/lib/pushmeup/apns/core.rb:41:in `send_notifications'
    from /Users/me/.rvm/gems/ruby-1.9.3-p545@global/gems/pushmeup-0.2.0/lib/pushmeup/apns/core.rb:37:in `send_notification'
    from pushAPNS.rb:12:in `<main>'

me@MacBook- Pro.local:~/Documents/mobile/plugins/com.phonegap.plugins.PushPlugin/Example/server$

How to Send APNS Push notification to Multiple Application using same server.

Hi,

Can you please help us to know, how to send push notification to multiple iOS app from same server.
we have two iOS app with package name as
com.domainname.application1 and
com.domainname.application2.

If I want to originate push notification from same server as database is same for both the application then How I can send the notifications.

Any help would highly be appreciated.

Regards,
Praveen Agarwal

Error when running pushAPNS.rb

I added my stuff to config file, and when I run it on command line i get this:

<main>': undefined local variable or methodโ€˜' for main:Object (NameError)

The line i think it is referencing is the APNS.pem which is set to '/Users/name/Desktop/ck.pem'

Whats wrong?

Persistence not working properly

This is a chunk from my irb test. Can you tell me what I might be doing wrong or is the close method in conflict with persistence?

irb(main):007:0>APNS.start_persistence
=> true
irb(main):008:0> APNS.send_notification(device_token, 'tell me if you get this')
NoMethodError: undefined method close' for nil:NilClass from /home/guruninja/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:83:inrescue in with_connection'
from /home/guruninja/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/pushmeup-0.3.0/lib/pushmeup/apns/core.rb:72:in `with_connection'

APN and GCM with Proxy

Your gem works great,
but my server need to use proxy to connect internet.
How can I do? Need configs in rails or in gem's parameters, please help.

Do notifications get sent in testing environment?

I have some automated tests for testing asynchronous jobs with sidekiq that send push notifications.

They pass, but the device which should be getting the notifications is not receiving it (yes I am sure the test env is set up correctly and the token is correct)

Is it just that the push notifications do not get sent out in test env

Feedback service not working

Hi,

I'm using this gem for sending push notifications on IOS and it works fine for me. Now I need to use apple feedback service to know about the device tokens whose user has deleted the app but when I tried calling feedback function(APNS.feedback), it gives me blank array. As I've seen in the code I don't think I should explicitly need to do any configuration regarding host or post as it is already managed in core.rb but I'm not sure why I'm not able to receive device tokens in array. Is there any other configuration required? I'm assuming it will work fine for me using sandbox gateway i.e in development mode.

Please comment.

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.