Closed nbastoWM closed 3 years ago
+1
same problem
Hey, how did you solved this problem?
Hi.
My code is working like this:
Before the class declaration:
require 'houston'
Then:
def send_ios_push_notification(title, text, type, param, sent_notification_id)
apn = Houston::Client.development
# manter este ficheiro na raiz do projecto
file = File.join(Rails.root, 'mycity_certificate.pem')
apn.certificate = File.read(file)
# Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app
notification = Houston::Notification.new(device: self.token)
notification.alert = title
# Notifications can also change the badge count, have a custom sound, have a category identifier, indicate available Newsstand content, or pass along arbitrary data.
unviewed_notifications = user.sent_push_notifications.where('viewed = false').count
notification.badge = unviewed_notifications
notification.sound = "default"
notification.category = "REACT_NATIVE"
notification.content_available = true
notification.custom_data = { text: text,
type: type,
param: param,
sent_notification_id: sent_notification_id
}
# And... send!
apn.push(notification)
end
Thanks for your response I put require 'houston'
before the class declaration but I still get the error "cannot load such file -- houston". Do you any idea why is this happening?
It is working fine in my local machine but when I deployed it to the server it is then I am getting this error.
@genarolaunchlabs can you show your Gemfile and how you add gem houston in it?
here's my Gemfile
`source 'https://rubygems.org'
gem 'rails', '4.2.6' gem 'pg', '>= 0.14.1' gem 'devise', '~> 4.1', '>= 4.1.1' gem 'geocoder' gem 'mailboxer', :git => 'git://github.com/div/mailboxer.git', :branch => 'rails42-foreigner' gem 'unicorn' gem 'houston' gem 'awesome_print', '~> 1.6', '>= 1.6.1'
gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do gem 'byebug' end
group :development do gem 'web-console', '~> 2.0' gem 'spring' end
`
I check houston if it is installed by gem list houston and the result: `* LOCAL GEMS *
houston (2.2.3)`
Hi, I've installed the gem as instructed, confirmed that the command line tool is working correctly with my certificate file, but when I add the usage sample code to a controller I get a couple of errors.
At first, if I use "APN" capitalized I get this error:
So I changed to lower case "apn".
Then I get this error:
I found out that the gem was not in Gemfile so I wrote a line with "gem 'houston' ". I also tried forcing the version - "gem 'houston', "~>2.2.3" " but the error persists. I just use the code as instructed:
What am I doing wrong? Thanks.