Skip to content

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

@sungsong88

Description

@sungsong88

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"}

Activity

felixletkemann

felixletkemann commented on Apr 30, 2020

@felixletkemann

I have got the same issue here!

sungsong88

sungsong88 commented on Jun 11, 2020

@sungsong88
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sungsong88@felixletkemann

        Issue actions

          publish with invalid registration_id fails with "no implicit conversion of String into Integer" · Issue #30 · expo-community/expo-server-sdk-ruby