codedge-llc / pigeon

iOS and Android push notifications for Elixir
https://hex.pm/packages/pigeon
MIT License
645 stars 145 forks source link

Status success with not_registered response #191

Closed matteo-gheri-pocketworks closed 3 years ago

matteo-gheri-pocketworks commented 3 years ago

Environment

1.11.2-otp-22 {:pigeon, "~> 1.6.0"},

Current behavior

Hello, I'm getting a weird response:

%Pigeon.FCM.Notification{collapse_key: nil, condition: nil, content_available: false, dry_run: false, message_id: nil, mutable_content: false, payload: %{"notification" => %{"body" => "Your BigPoints claim against 1024640 is ready for approval!"}}, priority: :normal, registration_id: "REG_ID_TOKEN", response: [not_registered: "REG_ID_TOKEN"], restricted_package_name: nil, status: :success, time_to_live: 2419200}

Expected behavior

def send_push_notification(device_token, message) do Pigeon.FCM.Notification.new(device_token, %{"body" => message}) |> Pigeon.FCM.push(on_response: &response_handler/1) end

But as the notification is not sent to Firebase I was expecting to get 'status: :error' not :success

Thank you.

hpopp commented 3 years ago

This is actually expected behavior. status: :success means that FCM successfully received the request. Each reg ID in a batch can have a different responses where some succeed, some fail, and others have a new reg ID that needs to be persisted.

In your case, that one should be removed. More details here about handling responses.