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

publish with invalid registration_id fails with "no implicit conversion of String into Integer" #30

Open
sungsong88 opened this issue Dec 9, 2019 · 2 comments

Comments

@sungsong88
Copy link

My class:

### Data Used: {"content"=>"Aaaaaa", "repeat"=>nil, "repeat_unit"=>nil, "remind_at"=>nil, "completed_at"=>nil, "reminded_at"=>nil, :type=>"Reminder", :title=>"Reminder", :body=>"Aaaaaa", :sound=>"default"}

class NotificationService::EXPO < NotificationService

  delegate :app, to: self

  def self.app
    @app ||= Exponent::Push::Client.new
  end

  def notify(notification)
    data = notification.push_notification_data
    app.publish({
      to: registration_id,
      sound: "default",
      title: data[:title],
      body: data[:body],
      badge: user.total_counts["notifications"],
      data: data
    })
  end

end

When registration_id is not valid anymore because the EXPO app that has that registration_id is removed from the device, it fails with:

ETHON: performed EASY effective_url=https://exp.host/--/api/v2/push/send response_code=200 return_code=ok total_time=9.14811
TypeError: no implicit conversion of String into Integer
	from app/models/notification_service/expo.rb:34:in `notify'
	from (irb):218

For now, I'm going to begin rescue that chunk.

Is there a way I can avoid that error? I can't seem to find what causes the problem.

The data I used is {"content"=>"Aaaaaa", "repeat"=>nil, "repeat_unit"=>nil, "remind_at"=>nil, "completed_at"=>nil, "reminded_at"=>nil, :type=>"Reminder", :title=>"Reminder", :body=>"Aaaaaa", :sound=>"default"}

@felixletkemann
Copy link

I have got the same issue here!

@sungsong88
Copy link
Author

+1 This issue is driving me crazy...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants