-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
I keep getting :bad_device_token for APN #164
Comments
Slightly unrelated, but depending on how I pass in the token my argument error: [[], {:jose_jws, {:jose_jws_alg_ecdsa, :ES256}, :undefined, %{"kid" => "...", "typ" => "JWT"}}, %{"aud" => "Joken", "exp" => ..., "iat" => ..., "iss" => "...", "jti" => "...", "nbf" => ...}] |
If you're using firebase, use FCM notifications for all push notifications, even iOS devices. APNS workers talk to Apple servers, which would reject the device token you've sent. |
@hpopp does that mean I only have to set-up FCM then? I don't think I see it in the docs, do you have an example perhaps? Thanks! Also, why would the Apple servers reject the token I sent? What's wrong with that token? |
Think about it this way... if Firebase on Google servers was the one issuing device tokens, Apple servers wouldn't know anything about it. Using FCM for iOS is not something I personally use in production, but I have verified that it does indeed work. You'll notice that some of the helper functions in FCM.Notification are iOS-specific. I don't have an actual guide for this, but perhaps I should write one. |
Ah, I thought the the device tokens were Apple's tokens. I thought it didn't matter how the token was retrieved, because ultimately it's a "device token" that belongs to the device. Looks like I'm wrong? Yeah a guide would be immensely helpful, I'm going to try it out and see how to get it to work, thanks for the pointers! Hopefully this works |
I just gave it a go and I got it under 30 minutes. It was incredibly easy, I spent so much time figuring out why the token was bad turns out this whole time I had a FCM token instead of an iOS token.. Thanks for the help @hpopp! Anyway, here's a code snippet for people who stumble upon this and want to send notification to APN via FCM: body = %{"title" => title, "body" => message}
Pigeon.FCM.Notification.new(token)
|> Pigeon.FCM.Notification.put_notification(body)
|> Pigeon.FCM.Notification.put_content_available(true)
|> Pigeon.FCM.push() That's literally all you need to do to send notifications to iOS. No need to fuss around with APN settings! |
Environment
elixir --version
): Elixir 1.9.1 (compiled with Erlang/OTP 20), Erlang/OTP 22Current behavior
I've been trying to just send a notification to my iOS device and it hasn't been working. Android worked fine, but for iOS it just never worked. I use runtime config, like so:
My frontend is Flutter, I'm using Google's
firebase_messasing
package to get the device token.Here's how I am sending the notification:
and the response:
Expected behavior
I expect it to send notification to my iOS device
The text was updated successfully, but these errors were encountered: